Skip to content

Commit 79167f5

Browse files
committed
add keys to improve layout shifts
1 parent d7b0ee9 commit 79167f5

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

lib/presentation_layer/components/note_card/name_row.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import 'package:camelus/config/palette.dart';
2-
import 'package:camelus/domain_layer/entities/user_metadata.dart';
3-
import 'package:camelus/helpers/helpers.dart';
4-
import 'package:camelus/presentation_layer/atoms/nip_05_text.dart';
5-
import 'package:camelus/presentation_layer/providers/nip05_provider.dart';
61
import 'package:flutter/material.dart';
7-
import 'package:flutter_svg/flutter_svg.dart';
2+
83
import 'package:hooks_riverpod/hooks_riverpod.dart';
94
import 'package:intl/intl.dart';
105
import 'package:timeago/timeago.dart' as timeago;
116

7+
import '../../../config/palette.dart';
8+
import '../../../domain_layer/entities/user_metadata.dart';
9+
import '../../../helpers/helpers.dart';
10+
import '../../atoms/nip_05_text.dart';
11+
1212
class NoteCardNameRow extends ConsumerStatefulWidget {
1313
final UserMetadata? myMetadata;
1414
final String pubkey;
@@ -86,6 +86,7 @@ class _NoteCardNameRowState extends ConsumerState<NoteCardNameRow> {
8686
],
8787
),
8888
Nip05Text(
89+
key: widget.key,
8990
pubkey: widget.pubkey,
9091
nip05verified: widget.myMetadata?.nip05,
9192
),

lib/presentation_layer/components/note_card/note_card.dart

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,23 @@ class NoteCard extends StatelessWidget {
4747
child: Column(
4848
crossAxisAlignment: CrossAxisAlignment.start,
4949
children: [
50-
_buildNameRow(context),
50+
NoteCardNameRow(
51+
key: ValueKey("${note.id}name_row"),
52+
createdAt: note.created_at,
53+
myMetadata: myMetadata,
54+
pubkey: note.pubkey,
55+
),
5156
const SizedBox(height: 10),
52-
_buildNoteContent(context),
57+
NoteCardSplitContent(
58+
key: ValueKey("${note.id}split_content"),
59+
note: note,
60+
profileCallback: (String pubkey) => Navigator.pushNamed(
61+
context, "/nostr/profile",
62+
arguments: pubkey),
63+
hashtagCallback: (String hashtag) => Navigator.pushNamed(
64+
context, "/nostr/hastag",
65+
arguments: hashtag),
66+
),
5367
],
5468
),
5569
),
@@ -112,24 +126,6 @@ class NoteCard extends StatelessWidget {
112126
);
113127
}
114128

115-
Widget _buildNameRow(BuildContext context) {
116-
return NoteCardNameRow(
117-
createdAt: note.created_at,
118-
myMetadata: myMetadata,
119-
pubkey: note.pubkey,
120-
);
121-
}
122-
123-
Widget _buildNoteContent(BuildContext context) {
124-
return NoteCardSplitContent(
125-
note: note,
126-
profileCallback: (String pubkey) =>
127-
Navigator.pushNamed(context, "/nostr/profile", arguments: pubkey),
128-
hashtagCallback: (String hashtag) =>
129-
Navigator.pushNamed(context, "/nostr/hastag", arguments: hashtag),
130-
);
131-
}
132-
133129
Widget _buildBottomActionRow(BuildContext context) {
134130
return BottomActionRow(
135131
key: ValueKey("${note.id}bottom_action_row"),

0 commit comments

Comments
 (0)