这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/util/get_note_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import '../view/widget/emoji_picker.dart';
import '../view/widget/note_sheet.dart';
import 'future_with_dialog.dart';

void Function()? getNoteAction(
WidgetRef ref, {
void Function(WidgetRef ref)? getNoteAction({
required Account account,
required NoteActionType type,
required Note note,
Expand All @@ -25,10 +24,10 @@ void Function()? getNoteAction(
}
return switch (type) {
NoteActionType.none => null,
NoteActionType.expand => () => ref.context.push(
NoteActionType.expand => (ref) => ref.context.push(
'/$account/notes/${appearNote.id}',
),
NoteActionType.menu => () => showNoteSheet(
NoteActionType.menu => (ref) => showNoteSheet(
context: ref.context,
account: account,
noteId: note.id,
Expand All @@ -37,7 +36,7 @@ void Function()? getNoteAction(
),
NoteActionType.reaction =>
!account.isGuest
? () async {
? (ref) async {
final emoji =
appearNote.reactionAcceptance == ReactionAcceptance.likeOnly
? '❤'
Expand Down
42 changes: 42 additions & 0 deletions lib/view/widget/deleted_note_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'dart:math';

import 'package:flutter/material.dart';

import '../../i18n/strings.g.dart';

class DeletedNoteWidget extends StatelessWidget {
const DeletedNoteWidget({
super.key,
this.borderRadius = const BorderRadius.all(Radius.circular(16.0)),
});

final BorderRadiusGeometry? borderRadius;

@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
borderRadius: borderRadius,
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.center,
colors: [
Colors.transparent,
Colors.transparent,
Color.fromRGBO(158, 158, 158, 0.1),
Color.fromRGBO(158, 158, 158, 0.1),
],
stops: [0.0, 0.7, 0.7, 1.0],
tileMode: TileMode.repeated,
transform: GradientRotation(-pi / 4),
),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(t.misskey.deletedNote),
),
),
);
}
}
138 changes: 138 additions & 0 deletions lib/view/widget/deleted_renote_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart' hide Clip;

import '../../model/account.dart';
import '../../model/general_settings.dart';
import '../../provider/general_settings_notifier_provider.dart';
import 'channel_color_bar_box.dart';
import 'deleted_note_widget.dart';
import 'note_sheet.dart';
import 'renote_header.dart';

class DeletedRenoteWidget extends HookConsumerWidget {
const DeletedRenoteWidget({
super.key,
required this.account,
required this.note,
this.backgroundColor,
this.borderRadius,
});

final Account account;
final Note note;
final Color? backgroundColor;
final BorderRadiusGeometry? borderRadius;

void Function(BuildContext context)? _getNoteAction(NoteActionType type) {
if (note.id.isEmpty) {
return null;
}
return switch (type) {
NoteActionType.none => null,
NoteActionType.expand => (context) => context.push(
'/$account/notes/${note.id}',
),
NoteActionType.menu => (context) => showNoteSheet(
context: context,
account: account,
noteId: note.id,
),
NoteActionType.reaction => null,
};
}

@override
Widget build(BuildContext context, WidgetRef ref) {
final (
verticalPadding,
horizontalPadding,
showAvatars,
tapAction,
doubleTapAction,
longPressAction,
noteBackgroundColor,
) = ref.watch(
generalSettingsNotifierProvider.select(
(settings) => (
settings.noteVerticalPadding,
settings.noteHorizontalPadding,
settings.showAvatarsInNote,
settings.noteTapAction,
settings.noteDoubleTapAction,
settings.noteLongPressAction,
switch (note.visibility) {
NoteVisibility.public => settings.publicNoteBackgroundColor,
NoteVisibility.home => settings.homeNoteBackgroundColor,
NoteVisibility.followers => settings.followersNoteBackgroundColor,
NoteVisibility.specified => settings.specifiedNoteBackgroundColor,
null => null,
},
),
),
);
final onTap = useMemoized(() => _getNoteAction(tapAction), [
account,
tapAction,
note.id,
]);
final onDoubleTap = useMemoized(() => _getNoteAction(doubleTapAction), [
account,
doubleTapAction,
note.id,
]);
final onLongPress = useMemoized(() => _getNoteAction(longPressAction), [
account,
longPressAction,
note.id,
]);
final backgroundColor = this.backgroundColor ?? noteBackgroundColor;
final theme = Theme.of(context);

return Material(
color: backgroundColor ?? theme.colorScheme.surface,
clipBehavior: Clip.hardEdge,
borderRadius: borderRadius,
child: InkWell(
onTap: onTap != null ? () => onTap(context) : null,
onDoubleTap: onDoubleTap != null ? () => onDoubleTap(context) : null,
onLongPress: onLongPress != null ? () => onLongPress(context) : null,
child: Padding(
padding: EdgeInsetsDirectional.only(
start: 4.0,
top: verticalPadding,
end: horizontalPadding,
bottom: verticalPadding,
),
child: Column(
children: [
ChannelColorBarBox(
note: note,
child: Padding(
padding: EdgeInsetsDirectional.only(
start: horizontalPadding - 4.0,
),
child: RenoteHeader(
account: account,
noteId: note.id,
onTap: () => context.push('/$account/notes/${note.id}'),
onLongPress: () => showNoteSheet(
context: context,
account: account,
noteId: note.id,
renote: true,
),
),
),
),
const SizedBox(height: 4.0),
const DeletedNoteWidget(),
],
),
),
),
);
}
}
23 changes: 16 additions & 7 deletions lib/view/widget/muted_note_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,26 @@ class MutedNoteWidget extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final (verticalPadding, horizontalPadding) = ref.watch(
final (verticalPadding, horizontalPadding, noteBackgroundColor) = ref.watch(
generalSettingsNotifierProvider.select(
(settings) =>
(settings.noteVerticalPadding, settings.noteHorizontalPadding),
(settings) => (
settings.noteVerticalPadding,
settings.noteHorizontalPadding,
switch (note.visibility) {
NoteVisibility.public => settings.publicNoteBackgroundColor,
NoteVisibility.home => settings.homeNoteBackgroundColor,
NoteVisibility.followers => settings.followersNoteBackgroundColor,
NoteVisibility.specified => settings.specifiedNoteBackgroundColor,
null => null,
},
),
),
);
final backgroundColor = this.backgroundColor ?? noteBackgroundColor;
final theme = Theme.of(context);

return Material(
color: Theme.of(context).colorScheme.surface,
color: backgroundColor ?? theme.colorScheme.surface,
clipBehavior: Clip.hardEdge,
borderRadius: borderRadius,
child: InkWell(
Expand All @@ -51,9 +62,7 @@ class MutedNoteWidget extends ConsumerWidget {
builder: (context, span) => Text.rich(
t.aria.userSaysSomething(name: span),
style: TextStyle(
color: Theme.of(
context,
).colorScheme.onSurface.withValues(alpha: 0.7),
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
),
textAlign: TextAlign.center,
),
Expand Down
Loading
Loading