Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of system color scheme on Android #298

Merged
merged 2 commits into from
Jul 1, 2024
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
2 changes: 1 addition & 1 deletion commet/lib/ui/atoms/emoji_reaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EmojiReaction extends StatelessWidget {

@override
Widget build(BuildContext context) {
var bgColor = material.Theme.of(context).colorScheme.primary;
var bgColor = material.Theme.of(context).colorScheme.tertiary;

if (!highlighted) {
bgColor = material.Theme.of(context).colorScheme.surfaceContainerLow;
Expand Down
2 changes: 1 addition & 1 deletion commet/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ packages:
description:
path: "packages/dynamic_color"
ref: HEAD
resolved-ref: c23b9658c1ada18021bb1356b921f574217d0668
resolved-ref: f8a2817197fb68bac47bd1067152c46a4ab56cab
url: "https://github.com/Airyzz/material-flutter-packages.git"
source: git
version: "1.7.0"
Expand Down
8 changes: 4 additions & 4 deletions tiamat/lib/atoms/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class Button extends StatelessWidget {
switch (type) {
case ButtonType.primary:
style = Theme.of(context).elevatedButtonTheme.style!.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onPrimaryContainer),
backgroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.primaryContainer));
foregroundColor:
WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary),
backgroundColor:
WidgetStatePropertyAll(Theme.of(context).colorScheme.primary));
break;
case ButtonType.secondary:
style = Theme.of(context).elevatedButtonTheme.style!.copyWith(
Expand Down
4 changes: 2 additions & 2 deletions tiamat/lib/atoms/circle_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CircleButton extends StatelessWidget {
clipBehavior: Clip.antiAlias,
child: ClipOval(
child: Material(
color: Theme.of(context).colorScheme.tertiaryContainer,
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(radius),
child: InkWell(
splashColor: Theme.of(context).highlightColor, // Splash color
Expand All @@ -40,7 +40,7 @@ class CircleButton extends StatelessWidget {
? Align(
alignment: Alignment.center,
child: Icon(
color: Theme.of(context).colorScheme.tertiary,
color: Theme.of(context).colorScheme.secondary,
icon,
size: radius,
))
Expand Down
78 changes: 20 additions & 58 deletions tiamat/lib/config/style/theme_amoled.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:tiamat/config/style/theme_base.dart';
import 'package:tiamat/config/style/theme_common.dart';
import 'package:tiamat/config/style/theme_extensions.dart';
import 'dart:io' show Platform;
Expand All @@ -21,62 +22,23 @@ class ThemeAmoledColors {
}

class ThemeAmoled {
static ThemeData get theme => ThemeData(
brightness: Brightness.dark,
fontFamily: "RobotoCustom",
fontFamilyFallback: ThemeCommon.fontFamilyFallback(),
useMaterial3: true,
extensions: const [
ThemeSettings(caulkBorders: true, caulkStrokeThickness: 1)
],
colorScheme: const ColorScheme(
primary: Colors.white,
secondary: ThemeAmoledColors.secondary,
secondaryContainer: Color.fromARGB(255, 40, 40, 40),
surface: ThemeAmoledColors.surface,
error: Color.fromARGB(255, 255, 124, 124),
onPrimary: Colors.white,
onSecondary: ThemeAmoledColors.onSurface,
onSurface: Colors.white,
onError: Colors.white,
tertiaryContainer: Colors.black,
brightness: Brightness.dark,
outline: ThemeAmoledColors.surfaceHigh1),
listTileTheme: const ListTileThemeData(
tileColor: ThemeAmoledColors.surface,
),
canvasColor: ThemeAmoledColors.surface,
iconTheme: const IconThemeData(color: ThemeAmoledColors.secondary),
shadowColor: Colors.black.withAlpha(100),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor:
WidgetStatePropertyAll(ThemeAmoledColors.primary),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
))),
dividerTheme:
const DividerThemeData(color: ThemeAmoledColors.surfaceHigh1),
sliderTheme: SliderThemeData(
inactiveTrackColor: ThemeAmoledColors.primary.withAlpha(100),
),
dialogTheme: const DialogTheme(
backgroundColor: ThemeAmoledColors.surface,
shadowColor: Colors.black),
dialogBackgroundColor: ThemeAmoledColors.highlightColor,
switchTheme: const SwitchThemeData(
thumbColor: WidgetStatePropertyAll(ThemeAmoledColors.secondary)),
dividerColor: ThemeAmoledColors.outlineColor,
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
overlayColor: const WidgetStatePropertyAll<Color>(Colors.white10),
foregroundColor: WidgetStatePropertyAll<Color>(Colors.grey.shade300),
shape: WidgetStatePropertyAll<OutlinedBorder>(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
textStyle: const WidgetStatePropertyAll<TextStyle>(
TextStyle(
color: Colors.white,
),
),
)));
static ThemeData get theme => ThemeBase.theme(const ColorScheme(
primary: Colors.white,
secondary: ThemeAmoledColors.secondary,
secondaryContainer: Color.fromARGB(255, 40, 40, 40),
surface: ThemeAmoledColors.surface,
error: Color.fromARGB(255, 255, 124, 124),
onPrimary: Colors.white,
onSecondary: ThemeAmoledColors.onSurface,
onSurface: Colors.white,
onError: Colors.white,
tertiaryContainer: Colors.black,
brightness: Brightness.dark,
outline: ThemeAmoledColors.surfaceHigh1))
.copyWith(extensions: [
const ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 120, 120, 255)),
const ThemeSettings(caulkBorders: true, caulkStrokeThickness: 1)
]);
}
50 changes: 50 additions & 0 deletions tiamat/lib/config/style/theme_base.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:tiamat/config/style/theme_common.dart';
import 'package:tiamat/config/style/theme_extensions.dart';

class ThemeBase {
static ThemeData theme(ColorScheme scheme) => ThemeData(
brightness: scheme.brightness,
fontFamily: "RobotoCustom",
fontFamilyFallback: ThemeCommon.fontFamilyFallback(),
useMaterial3: true,
extensions: const [
ThemeSettings(caulkBorders: true, caulkBorderRadius: 1),
ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 120, 120, 255))
],
colorScheme: scheme,
listTileTheme: ListTileThemeData(
tileColor: scheme.surface,
),
canvasColor: scheme.surface,
iconTheme: IconThemeData(color: scheme.secondary),
shadowColor: Colors.black.withAlpha(100),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
))),
dividerTheme: DividerThemeData(color: scheme.surfaceContainerHigh),
sliderTheme: SliderThemeData(
inactiveTrackColor: scheme.primary.withAlpha(100),
),
dialogTheme: DialogTheme(
backgroundColor: scheme.surface, shadowColor: Colors.black),
switchTheme:
SwitchThemeData(thumbColor: WidgetStatePropertyAll(scheme.secondary)),
dividerColor: scheme.outline,
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
overlayColor: const WidgetStatePropertyAll<Color>(Colors.white10),
foregroundColor: WidgetStatePropertyAll<Color>(Colors.grey.shade300),
shape: WidgetStatePropertyAll<OutlinedBorder>(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
textStyle: const WidgetStatePropertyAll<TextStyle>(
TextStyle(
color: Colors.white,
),
),
)));
}
93 changes: 30 additions & 63 deletions tiamat/lib/config/style/theme_dark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:tiamat/config/style/theme_base.dart';
import 'package:tiamat/config/style/theme_common.dart';
import 'package:tiamat/config/style/theme_extensions.dart';
import 'dart:io' show Platform;
Expand All @@ -21,67 +22,33 @@ class ThemeDarkColors {
}

class ThemeDark {
static ThemeData get theme => ThemeData(
brightness: Brightness.dark,
fontFamily: "RobotoCustom",
fontFamilyFallback: ThemeCommon.fontFamilyFallback(),
useMaterial3: true,
extensions: const [
ThemeSettings(caulkBorders: true, caulkBorderRadius: 1),
ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 120, 120, 255))
],
colorScheme: ColorScheme.fromSeed(
seedColor: const Color.fromARGB(255, 106, 141, 255),
secondary: ThemeDarkColors.secondary,
surface: ThemeDarkColors.surface,
surfaceContainer: ThemeDarkColors.surfaceContainer,
surfaceContainerLow: ThemeDarkColors.surfaceContainerLow,
surfaceContainerLowest: ThemeDarkColors.surfaceContainerLowest,
surfaceContainerHigh: ThemeDarkColors.surfaceContainerHigh,
surfaceContainerHighest: ThemeDarkColors.surfaceContainerHigh,
primaryContainer: ThemeDarkColors.primary,
onPrimaryContainer: Colors.white,
onPrimary: Colors.white,
onSecondary: ThemeDarkColors.onSurface,
onSurface: Colors.white,
brightness: Brightness.dark,
tertiaryContainer: ThemeDarkColors.surface,
onTertiaryContainer: Colors.white,
tertiary: Colors.white,
outline: ThemeDarkColors.surfaceContainerHigh),
listTileTheme: const ListTileThemeData(
tileColor: ThemeDarkColors.surface,
),
canvasColor: ThemeDarkColors.surface,
iconTheme: const IconThemeData(color: ThemeDarkColors.secondary),
shadowColor: Colors.black.withAlpha(100),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
))),
dividerTheme:
const DividerThemeData(color: ThemeDarkColors.surfaceContainerHigh),
sliderTheme: SliderThemeData(
inactiveTrackColor: ThemeDarkColors.primary.withAlpha(100),
),
dialogTheme: const DialogTheme(
backgroundColor: ThemeDarkColors.surface, shadowColor: Colors.black),
switchTheme: const SwitchThemeData(
thumbColor: WidgetStatePropertyAll(ThemeDarkColors.secondary)),
dividerColor: ThemeDarkColors.outlineColor,
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
overlayColor: const WidgetStatePropertyAll<Color>(Colors.white10),
foregroundColor: WidgetStatePropertyAll<Color>(Colors.grey.shade300),
shape: WidgetStatePropertyAll<OutlinedBorder>(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
textStyle: const WidgetStatePropertyAll<TextStyle>(
TextStyle(
color: Colors.white,
),
),
)));
static ThemeData get theme {
var scheme = ColorScheme.fromSeed(
seedColor: const Color.fromARGB(255, 106, 141, 255),
secondary: ThemeDarkColors.secondary,
surface: ThemeDarkColors.surface,
surfaceContainer: ThemeDarkColors.surfaceContainer,
surfaceContainerLow: ThemeDarkColors.surfaceContainerLow,
surfaceContainerLowest: ThemeDarkColors.surfaceContainerLowest,
surfaceContainerHigh: ThemeDarkColors.surfaceContainerHigh,
surfaceContainerHighest: ThemeDarkColors.surfaceContainerHigh,
primaryContainer: ThemeDarkColors.primary,
onPrimaryContainer: Colors.white,
onPrimary: Colors.white,
onSecondary: ThemeDarkColors.onSurface,
onSurface: Colors.white,
brightness: Brightness.dark,
tertiaryContainer: ThemeDarkColors.surface,
onTertiaryContainer: Colors.white,
tertiary: Colors.white,
outline: ThemeDarkColors.surfaceContainerHigh);

return ThemeBase.theme(scheme).copyWith(extensions: [
const ThemeSettings(caulkBorders: true, caulkBorderRadius: 1),
FoundationSettings(color: scheme.surfaceDim),
const ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 120, 120, 255))
]);
}
}
65 changes: 18 additions & 47 deletions tiamat/lib/config/style/theme_light.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:tiamat/config/style/theme_base.dart';
import 'package:tiamat/config/style/theme_common.dart';
import 'package:tiamat/config/style/theme_extensions.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -25,51 +26,21 @@ class ThemeLightColors {
}

class ThemeLight {
static ThemeData get theme => ThemeData(
brightness: Brightness.light,
useMaterial3: true,
fontFamily: "RobotoCustom",
extensions: const [
ThemeSettings(),
ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 80, 80, 255))
],
fontFamilyFallback: ThemeCommon.fontFamilyFallback(),
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.white,
brightness: Brightness.light,
primaryContainer: ThemeLightColors.primary,
onPrimaryContainer: Colors.white,
outline: Colors.white,
primary: ThemeLightColors.primary),
shadowColor: Colors.black.withAlpha(100),
sliderTheme: SliderThemeData(
inactiveTrackColor: ThemeLightColors.primary.withAlpha(100)),
listTileTheme: const ListTileThemeData(
tileColor: ThemeLightColors.surface,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
))),
iconTheme: const IconThemeData(color: ThemeLightColors.secondary),
dividerColor: ThemeLightColors.outlineColor,
dialogBackgroundColor: ThemeLightColors.surface,
dividerTheme:
const DividerThemeData(color: ThemeLightColors.outlineColor),
dialogTheme: const DialogTheme(
backgroundColor: ThemeLightColors.surface, shadowColor: Colors.black),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
overlayColor: const WidgetStatePropertyAll<Color>(Colors.black12),
foregroundColor:
const WidgetStatePropertyAll<Color>(ThemeLightColors.secondary),
shape: WidgetStatePropertyAll<OutlinedBorder>(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
textStyle: const WidgetStatePropertyAll<TextStyle>(
TextStyle(color: Colors.white),
),
)));
static ThemeData get theme {
var scheme = ColorScheme.fromSeed(
seedColor: Colors.white,
brightness: Brightness.light,
primaryContainer: ThemeLightColors.primary,
onPrimaryContainer: Colors.white,
outline: Colors.white,
primary: ThemeLightColors.primary);

return ThemeBase.theme(scheme).copyWith(extensions: [
const ThemeSettings(),
FoundationSettings(color: scheme.surfaceDim),
const ExtraColors(
codeHighlight: Color(0xffc678dd),
linkColor: Color.fromARGB(255, 80, 80, 255))
]);
}
}
Loading
Loading