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;
Color get listPlaceholderBackgroundColor =>
colorScheme.secondaryContainer.withOpacity(.6);
colorScheme.primaryContainer.withOpacity(.6);
Color get listPlaceholderForegroundColor =>
colorScheme.onSecondaryContainer.withOpacity(.7);
colorScheme.onPrimaryContainer.withOpacity(.7);
Color get homeNavigationBarBackgroundColor =>
elevate(colorScheme.surface, 2).withOpacity(.55);
@ -148,8 +148,8 @@ ColorScheme _getColorScheme(
}
return SeedColorScheme.fromSeeds(
brightness: brightness,
primaryKey: seedColor,
tones: FlexTones.oneHue(brightness),
primaryKey: seedColor,
);
}
@ -188,7 +188,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
return colorScheme.onSurface;
} else {
if (states.contains(MaterialState.selected)) {
return colorScheme.primary;
return colorScheme.secondary;
} else {
return Colors.transparent;
}
@ -210,7 +210,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
} else {
if (states.contains(MaterialState.selected)) {
// return colorScheme.primary;
return colorScheme.primaryContainer;
return colorScheme.secondary;
} else {
return colorScheme.surfaceVariant;
}
@ -227,7 +227,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
} else {
if (states.contains(MaterialState.selected)) {
// return colorScheme.onPrimary;
return colorScheme.primary;
return colorScheme.onSecondary;
} else {
return colorScheme.outline;
}
@ -242,6 +242,46 @@ ThemeData _applyColorScheme(ColorScheme colorScheme) {
actionTextColor: colorScheme.inversePrimary,
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: [
M3(
checkbox: M3Checkbox(

View file

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

View file

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

View file

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

View file

@ -25,7 +25,7 @@ class Selectable extends StatelessWidget {
Positioned.fill(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: borderRadius,
),
),
@ -41,10 +41,10 @@ class Selectable extends StatelessWidget {
isSelected ? childBorderRadius : BorderRadius.zero,
side: BorderSide(
color: isSelected
? Theme.of(context).colorScheme.primaryContainer
? Theme.of(context).colorScheme.secondaryContainer
: Theme.of(context)
.colorScheme
.primaryContainer
.secondaryContainer
.withOpacity(0),
width: isSelected ? 4 : 0,
),
@ -65,12 +65,12 @@ class Selectable extends StatelessWidget {
Icon(
Icons.circle,
size: iconSize - 2,
color: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.secondary,
),
Icon(
Icons.check_circle_outlined,
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,
visualDensity: VisualDensity.compact,
selected: true,
selectedColor: Theme.of(context)
.elevate(Theme.of(context).colorScheme.surface, 5),
label: Text(_tags[index]),
onSelected: (_) {},
),

View file

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

View file

@ -51,7 +51,7 @@ dependencies:
draggable_scrollbar:
git:
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
equatable: ^2.0.5
event_bus: ^2.0.0

View file

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