Skip to content

Commit

Permalink
省略されたノートを一定の行まで表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Oct 18, 2023
1 parent 503bcce commit 4773fc0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 72 deletions.
6 changes: 6 additions & 0 deletions lib/view/common/misskey_notes/mfm_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class MfmText extends ConsumerStatefulWidget {
final List<InlineSpan> prefixSpan;
final Function(MisskeyEmojiData)? onEmojiTap;
final bool isEnableAnimatedMFM;
final TextOverflow? overflow;
final int? maxLines;

const MfmText({
super.key,
Expand All @@ -45,6 +47,8 @@ class MfmText extends ConsumerStatefulWidget {
this.prefixSpan = const [],
this.onEmojiTap,
this.isEnableAnimatedMFM = true,
this.overflow,
this.maxLines,
}) : assert(mfmText != null || mfmNode != null);

@override
Expand Down Expand Up @@ -221,6 +225,8 @@ class MfmTextState extends ConsumerState<MfmText> {
suffixSpan: widget.suffixSpan,
prefixSpan: widget.prefixSpan,
isUseAnimation: widget.isEnableAnimatedMFM,
overflow: widget.overflow,
maxLines: widget.maxLines,
);
}
}
Expand Down
130 changes: 58 additions & 72 deletions lib/view/common/misskey_notes/misskey_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,81 +409,67 @@ class MisskeyNoteState extends ConsumerState<MisskeyNote> {
],
if (displayNote.cw == null ||
displayNote.cw != null && isCwOpened) ...[
if (isReactionedRenote)
SimpleMfmText(
"${(displayNote.text ?? "").substring(0, min((displayNote.text ?? "").length, 50))}..."
.replaceAll("\n\n", "\n"),
emojis: displayNote.emojis,
suffixSpan: [
WidgetSpan(
child: InNoteButton(
onPressed: () {
ref
.read(notesProvider(
AccountScope.of(context)))
.updateNoteStatus(
widget.note.id,
(status) => status.copyWith(
isReactionedRenote: !status
.isReactionedRenote),
);
},
child: const Text("続きを表示"),
MfmText(
mfmNode: displayTextNodes,
host: displayNote.user.host,
emoji: displayNote.emojis,
isEnableAnimatedMFM: ref
.read(generalSettingsRepositoryProvider)
.settings
.enableAnimatedMFM,
onEmojiTap: (emojiData) async =>
await reactionControl(
ref,
context,
displayNote,
requestEmoji: emojiData,
),
overflow: TextOverflow.fade,
suffixSpan: [
if (!isEmptyRenote &&
displayNote.renoteId != null &&
(widget.recursive == 2 ||
widget.isForceUnvisibleRenote))
TextSpan(
text: " RN:...",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontStyle: FontStyle.italic,
),
)
],
)
else ...[
if (isLongVisible)
MfmText(
mfmNode: displayTextNodes,
host: displayNote.user.host,
emoji: displayNote.emojis,
isEnableAnimatedMFM: ref
.read(generalSettingsRepositoryProvider)
.settings
.enableAnimatedMFM,
onEmojiTap: (emojiData) async =>
await reactionControl(
ref, context, displayNote,
requestEmoji: emojiData),
suffixSpan: [
if (!isEmptyRenote &&
displayNote.renoteId != null &&
(widget.recursive == 2 ||
widget.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,
suffixSpan: [
WidgetSpan(
child: InNoteButton(
onPressed: () {
ref
.read(notesProvider(
AccountScope.of(context)))
.updateNoteStatus(
widget.note.id,
(status) => status.copyWith(
isLongVisible: !status
.isLongVisible));
},
child: const Text("続きを表示"),
),
],
maxLines: isReactionedRenote
? 1
: isLongVisible
? null
: 10,
),
if (isReactionedRenote || !isLongVisible)
Center(
child: InNoteButton(
onPressed: () {
final repository = ref.read(
notesProvider(
AccountScope.of(context),
),
)
],
);
repository.updateNoteStatus(
widget.note.id,
(status) => isReactionedRenote
? status.copyWith(
isReactionedRenote:
!status.isReactionedRenote,
)
: status.copyWith(
isLongVisible:
!status.isLongVisible,
),
);
},
child: const Text("続きを表示"),
),
),
if (!isReactionedRenote) ...[
MisskeyFileView(
files: displayNote.files,
height: 200 *
Expand Down

0 comments on commit 4773fc0

Please sign in to comment.