Ready theme to support secondary color

This commit is contained in:
Ming Ming 2024-05-17 00:37:33 +08:00
parent 6311f8a4de
commit 64e13bdee5
9 changed files with 64 additions and 23 deletions

View file

@ -13,10 +13,10 @@ extension ThemeExtension on ThemeData {
double get widthLimitedContentMaxWidth => 550.0; double get widthLimitedContentMaxWidth => 550.0;
Color get listPlaceholderBackgroundColor => Color get listPlaceholderBackgroundColor =>
colorScheme.secondaryContainer.withOpacity(.6); colorScheme.primaryContainer.withOpacity(.6);
Color get listPlaceholderForegroundColor => Color get listPlaceholderForegroundColor =>
colorScheme.onSecondaryContainer.withOpacity(.7); colorScheme.onPrimaryContainer.withOpacity(.7);
Color get homeNavigationBarBackgroundColor => Color get homeNavigationBarBackgroundColor =>
elevate(colorScheme.surface, 2).withOpacity(.55); elevate(colorScheme.surface, 2).withOpacity(.55);
@ -148,8 +148,8 @@ ColorScheme _getColorScheme(
} }
return SeedColorScheme.fromSeeds( return SeedColorScheme.fromSeeds(
brightness: brightness, brightness: brightness,
primaryKey: seedColor,
tones: FlexTones.oneHue(brightness), tones: FlexTones.oneHue(brightness),
primaryKey: seedColor,
); );
} }
@ -188,7 +188,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
return colorScheme.onSurface; return colorScheme.onSurface;
} else { } else {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return colorScheme.primary; return colorScheme.secondary;
} else { } else {
return Colors.transparent; return Colors.transparent;
} }
@ -210,7 +210,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
} else { } else {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
// return colorScheme.primary; // return colorScheme.primary;
return colorScheme.primaryContainer; return colorScheme.secondary;
} else { } else {
return colorScheme.surfaceVariant; return colorScheme.surfaceVariant;
} }
@ -227,7 +227,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
} else { } else {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
// return colorScheme.onPrimary; // return colorScheme.onPrimary;
return colorScheme.primary; return colorScheme.onSecondary;
} else { } else {
return colorScheme.outline; return colorScheme.outline;
} }
@ -242,6 +242,46 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
actionTextColor: colorScheme.inversePrimary, actionTextColor: colorScheme.inversePrimary,
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
), ),
sliderTheme: SliderThemeData(
activeTrackColor: colorScheme.secondary,
inactiveTrackColor: colorScheme.secondaryContainer,
thumbColor: colorScheme.secondary,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(colorScheme.secondaryContainer),
foregroundColor: MaterialStateProperty.all(colorScheme.secondary),
overlayColor:
MaterialStateProperty.all(colorScheme.secondary.withOpacity(.1)),
),
),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(colorScheme.secondary),
overlayColor:
MaterialStateProperty.all(colorScheme.secondary.withOpacity(.1)),
),
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: colorScheme.secondary,
selectionHandleColor: colorScheme.secondary,
selectionColor: colorScheme.secondary.withOpacity(.4),
),
inputDecorationTheme: InputDecorationTheme(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: colorScheme.secondary, width: 2),
),
),
chipTheme: ChipThemeData(
selectedColor: Color.lerp(
colorScheme.secondaryContainer, colorScheme.surfaceTint, .14),
iconTheme: IconThemeData(
color: colorScheme.secondary,
),
),
progressIndicatorTheme:
ProgressIndicatorThemeData(color: colorScheme.secondary),
extensions: [ extensions: [
M3( M3(
checkbox: M3Checkbox( checkbox: M3Checkbox(

View file

@ -303,7 +303,7 @@ class _ScrollLabel extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: DefaultTextStyle( child: DefaultTextStyle(
style: Theme.of(context).textTheme.titleMedium!.copyWith( style: Theme.of(context).textTheme.titleMedium!.copyWith(
color: Theme.of(context).colorScheme.onInverseSurface), color: Theme.of(context).colorScheme.onSecondaryContainer),
child: Text(text), child: Text(text),
), ),
); );

View file

@ -322,8 +322,10 @@ class _BodyState extends State<_Body> {
AppDimension.of(context).homeBottomAppBarHeight, AppDimension.of(context).homeBottomAppBarHeight,
labelTextBuilder: (_) => const _ScrollLabel(), labelTextBuilder: (_) => const _ScrollLabel(),
labelPadding: const EdgeInsets.symmetric(horizontal: 40), labelPadding: const EdgeInsets.symmetric(horizontal: 40),
backgroundColor: Theme.of(context).elevate( backgroundColor:
Theme.of(context).colorScheme.inverseSurface, 3), Theme.of(context).colorScheme.secondaryContainer,
foregroundColor:
Theme.of(context).colorScheme.onSecondaryContainer,
heightScrollThumb: 60, heightScrollThumb: 60,
onScrollBegin: () { onScrollBegin: () {
_bloc.add(const _StartScrolling()); _bloc.add(const _StartScrolling());
@ -335,6 +337,9 @@ class _BodyState extends State<_Body> {
behavior: ScrollConfiguration.of(context) behavior: ScrollConfiguration.of(context)
.copyWith(scrollbars: false), .copyWith(scrollbars: false),
child: RefreshIndicator( child: RefreshIndicator(
color: Theme.of(context).colorScheme.secondary,
backgroundColor:
Theme.of(context).colorScheme.secondaryContainer,
onRefresh: () async { onRefresh: () async {
_bloc.add(const _RequestRefresh()); _bloc.add(const _RequestRefresh());
var hasNotNull = false; var hasNotNull = false;

View file

@ -653,8 +653,6 @@ class _FilterBubbleList extends StatelessWidget {
showCheckmark: false, showCheckmark: false,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
selected: true, selected: true,
selectedColor:
Theme.of(context).elevate(Theme.of(context).colorScheme.surface, 5),
label: Text(label), label: Text(label),
onSelected: (_) {}, onSelected: (_) {},
), ),

View file

@ -25,7 +25,7 @@ class Selectable extends StatelessWidget {
Positioned.fill( Positioned.fill(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer, color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: borderRadius, borderRadius: borderRadius,
), ),
), ),
@ -41,10 +41,10 @@ class Selectable extends StatelessWidget {
isSelected ? childBorderRadius : BorderRadius.zero, isSelected ? childBorderRadius : BorderRadius.zero,
side: BorderSide( side: BorderSide(
color: isSelected color: isSelected
? Theme.of(context).colorScheme.primaryContainer ? Theme.of(context).colorScheme.secondaryContainer
: Theme.of(context) : Theme.of(context)
.colorScheme .colorScheme
.primaryContainer .secondaryContainer
.withOpacity(0), .withOpacity(0),
width: isSelected ? 4 : 0, width: isSelected ? 4 : 0,
), ),
@ -65,12 +65,12 @@ class Selectable extends StatelessWidget {
Icon( Icon(
Icons.circle, Icons.circle,
size: iconSize - 2, size: iconSize - 2,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.secondary,
), ),
Icon( Icon(
Icons.check_circle_outlined, Icons.check_circle_outlined,
size: iconSize, size: iconSize,
color: Theme.of(context).colorScheme.primaryContainer, color: Theme.of(context).colorScheme.secondaryContainer,
), ),
], ],
), ),

View file

@ -256,8 +256,6 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
showCheckmark: false, showCheckmark: false,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
selected: true, selected: true,
selectedColor: Theme.of(context)
.elevate(Theme.of(context).colorScheme.surface, 5),
label: Text(_tags[index]), label: Text(_tags[index]),
onSelected: (_) {}, onSelected: (_) {},
), ),

View file

@ -376,8 +376,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "v0.1.0-nc-photos-7" ref: "v0.1.0-nc-photos-8"
resolved-ref: c2e009d371950322f67ff7ce18a67881000629ce resolved-ref: "4fa2ca0f8bbab5c4300b242c63865e0530a173c8"
url: "https://gitlab.com/nc-photos/flutter-draggable-scrollbar" url: "https://gitlab.com/nc-photos/flutter-draggable-scrollbar"
source: git source: git
version: "0.1.0+7" version: "0.1.0+7"

View file

@ -51,7 +51,7 @@ dependencies:
draggable_scrollbar: draggable_scrollbar:
git: git:
url: https://gitlab.com/nc-photos/flutter-draggable-scrollbar url: https://gitlab.com/nc-photos/flutter-draggable-scrollbar
ref: v0.1.0-nc-photos-7 ref: v0.1.0-nc-photos-8
dynamic_color: ^1.6.6 dynamic_color: ^1.6.6
equatable: ^2.0.5 equatable: ^2.0.5
event_bus: ^2.0.0 event_bus: ^2.0.0

View file

@ -66,13 +66,13 @@ class FancyOptionPickerItemView extends StatelessWidget {
return ListTile( return ListTile(
leading: Icon( leading: Icon(
isSelected ? Icons.check : null, isSelected ? Icons.check : null,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.secondary,
), ),
title: Text( title: Text(
label, label,
style: isSelected style: isSelected
? TextStyle( ? TextStyle(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.secondary,
) )
: null, : null,
), ),