Skip to content

Commit

Permalink
Use latest colour theme behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
banool committed Oct 28, 2024
1 parent ce60a7e commit 74ab992
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 58 deletions.
3 changes: 1 addition & 2 deletions lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'word_page.dart';

const String APP_NAME = "Auslan Dictionary";

// const Color MAIN_COLOR = Colors.blue;
// const Color APP_BAR_DISABLED_COLOR = Color.fromARGB(94, 0, 0, 0);
const MaterialColor MAIN_COLOR = Colors.blue;

const String IOS_APP_ID = "1531368368";
const String ANDROID_APP_ID = "com.banool.auslan_dictionary";
Expand Down
28 changes: 13 additions & 15 deletions lib/flashcards_landing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,20 @@ class MyFlashcardsLandingPageController
await showDialog(
context: context,
builder: (ctx) {
return MultiSelectDialog(
listType: MultiSelectListType.CHIP,
title:
Text(DictLibLocalizations.of(context)!.flashcardsRegions),
items: regionsWithoutEverywhere
.map((e) => MultiSelectItem(e.index, e.pretty))
.toList(),
initialValue: additionalRegionsValues,
onConfirm: (values) {
setState(() {
sharedPreferences.setStringList(KEY_FLASHCARD_REGIONS,
values.map((e) => e.toString()).toList());
updateRevisionSettings();
return buildMultiSelectDialog(
context: context,
title: DictLibLocalizations.of(context)!.flashcardsRegions,
items: regionsWithoutEverywhere
.map((e) => MultiSelectItem(e.index, e.pretty))
.toList(),
initialValue: additionalRegionsValues,
onConfirm: (values) {
setState(() {
sharedPreferences.setStringList(KEY_FLASHCARD_REGIONS,
values.map((e) => e.toString()).toList());
updateRevisionSettings();
});
});
},
);
},
);
},
Expand Down
5 changes: 2 additions & 3 deletions lib/flashcards_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class FlashcardsPageState extends State<FlashcardsPage> {

Widget buildFlashcardWidget(DRCard card, SubEntry subEntry, String word,
bool wordToSign, bool revealed) {
ColorScheme currentTheme = Theme.of(context).colorScheme;
ColorScheme colorScheme = Theme.of(context).colorScheme;
var shouldUseHorizontalDisplay = getShouldUseHorizontalLayout(context);

// See here for an explanation of why I pass in a key here:
Expand Down Expand Up @@ -300,11 +300,10 @@ class FlashcardsPageState extends State<FlashcardsPage> {
if (states.contains(WidgetState.disabled)) {
return Colors.grey;
} else {
return currentTheme.primary;
return colorScheme.primaryContainer;
}
},
),
foregroundColor: WidgetStateProperty.all<Color>(Colors.white),
),
onPressed: () async {
await Navigator.push(
Expand Down
45 changes: 19 additions & 26 deletions lib/root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,12 @@ class _RootAppState extends State<RootApp> {
debugShowCheckedModeBanner: false,
themeMode: themeMode,
theme: ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue,
// Use ColorScheme to define primary and secondary colors
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
).copyWith(
secondary: Colors.blue,
colorScheme: ColorScheme.fromSeed(
seedColor: MAIN_COLOR,
brightness: Brightness.light,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.blue,
backgroundColor: MAIN_COLOR,
foregroundColor: Colors.white,
elevation: 0,
),
Expand All @@ -168,7 +164,7 @@ class _RootAppState extends State<RootApp> {
),
typography: Typography.material2021(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue, brightness: Brightness.light)),
seedColor: MAIN_COLOR, brightness: Brightness.light)),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
foregroundColor: WidgetStatePropertyAll(Colors.black),
Expand All @@ -180,17 +176,17 @@ class _RootAppState extends State<RootApp> {
(Set<WidgetState> states) =>
states.contains(WidgetState.disabled)
? Colors.black38
: Colors.white,
: Colors.black,
),
),
),
// Update InputDecoration theme for search field underline and placeholder
inputDecorationTheme: const InputDecorationTheme(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderSide: BorderSide(color: MAIN_COLOR),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderSide: BorderSide(color: MAIN_COLOR),
),
hintStyle: TextStyle(color: Colors.black54),
),
Expand All @@ -207,13 +203,14 @@ class _RootAppState extends State<RootApp> {
),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: Colors.blue,
backgroundColor: MAIN_COLOR,
contentTextStyle: TextStyle(color: Colors.white),
),
// Update BottomNavigationBar theme
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
selectedItemColor: Colors.blue,
selectedItemColor: MAIN_COLOR,
unselectedItemColor: Colors.grey,
backgroundColor: Colors.white,
),
visualDensity: VisualDensity.adaptivePlatformDensity,
pageTransitionsTheme: const PageTransitionsTheme(builders: {
Expand All @@ -222,14 +219,9 @@ class _RootAppState extends State<RootApp> {
}),
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
// Use ColorScheme to define primary and secondary colors
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.blue,
colorScheme: ColorScheme.fromSeed(
seedColor: MAIN_COLOR,
brightness: Brightness.dark,
).copyWith(
secondary: Colors.blue,
),
appBarTheme: const AppBarTheme(
backgroundColor: Color(0xFF1F1F1F),
Expand All @@ -246,7 +238,7 @@ class _RootAppState extends State<RootApp> {
),
typography: Typography.material2021(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue, brightness: Brightness.dark)),
seedColor: MAIN_COLOR, brightness: Brightness.dark)),
// Update TextButton theme
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
Expand All @@ -266,10 +258,10 @@ class _RootAppState extends State<RootApp> {
// Update InputDecoration theme for search field underline and placeholder
inputDecorationTheme: const InputDecorationTheme(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderSide: BorderSide(color: MAIN_COLOR),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderSide: BorderSide(color: MAIN_COLOR),
),
hintStyle: TextStyle(color: Colors.white60),
),
Expand All @@ -286,13 +278,14 @@ class _RootAppState extends State<RootApp> {
),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: Colors.blue,
backgroundColor: MAIN_COLOR,
contentTextStyle: TextStyle(color: Colors.black),
),
// Update BottomNavigationBar theme
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
selectedItemColor: Colors.blue,
selectedItemColor: MAIN_COLOR,
unselectedItemColor: Colors.grey,
backgroundColor: Color(0xFF121212),
),
visualDensity: VisualDensity.adaptivePlatformDensity,
pageTransitionsTheme: const PageTransitionsTheme(builders: {
Expand Down
23 changes: 20 additions & 3 deletions lib/word_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ class _EntryPageState extends State<EntryPage> {

Widget? getRelatedEntriesWidget(BuildContext context, MySubEntry subEntry,
bool shouldUseHorizontalDisplay) {
return getInnerRelatedEntriesWidget(
context: context,
subEntry: subEntry,
shouldUseHorizontalDisplay: shouldUseHorizontalDisplay,
getRelatedEntry: (keyword) =>
keyedByEnglishEntriesGlobal.containsKey(keyword)
? keyedByEnglishEntriesGlobal[keyword]
: null,
navigateToEntryPage: (context, entry, showFavouritesButton) =>
navigateToEntryPage(context, entry, showFavouritesButton));

ColorScheme colorScheme = Theme.of(context).colorScheme;

int numKeywords = subEntry.keywords.length;
if (numKeywords == 0) {
return null;
Expand All @@ -199,14 +212,18 @@ Widget? getRelatedEntriesWidget(BuildContext context, MySubEntry subEntry,
}
textSpans.add(TextSpan(
text: "$keyword$suffix",
style: TextStyle(),
style: TextStyle(
color: colorScheme.onSurface,
),
recognizer: TapGestureRecognizer()..onTap = navFunction,
));
idx += 1;
}

var initial = const TextSpan(
text: "Related words: ", style: TextStyle(fontWeight: FontWeight.bold));
var initial = TextSpan(
text: "Related words: ",
style:
TextStyle(color: colorScheme.onSurface, fontWeight: FontWeight.bold));
textSpans = [initial] + textSpans;
var richText = RichText(
text: TextSpan(children: textSpans),
Expand Down
15 changes: 8 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ packages:
description:
path: "."
ref: main
resolved-ref: "5ce15cd83af0a403f327898239dea97aa5ebe65d"
resolved-ref: d8a3f16cd7ee913642e43fb683f47d1031458f3b
url: "https://github.com/banool/dictionarylib.git"
source: git
version: "0.2.6"
version: "0.2.8"
dolphinsr_dart:
dependency: "direct main"
description:
Expand Down Expand Up @@ -533,12 +533,13 @@ packages:
source: hosted
version: "1.15.0"
multi_select_flutter:
dependency: "direct main"
dependency: transitive
description:
name: multi_select_flutter
sha256: "503857b415d390d29159df8a9d92d83c6aac17aaf1c307fb7bcfc77d097d20ed"
url: "https://pub.dev"
source: hosted
path: "."
ref: master
resolved-ref: "6581736ca3db116b90a7750c51c2c01187179cdb"
url: "https://github.com/erickgon92/multi_select_flutter"
source: git
version: "4.1.3"
octo_image:
dependency: transitive
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Free video dictionary of Auslan signs

publish_to: 'none'

version: 1.17.3+787
version: 1.17.5+789

environment:
sdk: '>=2.18.0 <3.0.0'
Expand Down Expand Up @@ -32,7 +32,6 @@ dependencies:
http:
launch_review:
mailto:
multi_select_flutter:
package_info_plus:
path_provider:
shared_preferences:
Expand Down

0 comments on commit 74ab992

Please sign in to comment.