diff --git a/lib/model/general_settings.dart b/lib/model/general_settings.dart index c90d21d0..c2450f54 100644 --- a/lib/model/general_settings.dart +++ b/lib/model/general_settings.dart @@ -67,6 +67,10 @@ class GeneralSettings with _$GeneralSettings { @Default(1.0) double noteFooterScale, @Default(defaultNoteVerticalPadding) double noteVerticalPadding, @Default(defaultNoteHorizontalPadding) double noteHorizontalPadding, + @ColorConverter() Color? publicNoteBackgroundColor, + @ColorConverter() Color? homeNoteBackgroundColor, + @ColorConverter() Color? followersNoteBackgroundColor, + @ColorConverter() Color? specifiedNoteBackgroundColor, // Emoji picker @Default(false) bool emojiPickerUseDialog, @@ -133,3 +137,17 @@ enum NoteActionType { menu, reaction, } + +class ColorConverter extends JsonConverter { + const ColorConverter(); + + @override + Color fromJson(int json) { + return Color(json); + } + + @override + int toJson(Color color) { + return color.value; + } +} diff --git a/lib/model/general_settings.freezed.dart b/lib/model/general_settings.freezed.dart index 5d028d6a..8be7b0dc 100644 --- a/lib/model/general_settings.freezed.dart +++ b/lib/model/general_settings.freezed.dart @@ -55,7 +55,15 @@ mixin _$GeneralSettings { bool get limitWidthOfReaction => throw _privateConstructorUsedError; double get noteFooterScale => throw _privateConstructorUsedError; double get noteVerticalPadding => throw _privateConstructorUsedError; - double get noteHorizontalPadding => + double get noteHorizontalPadding => throw _privateConstructorUsedError; + @ColorConverter() + Color? get publicNoteBackgroundColor => throw _privateConstructorUsedError; + @ColorConverter() + Color? get homeNoteBackgroundColor => throw _privateConstructorUsedError; + @ColorConverter() + Color? get followersNoteBackgroundColor => throw _privateConstructorUsedError; + @ColorConverter() + Color? get specifiedNoteBackgroundColor => throw _privateConstructorUsedError; // Emoji picker bool get emojiPickerUseDialog => throw _privateConstructorUsedError; double get emojiPickerScale => throw _privateConstructorUsedError; @@ -135,6 +143,10 @@ abstract class $GeneralSettingsCopyWith<$Res> { double noteFooterScale, double noteVerticalPadding, double noteHorizontalPadding, + @ColorConverter() Color? publicNoteBackgroundColor, + @ColorConverter() Color? homeNoteBackgroundColor, + @ColorConverter() Color? followersNoteBackgroundColor, + @ColorConverter() Color? specifiedNoteBackgroundColor, bool emojiPickerUseDialog, double emojiPickerScale, bool emojiPickerAutofocus, @@ -211,6 +223,10 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings> Object? noteFooterScale = null, Object? noteVerticalPadding = null, Object? noteHorizontalPadding = null, + Object? publicNoteBackgroundColor = freezed, + Object? homeNoteBackgroundColor = freezed, + Object? followersNoteBackgroundColor = freezed, + Object? specifiedNoteBackgroundColor = freezed, Object? emojiPickerUseDialog = null, Object? emojiPickerScale = null, Object? emojiPickerAutofocus = null, @@ -370,6 +386,22 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings> ? _value.noteHorizontalPadding : noteHorizontalPadding // ignore: cast_nullable_to_non_nullable as double, + publicNoteBackgroundColor: freezed == publicNoteBackgroundColor + ? _value.publicNoteBackgroundColor + : publicNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + homeNoteBackgroundColor: freezed == homeNoteBackgroundColor + ? _value.homeNoteBackgroundColor + : homeNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + followersNoteBackgroundColor: freezed == followersNoteBackgroundColor + ? _value.followersNoteBackgroundColor + : followersNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + specifiedNoteBackgroundColor: freezed == specifiedNoteBackgroundColor + ? _value.specifiedNoteBackgroundColor + : specifiedNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, emojiPickerUseDialog: null == emojiPickerUseDialog ? _value.emojiPickerUseDialog : emojiPickerUseDialog // ignore: cast_nullable_to_non_nullable @@ -532,6 +564,10 @@ abstract class _$$GeneralSettingsImplCopyWith<$Res> double noteFooterScale, double noteVerticalPadding, double noteHorizontalPadding, + @ColorConverter() Color? publicNoteBackgroundColor, + @ColorConverter() Color? homeNoteBackgroundColor, + @ColorConverter() Color? followersNoteBackgroundColor, + @ColorConverter() Color? specifiedNoteBackgroundColor, bool emojiPickerUseDialog, double emojiPickerScale, bool emojiPickerAutofocus, @@ -606,6 +642,10 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res> Object? noteFooterScale = null, Object? noteVerticalPadding = null, Object? noteHorizontalPadding = null, + Object? publicNoteBackgroundColor = freezed, + Object? homeNoteBackgroundColor = freezed, + Object? followersNoteBackgroundColor = freezed, + Object? specifiedNoteBackgroundColor = freezed, Object? emojiPickerUseDialog = null, Object? emojiPickerScale = null, Object? emojiPickerAutofocus = null, @@ -765,6 +805,22 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res> ? _value.noteHorizontalPadding : noteHorizontalPadding // ignore: cast_nullable_to_non_nullable as double, + publicNoteBackgroundColor: freezed == publicNoteBackgroundColor + ? _value.publicNoteBackgroundColor + : publicNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + homeNoteBackgroundColor: freezed == homeNoteBackgroundColor + ? _value.homeNoteBackgroundColor + : homeNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + followersNoteBackgroundColor: freezed == followersNoteBackgroundColor + ? _value.followersNoteBackgroundColor + : followersNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, + specifiedNoteBackgroundColor: freezed == specifiedNoteBackgroundColor + ? _value.specifiedNoteBackgroundColor + : specifiedNoteBackgroundColor // ignore: cast_nullable_to_non_nullable + as Color?, emojiPickerUseDialog: null == emojiPickerUseDialog ? _value.emojiPickerUseDialog : emojiPickerUseDialog // ignore: cast_nullable_to_non_nullable @@ -922,6 +978,10 @@ class _$GeneralSettingsImpl implements _GeneralSettings { this.noteFooterScale = 1.0, this.noteVerticalPadding = defaultNoteVerticalPadding, this.noteHorizontalPadding = defaultNoteHorizontalPadding, + @ColorConverter() this.publicNoteBackgroundColor, + @ColorConverter() this.homeNoteBackgroundColor, + @ColorConverter() this.followersNoteBackgroundColor, + @ColorConverter() this.specifiedNoteBackgroundColor, this.emojiPickerUseDialog = false, this.emojiPickerScale = 1.0, this.emojiPickerAutofocus = true, @@ -1053,6 +1113,18 @@ class _$GeneralSettingsImpl implements _GeneralSettings { @override @JsonKey() final double noteHorizontalPadding; + @override + @ColorConverter() + final Color? publicNoteBackgroundColor; + @override + @ColorConverter() + final Color? homeNoteBackgroundColor; + @override + @ColorConverter() + final Color? followersNoteBackgroundColor; + @override + @ColorConverter() + final Color? specifiedNoteBackgroundColor; // Emoji picker @override @JsonKey() @@ -1147,7 +1219,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings { @override String toString() { - return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, disableShowingAnimatedImages: $disableShowingAnimatedImages, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarOnBottom: $showTimelineTabBarOnBottom, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)'; + return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, publicNoteBackgroundColor: $publicNoteBackgroundColor, homeNoteBackgroundColor: $homeNoteBackgroundColor, followersNoteBackgroundColor: $followersNoteBackgroundColor, specifiedNoteBackgroundColor: $specifiedNoteBackgroundColor, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, disableShowingAnimatedImages: $disableShowingAnimatedImages, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarOnBottom: $showTimelineTabBarOnBottom, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)'; } @override @@ -1217,6 +1289,10 @@ class _$GeneralSettingsImpl implements _GeneralSettings { (identical(other.noteFooterScale, noteFooterScale) || other.noteFooterScale == noteFooterScale) && (identical(other.noteVerticalPadding, noteVerticalPadding) || other.noteVerticalPadding == noteVerticalPadding) && (identical(other.noteHorizontalPadding, noteHorizontalPadding) || other.noteHorizontalPadding == noteHorizontalPadding) && + (identical(other.publicNoteBackgroundColor, publicNoteBackgroundColor) || other.publicNoteBackgroundColor == publicNoteBackgroundColor) && + (identical(other.homeNoteBackgroundColor, homeNoteBackgroundColor) || other.homeNoteBackgroundColor == homeNoteBackgroundColor) && + (identical(other.followersNoteBackgroundColor, followersNoteBackgroundColor) || other.followersNoteBackgroundColor == followersNoteBackgroundColor) && + (identical(other.specifiedNoteBackgroundColor, specifiedNoteBackgroundColor) || other.specifiedNoteBackgroundColor == specifiedNoteBackgroundColor) && (identical(other.emojiPickerUseDialog, emojiPickerUseDialog) || other.emojiPickerUseDialog == emojiPickerUseDialog) && (identical(other.emojiPickerScale, emojiPickerScale) || other.emojiPickerScale == emojiPickerScale) && (identical(other.emojiPickerAutofocus, emojiPickerAutofocus) || other.emojiPickerAutofocus == emojiPickerAutofocus) && @@ -1284,6 +1360,10 @@ class _$GeneralSettingsImpl implements _GeneralSettings { noteFooterScale, noteVerticalPadding, noteHorizontalPadding, + publicNoteBackgroundColor, + homeNoteBackgroundColor, + followersNoteBackgroundColor, + specifiedNoteBackgroundColor, emojiPickerUseDialog, emojiPickerScale, emojiPickerAutofocus, @@ -1365,6 +1445,10 @@ abstract class _GeneralSettings implements GeneralSettings { final double noteFooterScale, final double noteVerticalPadding, final double noteHorizontalPadding, + @ColorConverter() final Color? publicNoteBackgroundColor, + @ColorConverter() final Color? homeNoteBackgroundColor, + @ColorConverter() final Color? followersNoteBackgroundColor, + @ColorConverter() final Color? specifiedNoteBackgroundColor, final bool emojiPickerUseDialog, final double emojiPickerScale, final bool emojiPickerAutofocus, @@ -1464,6 +1548,18 @@ abstract class _GeneralSettings implements GeneralSettings { double get noteVerticalPadding; @override double get noteHorizontalPadding; + @override + @ColorConverter() + Color? get publicNoteBackgroundColor; + @override + @ColorConverter() + Color? get homeNoteBackgroundColor; + @override + @ColorConverter() + Color? get followersNoteBackgroundColor; + @override + @ColorConverter() + Color? get specifiedNoteBackgroundColor; @override // Emoji picker bool get emojiPickerUseDialog; @override diff --git a/lib/model/general_settings.g.dart b/lib/model/general_settings.g.dart index daa058a4..0c1e92d7 100644 --- a/lib/model/general_settings.g.dart +++ b/lib/model/general_settings.g.dart @@ -59,6 +59,16 @@ _$GeneralSettingsImpl _$$GeneralSettingsImplFromJson( noteHorizontalPadding: (json['noteHorizontalPadding'] as num?)?.toDouble() ?? defaultNoteHorizontalPadding, + publicNoteBackgroundColor: _$JsonConverterFromJson( + json['publicNoteBackgroundColor'], const ColorConverter().fromJson), + homeNoteBackgroundColor: _$JsonConverterFromJson( + json['homeNoteBackgroundColor'], const ColorConverter().fromJson), + followersNoteBackgroundColor: _$JsonConverterFromJson( + json['followersNoteBackgroundColor'], + const ColorConverter().fromJson), + specifiedNoteBackgroundColor: _$JsonConverterFromJson( + json['specifiedNoteBackgroundColor'], + const ColorConverter().fromJson), emojiPickerUseDialog: json['emojiPickerUseDialog'] as bool? ?? false, emojiPickerScale: (json['emojiPickerScale'] as num?)?.toDouble() ?? 1.0, emojiPickerAutofocus: json['emojiPickerAutofocus'] as bool? ?? true, @@ -148,6 +158,22 @@ Map _$$GeneralSettingsImplToJson( val['noteFooterScale'] = instance.noteFooterScale; val['noteVerticalPadding'] = instance.noteVerticalPadding; val['noteHorizontalPadding'] = instance.noteHorizontalPadding; + writeNotNull( + 'publicNoteBackgroundColor', + _$JsonConverterToJson( + instance.publicNoteBackgroundColor, const ColorConverter().toJson)); + writeNotNull( + 'homeNoteBackgroundColor', + _$JsonConverterToJson( + instance.homeNoteBackgroundColor, const ColorConverter().toJson)); + writeNotNull( + 'followersNoteBackgroundColor', + _$JsonConverterToJson(instance.followersNoteBackgroundColor, + const ColorConverter().toJson)); + writeNotNull( + 'specifiedNoteBackgroundColor', + _$JsonConverterToJson(instance.specifiedNoteBackgroundColor, + const ColorConverter().toJson)); val['emojiPickerUseDialog'] = instance.emojiPickerUseDialog; val['emojiPickerScale'] = instance.emojiPickerScale; val['emojiPickerAutofocus'] = instance.emojiPickerAutofocus; @@ -233,6 +259,12 @@ const _$EmojiStyleEnumMap = { EmojiStyle.twemoji: 'twemoji', }; +Value? _$JsonConverterFromJson( + Object? json, + Value? Function(Json json) fromJson, +) => + json == null ? null : fromJson(json as Json); + const _$NoteActionTypeEnumMap = { NoteActionType.none: 'none', NoteActionType.expand: 'expand', @@ -245,3 +277,9 @@ const _$ThemeModeEnumMap = { ThemeMode.light: 'light', ThemeMode.dark: 'dark', }; + +Json? _$JsonConverterToJson( + Value? value, + Json? Function(Value value) toJson, +) => + value == null ? null : toJson(value); diff --git a/lib/provider/general_settings_notifier_provider.dart b/lib/provider/general_settings_notifier_provider.dart index 90d14cf8..70af15c6 100644 --- a/lib/provider/general_settings_notifier_provider.dart +++ b/lib/provider/general_settings_notifier_provider.dart @@ -215,6 +215,39 @@ class GeneralSettingsNotifier extends _$GeneralSettingsNotifier { await _save(); } + Future setPublicNoteBackgroundColor( + Color? publicNoteBackgroundColor, + ) async { + state = + state.copyWith(publicNoteBackgroundColor: publicNoteBackgroundColor); + await _save(); + } + + Future setHomeNoteBackgroundColor( + Color? homeNoteBackgroundColor, + ) async { + state = state.copyWith(homeNoteBackgroundColor: homeNoteBackgroundColor); + await _save(); + } + + Future setFollowersNoteBackgroundColor( + Color? followersNoteBackgroundColor, + ) async { + state = state.copyWith( + followersNoteBackgroundColor: followersNoteBackgroundColor, + ); + await _save(); + } + + Future setSpecifiedNoteBackgroundColor( + Color? specifiedNoteBackgroundColor, + ) async { + state = state.copyWith( + specifiedNoteBackgroundColor: specifiedNoteBackgroundColor, + ); + await _save(); + } + Future setEmojiPickerUseDialog(bool emojiPickerUseDialog) async { state = state.copyWith(emojiPickerUseDialog: emojiPickerUseDialog); await _save(); diff --git a/lib/provider/general_settings_notifier_provider.g.dart b/lib/provider/general_settings_notifier_provider.g.dart index 2d5f50dc..37988f41 100644 --- a/lib/provider/general_settings_notifier_provider.g.dart +++ b/lib/provider/general_settings_notifier_provider.g.dart @@ -7,7 +7,7 @@ part of 'general_settings_notifier_provider.dart'; // ************************************************************************** String _$generalSettingsNotifierHash() => - r'e3447c2d1cba800500755ac9029c856ea7b1d8b3'; + r'24703a29c2be7d34ed75adc2d95525199b6737d2'; /// See also [GeneralSettingsNotifier]. @ProviderFor(GeneralSettingsNotifier) diff --git a/lib/view/page/settings/note_display_page.dart b/lib/view/page/settings/note_display_page.dart index ca7ae076..a9fd5b8b 100644 --- a/lib/view/page/settings/note_display_page.dart +++ b/lib/view/page/settings/note_display_page.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'package:flex_color_picker/flex_color_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -553,6 +554,141 @@ class NoteDisplayPage extends HookConsumerWidget { icon: const Icon(Icons.refresh), ), ), + Padding( + padding: const EdgeInsets.only(left: 16.0), + child: Text( + t.misskey.backgroundColor, + style: TextStyle( + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.8), + ), + ), + ), + ListTile( + title: Text(t.misskey.visibility_.public), + trailing: DecoratedBox( + decoration: BoxDecoration( + color: settings.publicNoteBackgroundColor, + border: Border.all( + color: Theme.of(context).colorScheme.outline, + ), + shape: BoxShape.circle, + ), + child: const SizedBox(width: 28.0, height: 28.0), + ), + onTap: () async { + final result = await showColorPickerDialog( + context, + settings.publicNoteBackgroundColor ?? + Colors.transparent, + pickersEnabled: { + ColorPickerType.primary: false, + ColorPickerType.accent: false, + ColorPickerType.wheel: true, + }, + enableOpacity: true, + ); + await ref + .read(generalSettingsNotifierProvider.notifier) + .setPublicNoteBackgroundColor( + result != Colors.transparent ? result : null, + ); + }, + ), + ListTile( + title: Text(t.misskey.visibility_.home), + trailing: DecoratedBox( + decoration: BoxDecoration( + color: settings.homeNoteBackgroundColor, + border: Border.all( + color: Theme.of(context).colorScheme.outline, + ), + shape: BoxShape.circle, + ), + child: const SizedBox(width: 28.0, height: 28.0), + ), + onTap: () async { + final result = await showColorPickerDialog( + context, + settings.homeNoteBackgroundColor ?? Colors.transparent, + pickersEnabled: { + ColorPickerType.primary: false, + ColorPickerType.accent: false, + ColorPickerType.wheel: true, + }, + enableOpacity: true, + ); + await ref + .read(generalSettingsNotifierProvider.notifier) + .setHomeNoteBackgroundColor( + result != Colors.transparent ? result : null, + ); + }, + ), + ListTile( + title: Text(t.misskey.visibility_.followers), + trailing: DecoratedBox( + decoration: BoxDecoration( + color: settings.followersNoteBackgroundColor, + border: Border.all( + color: Theme.of(context).colorScheme.outline, + ), + shape: BoxShape.circle, + ), + child: const SizedBox(width: 28.0, height: 28.0), + ), + onTap: () async { + final result = await showColorPickerDialog( + context, + settings.followersNoteBackgroundColor ?? + Colors.transparent, + pickersEnabled: { + ColorPickerType.primary: false, + ColorPickerType.accent: false, + ColorPickerType.wheel: true, + }, + enableOpacity: true, + ); + await ref + .read(generalSettingsNotifierProvider.notifier) + .setFollowersNoteBackgroundColor( + result != Colors.transparent ? result : null, + ); + }, + ), + ListTile( + title: Text(t.misskey.visibility_.specified), + trailing: DecoratedBox( + decoration: BoxDecoration( + color: settings.specifiedNoteBackgroundColor, + border: Border.all( + color: Theme.of(context).colorScheme.outline, + ), + shape: BoxShape.circle, + ), + child: const SizedBox(width: 28.0, height: 28.0), + ), + onTap: () async { + final result = await showColorPickerDialog( + context, + settings.specifiedNoteBackgroundColor ?? + Colors.transparent, + pickersEnabled: { + ColorPickerType.primary: false, + ColorPickerType.accent: false, + ColorPickerType.wheel: true, + }, + enableOpacity: true, + ); + await ref + .read(generalSettingsNotifierProvider.notifier) + .setSpecifiedNoteBackgroundColor( + result != Colors.transparent ? result : null, + ); + }, + ), ], ), _NoteDisplayArea.preview => SingleChildScrollView( diff --git a/lib/view/widget/note_widget.dart b/lib/view/widget/note_widget.dart index 08987fe7..553a9e5b 100644 --- a/lib/view/widget/note_widget.dart +++ b/lib/view/widget/note_widget.dart @@ -203,11 +203,24 @@ class NoteWidget extends HookConsumerWidget { isRenote && (isMyRenote || isMyNote || appearNote.myReaction != null), ); + final backgroundColor = ref.watch( + generalSettingsNotifierProvider.select( + (settings) => switch (note.visibility) { + NoteVisibility.public => settings.publicNoteBackgroundColor, + NoteVisibility.home => settings.homeNoteBackgroundColor, + NoteVisibility.followers => settings.followersNoteBackgroundColor, + NoteVisibility.specified => settings.specifiedNoteBackgroundColor, + null => null, + }, + ), + ); final colors = ref.watch(misskeyColorsProvider(Theme.of(context).brightness)); final style = DefaultTextStyle.of(context).style; - return ClipRect( + return Material( + color: backgroundColor, + clipBehavior: Clip.hardEdge, child: InkWell( onTap: getNoteAction( ref,