Skip to content

Commit

Permalink
省略されたノートを一定の行まで表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Nov 9, 2024
1 parent 47cefb3 commit d42bb59
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 55 deletions.
96 changes: 42 additions & 54 deletions lib/view/common/misskey_notes/misskey_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -599,64 +599,52 @@ class MisskeyNote extends HookConsumerWidget {
],
if (displayNote.cw == null ||
displayNote.cw != null && isCwOpened) ...[
if (isReactionedRenote)
SimpleMfmText(
"${(displayNote.text ?? "").substring(0, min((displayNote.text ?? "").length, 50))}..."
.replaceAll("\n\n", "\n"),
isNyaize: displayNote.user.isCat,
emojis: displayNote.emojis,
suffixSpan: [
WidgetSpan(
child: InNoteButton(
onPressed: toggleReactionedRenote,
child: Text(S.of(context).showReactionedNote),
MfmText(
mfmNode: displayTextNodes,
host: displayNote.user.host,
emoji: displayNote.emojis,
isNyaize: displayNote.user.isCat,
isEnableAnimatedMFM: ref
.read(generalSettingsRepositoryProvider)
.settings
.enableAnimatedMFM,
onEmojiTap: (emojiData) async =>
await reactionControl(
requestEmoji: emojiData,
),
suffixSpan: [
if (!isEmptyRenote &&
displayNote.renoteId != null &&
(recursive == 2 || isForceUnvisibleRenote))
TextSpan(
text: " RN:...",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontStyle: FontStyle.italic,
),
),
],
],
maxLines: isReactionedRenote
? 1
: isLongVisible
? null
: 10,
),
if (isReactionedRenote)
Center(
child: InNoteButton(
onPressed: toggleReactionedRenote,
child: Text(S.of(context).showReactionedNote),
),
)
else ...[
if (isLongVisible)
MfmText(
mfmNode: displayTextNodes,
host: displayNote.user.host,
emoji: displayNote.emojis,
isNyaize: displayNote.user.isCat,
isEnableAnimatedMFM: ref
.read(generalSettingsRepositoryProvider)
.settings
.enableAnimatedMFM,
onEmojiTap: (emojiData) async =>
await reactionControl(
requestEmoji: emojiData,
),
suffixSpan: [
if (!isEmptyRenote &&
displayNote.renoteId != null &&
(recursive == 2 || isForceUnvisibleRenote))
TextSpan(
text: " RN:...",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontStyle: FontStyle.italic,
),
),
],
)
else
SimpleMfmText(
"${(displayNote.text ?? "").substring(0, min((displayNote.text ?? "").length, 150))}..."
.replaceAll("\n\n", "\n"),
emojis: displayNote.emojis,
isNyaize: displayNote.user.isCat,
suffixSpan: [
WidgetSpan(
child: InNoteButton(
onPressed: toggleLongNote,
child: Text(S.of(context).showLongText),
),
),
],
else if (!isLongVisible)
Center(
child: InNoteButton(
onPressed: toggleLongNote,
child: Text(S.of(context).showLongText),
),
),
if (!isReactionedRenote) ...[
MisskeyFileView(
files: displayNote.files,
height: 200 * pow(0.5, recursive - 1).toDouble(),
Expand Down
2 changes: 1 addition & 1 deletion test/view/common/misskey_notes/misskey_notes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ System.out.println("@ai uneune");
),
);
await tester.pumpAndSettle();
expect(find.textContaining(longText, findRichText: true), findsNothing);
await tester.tap(find.text("続きを表示"));
await tester.pumpAndSettle();
expect(find.text("続きを表示"), findsNothing);
expect(
find.textContaining(longText, findRichText: true),
findsOneWidget,
Expand Down

0 comments on commit d42bb59

Please sign in to comment.