added feature to use google fonts & some fix
This commit is contained in:
parent
48c6c83355
commit
45fbd42c19
12 changed files with 680 additions and 286 deletions
|
|
@ -5,10 +5,10 @@ import 'package:flex_color_scheme/flex_color_scheme.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/modules/more/settings/appearance/providers/app_font_family.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:mangayomi/providers/storage_provider.dart';
|
||||
import 'package:mangayomi/router/router.dart';
|
||||
|
|
@ -93,6 +93,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
// Define light and dark theme data.
|
||||
final isDarkTheme = ref.watch(themeModeStateProvider);
|
||||
final blendLevel = ref.watch(blendLevelStateProvider);
|
||||
final appFontFamily = ref.watch(appFontFamilyProvider);
|
||||
final pureBlackDarkMode = ref.watch(pureBlackDarkModeStateProvider);
|
||||
final locale = ref.watch(l10nLocaleStateProvider);
|
||||
ThemeData themeLight = FlexThemeData.light(
|
||||
|
|
@ -111,7 +112,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
useMaterial3ErrorColors: true,
|
||||
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
||||
useMaterial3: true,
|
||||
fontFamily: GoogleFonts.aBeeZee().fontFamily,
|
||||
fontFamily: appFontFamily,
|
||||
);
|
||||
ThemeData themeDark = FlexThemeData.dark(
|
||||
colors: ref.watch(flexSchemeColorStateProvider),
|
||||
|
|
@ -130,7 +131,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
useMaterial3ErrorColors: true,
|
||||
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
||||
useMaterial3: true,
|
||||
fontFamily: GoogleFonts.aBeeZee().fontFamily,
|
||||
fontFamily: appFontFamily,
|
||||
);
|
||||
final router = ref.watch(routerProvider);
|
||||
// Return the main MaterialApp with router, themes, and localization settings.
|
||||
|
|
|
|||
|
|
@ -177,6 +177,8 @@ class Settings {
|
|||
@enumerated
|
||||
late DisplayType mangaHomeDisplayType;
|
||||
|
||||
String? appFontFamily;
|
||||
|
||||
Settings(
|
||||
{this.id = 227,
|
||||
this.displayType = DisplayType.compactGrid,
|
||||
|
|
@ -254,7 +256,8 @@ class Settings {
|
|||
this.customColorFilter,
|
||||
this.colorFilterBlendMode = ColorFilterBlendMode.none,
|
||||
this.playerSubtitleSettings,
|
||||
this.mangaHomeDisplayType = DisplayType.comfortableGrid});
|
||||
this.mangaHomeDisplayType = DisplayType.comfortableGrid,
|
||||
this.appFontFamily});
|
||||
|
||||
Settings.fromJson(Map<String, dynamic> json) {
|
||||
animatePageTransitions = json['animatePageTransitions'];
|
||||
|
|
@ -394,6 +397,7 @@ class Settings {
|
|||
? PlayerSubtitleSettings.fromJson(json['customColorFilter'])
|
||||
: null;
|
||||
mangaHomeDisplayType = DisplayType.values[json['mangaHomeDisplayType']];
|
||||
appFontFamily = json['appFontFamily'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
|
@ -498,6 +502,7 @@ class Settings {
|
|||
if (playerSubtitleSettings != null)
|
||||
'playerSubtitleSettings': playerSubtitleSettings!.toJson(),
|
||||
'mangaHomeDisplayType': mangaHomeDisplayType.index,
|
||||
'appFontFamily': appFontFamily
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -303,13 +303,17 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
|
|||
Widget textWidget(String text, bool selected) => Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(text,
|
||||
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
||||
fontSize: 16,
|
||||
fontStyle: selected ? FontStyle.italic : null,
|
||||
color: selected ? context.primaryColor : null),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis)),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.of(context).padding.top),
|
||||
child: Text(text,
|
||||
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
||||
fontSize: 16,
|
||||
fontStyle: selected ? FontStyle.italic : null,
|
||||
color: selected ? context.primaryColor : null),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
)),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ TextStyle subtileTextStyle(WidgetRef ref) {
|
|||
fontStyle: subSets.useItalic! ? FontStyle.italic : null,
|
||||
color: Color.fromARGB(subSets.textColorA!, subSets.textColorR!,
|
||||
subSets.textColorG!, subSets.textColorB!),
|
||||
fontFamily: "",
|
||||
shadows: [
|
||||
Shadow(
|
||||
offset: const Offset(-1.5, -1.5), color: borderColor, blurRadius: 1.4),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ part of 'library_state_provider.dart';
|
|||
// **************************************************************************
|
||||
|
||||
String _$libraryDisplayTypeStateHash() =>
|
||||
r'6a18446eb49bc55d64fabfb0aa35ff1f2dd52d88';
|
||||
r'9756e17b70fcb76aa6bac2a50e0927c2ad28717f';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ part of 'state_provider.dart';
|
|||
// **************************************************************************
|
||||
|
||||
String _$mangaHomeDisplayTypeStateHash() =>
|
||||
r'd59cd15db8c2884a77c72f5af9d659e0b07c0556';
|
||||
r'48582d80d07c966d5765f20ecc92947e9dd0881c';
|
||||
|
||||
/// See also [MangaHomeDisplayTypeState].
|
||||
@ProviderFor(MangaHomeDisplayTypeState)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import 'package:mangayomi/modules/widgets/draggable_scroll_bar.dart';
|
|||
import 'package:mangayomi/utils/date.dart';
|
||||
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
||||
|
||||
Widget btnToShowChapterListDialog(BuildContext context, String title, Chapter chapter) {
|
||||
Widget btnToShowChapterListDialog(
|
||||
BuildContext context, String title, Chapter chapter) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
|
|
@ -59,6 +60,7 @@ class _ChapterListWidgetState extends State<ChapterListWidget> {
|
|||
return DraggableScrollbarWidget(
|
||||
controller: controller,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
controller: controller,
|
||||
itemCount: chapterList.length,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:mangayomi/modules/more/settings/appearance/providers/app_font_family.dart';
|
||||
import 'package:mangayomi/modules/more/settings/appearance/providers/theme_mode_state_provider.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
||||
|
|
@ -23,6 +25,15 @@ class AppearanceScreen extends ConsumerWidget {
|
|||
final pureBlackDarkMode = ref.watch(pureBlackDarkModeStateProvider);
|
||||
final isDarkTheme = ref.watch(themeModeStateProvider);
|
||||
final l10nLocale = ref.watch(l10nLocaleStateProvider);
|
||||
final appFontFamily = ref.watch(appFontFamilyProvider);
|
||||
final appFontFamilySub = appFontFamily == null
|
||||
? context.l10n.default0
|
||||
: GoogleFonts.asMap()
|
||||
.entries
|
||||
.toList()
|
||||
.firstWhere(
|
||||
(element) => element.value().fontFamily! == appFontFamily)
|
||||
.key;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(l10n!.appearance),
|
||||
|
|
@ -138,6 +149,128 @@ class AppearanceScreen extends ConsumerWidget {
|
|||
fontSize: 11, color: context.secondaryColor),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
String textValue = "";
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(context.l10n.font),
|
||||
content:
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return SizedBox(
|
||||
width: context.mediaWidth(0.8),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
textValue = v;
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
filled: false,
|
||||
enabledBorder:
|
||||
OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: context
|
||||
.secondaryColor),
|
||||
),
|
||||
focusedBorder:
|
||||
OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: context
|
||||
.primaryColor),
|
||||
),
|
||||
border:
|
||||
const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide()),
|
||||
hintText: l10n.search)),
|
||||
),
|
||||
Builder(builder: (context) {
|
||||
List values = GoogleFonts.asMap()
|
||||
.entries
|
||||
.toList();
|
||||
values = values
|
||||
.where((values) => values.key
|
||||
.toLowerCase()
|
||||
.contains(
|
||||
textValue.toLowerCase()))
|
||||
.toList();
|
||||
return Flexible(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: values.length,
|
||||
itemBuilder: (context, index) {
|
||||
final value = values[index];
|
||||
return RadioListTile(
|
||||
dense: true,
|
||||
contentPadding:
|
||||
const EdgeInsets.all(0),
|
||||
value:
|
||||
value.value().fontFamily,
|
||||
groupValue: appFontFamily,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(
|
||||
appFontFamilyProvider
|
||||
.notifier)
|
||||
.set(value);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
title: Text(value.key),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
));
|
||||
}),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
ref
|
||||
.read(appFontFamilyProvider
|
||||
.notifier)
|
||||
.set(null);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(
|
||||
l10n.default0,
|
||||
style: TextStyle(
|
||||
color: context.primaryColor),
|
||||
)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(
|
||||
l10n.cancel,
|
||||
style: TextStyle(
|
||||
color: context.primaryColor),
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
title: Text(context.l10n.font),
|
||||
subtitle: Text(
|
||||
appFontFamilySub,
|
||||
style: TextStyle(
|
||||
fontSize: 11, color: context.secondaryColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'app_font_family.g.dart';
|
||||
|
||||
@riverpod
|
||||
class AppFontFamily extends _$AppFontFamily {
|
||||
@override
|
||||
String? build() {
|
||||
return isar.settings.getSync(227)!.appFontFamily;
|
||||
}
|
||||
|
||||
void set(String? fontFamily) {
|
||||
final settings = isar.settings.getSync(227);
|
||||
state = fontFamily;
|
||||
isar.writeTxnSync(
|
||||
() => isar.settings.putSync(settings!..appFontFamily = fontFamily));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'app_font_family.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$appFontFamilyHash() => r'500f9cd0c0b0dd27d7026c4aa029c33fed337430';
|
||||
|
||||
/// See also [AppFontFamily].
|
||||
@ProviderFor(AppFontFamily)
|
||||
final appFontFamilyProvider =
|
||||
AutoDisposeNotifierProvider<AppFontFamily, String?>.internal(
|
||||
AppFontFamily.new,
|
||||
name: r'appFontFamilyProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$appFontFamilyHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AppFontFamily = AutoDisposeNotifier<String?>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
|
|
@ -6,7 +6,7 @@ part of 'router.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$routerHash() => r'50d606dbd2d70fb41bf26613e12475e787990319';
|
||||
String _$routerHash() => r'b995df5ff14b21e89769cbb0f0955a4a41b39386';
|
||||
|
||||
/// See also [router].
|
||||
@ProviderFor(router)
|
||||
|
|
|
|||
Loading…
Reference in a new issue