Skip to content

Commit eb266c3

Browse files
committed
reorg and fonts
moved services to app module and added variable fonts
1 parent 4bdbdd4 commit eb266c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+7339
-75
lines changed

todo_app/domain_layer_non_rxdart/lib/domain_layer_non_rxdart.dart

-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,3 @@
88
*
99
*/
1010
library domain_layer_non_rxdart;
11-
12-
13-
export 'src/init_logging.dart';
14-
export 'src/services/app_services.dart';
15-
export 'src/services/asset_image_loading_service.dart';
16-
export 'src/services/logging_appenders_service.dart';
17-
export 'src/services/services_provider.dart';
18-
export 'src/set_up_appenders.dart';

todo_app/domain_layer_non_rxdart/pubspec.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ dependencies:
1515
equatable: ^2.0.5
1616
fluent_validation: ^2.1.1
1717
validators: ^3.0.0
18-
logging: ^1.2.0
19-
logging_appenders: ^1.2.0+1
20-
path_provider: ^2.1.1
21-
18+
2219

2320

2421
dev_dependencies:
Binary file not shown.

todo_app/todoapp_vanilla/lib/catcher/catcher_options.dart renamed to todo_app/todoapp_vanilla/lib/infrastructure/catcher/catcher_options.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66

77
import 'package:catcher/catcher.dart';
8-
import 'package:todoapp_vanilla/catcher/catcher_report_modes.dart';
9-
import 'package:todoapp_vanilla/catcher/custom_catcher_logger.dart';
8+
import 'package:todoapp_vanilla/infrastructure/catcher/catcher_report_modes.dart';
9+
import 'package:todoapp_vanilla/infrastructure/catcher/custom_catcher_logger.dart';
10+
1011

1112

1213
CatcherOptions debugOptions = CatcherOptions(pageReportMode, [

todo_app/todoapp_vanilla/lib/const/app.dart renamed to todo_app/todoapp_vanilla/lib/infrastructure/const/app.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22

3+
import 'package:flutter/material.dart';
4+
35
class App {
46
// This class is not meant to be instantiated or extended; this constructor
57
// prevents instantiation and extension.
@@ -17,4 +19,4 @@ class App {
1719

1820

1921

20-
}
22+
}

todo_app/todoapp_vanilla/lib/main.dart

+35-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
// license that can be found in the LICENSE file.
88

99
import 'package:catcher/core/catcher.dart';
10+
import 'package:domain_layer_non_rxdart/domain_layer_non_rxdart.dart';
1011
import 'package:flutter/material.dart';
11-
import 'package:todoapp_vanilla/catcher/catcher_navigator_key.dart';
12-
import 'package:todoapp_vanilla/catcher/catcher_options.dart';
12+
import 'package:todoapp_vanilla/infrastructure/catcher/catcher_navigator_key.dart';
13+
import 'package:todoapp_vanilla/infrastructure/catcher/catcher_options.dart';
1314

1415
import 'package:todoapp_vanilla/my_app.dart';
1516
import 'package:todoapp_vanilla/services/app_services.dart';
1617
import 'package:todoapp_vanilla/services/services_provider.dart';
1718

19+
1820
// Flutter 3.3 and beyond we no longer use runGuardedZone
1921
// Note, there is a move in framework code to
2022
// supply app initialization callbacks which has not
@@ -28,7 +30,38 @@ import 'package:todoapp_vanilla/services/services_provider.dart';
2830
// longer used as it slowed down app load time and thus
2931
// moved to PlatformDispatcher.onError callback which
3032
// is used in the new Catcher code.
33+
34+
// Theme Persistance Notes:
35+
// if using hive would be:
36+
// ```dart
37+
// class HiveStorage extends SDKThemeStorage {
38+
// final box = Hive.box<String>(_boxName);
39+
// final key = 'theme';
40+
// @override
41+
// Future<void> delete() async {
42+
// await box.clear();
43+
// }
44+
//
45+
// @override
46+
// SDLThemeState? read() {
47+
// final res = box.get(key);
48+
// if (res == null) return null;
49+
// return SDKThemeState.fromJson(res);
50+
// }
51+
//
52+
// @override
53+
// Future<void> write(SDKThemeState state) async {
54+
// await box.put(key, state.toJson());
55+
// }
56+
//}
57+
//
58+
// ```
59+
60+
61+
62+
3163
Future<void> main() async {
64+
// then include hive init in AppServices
3265
final myServices = await AppServices.initialize();
3366

3467
Catcher(

todo_app/todoapp_vanilla/lib/my_app.dart

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import 'package:flutter/material.dart';
66
import 'package:todoapp_vanilla/child_widget.dart';
7+
import 'package:todoapp_vanilla/src/presentation/themes/my_light_hc_flex_color_scheme.dart';
8+
79

810
class MyApp extends StatefulWidget {
911
final GlobalKey<NavigatorState> navigatorKey;
@@ -25,6 +27,7 @@ class _MyAppState extends State<MyApp> {
2527
return MaterialApp(
2628
debugShowCheckedModeBanner: false,
2729
navigatorKey: widget.navigatorKey,
30+
highContrastTheme: customLightHCThemeData,
2831
home: Scaffold(
2932
appBar: AppBar(
3033
title: const Text('Plugin example app'),

todo_app/domain_layer_non_rxdart/lib/src/services/app_services.dart renamed to todo_app/todoapp_vanilla/lib/services/app_services.dart

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
import 'package:domain_layer_non_rxdart/src/services/asset_image_loading_service.dart';
6-
import 'package:domain_layer_non_rxdart/src/services/logging_appenders_service.dart';
7-
import 'package:domain_layer_non_rxdart/src/services/services_provider.dart';
5+
86
import 'package:flutter/material.dart';
7+
import 'package:todoapp_vanilla/services/asset_image_loading_service.dart';
8+
import 'package:todoapp_vanilla/services/loading_font_service.dart';
9+
import 'package:todoapp_vanilla/services/logging_appenders_service.dart';
10+
import 'package:todoapp_vanilla/services/services_provider.dart';
911

1012

1113
class AppServices {
1214
final LoggingAppendersService loggingAppendersService;
1315
final AssetImageLoadingService assetImageLoadingService;
16+
final LoadingFontService loadingFontService;
1417

15-
AppServices(this.loggingAppendersService, this.assetImageLoadingService, );
18+
AppServices(this.loggingAppendersService, this.assetImageLoadingService, this.loadingFontService );
1619

1720
static Future<AppServices> initialize() async {
1821

@@ -23,8 +26,12 @@ class AppServices {
2326
final assetImageLoadingService = AssetImageLoadingService();
2427
await assetImageLoadingService.initialize();
2528

29+
30+
final loadingFontService = LoadingFontService();
31+
await loadingFontService.initialize();
32+
2633

27-
return AppServices(loggingAppendersService, assetImageLoadingService);
34+
return AppServices(loggingAppendersService, assetImageLoadingService, loadingFontService);
2835
}
2936

3037
static AppServices of(BuildContext context) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ignore_for_file: empty_constructor_bodies
2+
3+
import 'package:flutter/services.dart';
4+
5+
class LoadingFontService {
6+
LoadingFontService() {}
7+
8+
Future<void> initialize() async {
9+
// I am not updated on the recent AssetManifest API that recently
10+
// was added in the Flutter stable channel and so doing it
11+
// this way instead.
12+
//
13+
// Since we are not using GoogleFonts as it is not
14+
// fully support variable fonts yet we have to manually
15+
// load fonts into the cache
16+
final fontDataOne = await rootBundle.load(
17+
'assets/google_fonts/RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf',
18+
);
19+
final fontLoaderOne = FontLoader('RobotoFlex');
20+
fontLoaderOne.addFont(fontDataOne as Future<ByteData>);
21+
await fontLoaderOne.load();
22+
23+
final fontDataTwo =
24+
await rootBundle.load('assets/google_fonts/RobotoSerif-Italic-VariableFont_GRAD,opsz,wdth,wght.ttf');
25+
final fontLoaderTwo = FontLoader('RobotoSerif-Italian');
26+
fontLoaderTwo.addFont(fontDataTwo as Future<ByteData>);
27+
await fontLoaderTwo.load();
28+
29+
final fontDataThree =
30+
await rootBundle.load('assets/google_fonts/RobotoSerif-VariableFont_GRAD,opsz,wdth,wght.ttf');
31+
final fontLoaderThree = FontLoader('RobotoSerif');
32+
fontLoaderThree.addFont(fontDataThree as Future<ByteData>);
33+
await fontLoaderThree.load();
34+
35+
final fontDataFour = await rootBundle.load('assets/google_fonts/RobotoSlab-VariableFont_wght.ttf');
36+
final fontLoaderFour = FontLoader('RobotoSlab');
37+
fontLoaderFour.addFont(fontDataFour as Future<ByteData>);
38+
await fontLoaderThree.load();
39+
}
40+
}

todo_app/domain_layer_non_rxdart/lib/src/services/logging_appenders_service.dart renamed to todo_app/todoapp_vanilla/lib/services/logging_appenders_service.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
// ignore_for_file: empty_constructor_bodies
66

7-
import 'package:domain_layer_non_rxdart/domain_layer_non_rxdart.dart';
7+
8+
import 'package:todoapp_vanilla/services/init_logging.dart';
9+
import 'package:todoapp_vanilla/services/set_up_appenders.dart';
810

911
class LoggingAppendersService {
1012
LoggingAppendersService() {}

todo_app/domain_layer_non_rxdart/lib/src/services/services_provider.dart renamed to todo_app/todoapp_vanilla/lib/services/services_provider.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// To assist organize stuff as the change
66
// to runApp to have callback initializations
77
// exposed is not in beta or stable yet
8-
import 'package:domain_layer_non_rxdart/src/services/app_services.dart';
8+
99
import 'package:flutter/material.dart';
10+
import 'package:todoapp_vanilla/services/app_services.dart';
1011

1112

1213

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2023 Fredrick Allan Grott. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
6+
7+
// Note: Under MD2 we copyWith'd to keep brand colors.
8+
// While we could use the same approach for MD3
9+
// it would conflict with supporting Material You
10+
// dynamic color. A better approach is to accept
11+
// that brand colors will only show up in the logo
12+
// of the app in appbar and that theme will at times
13+
// show tone and chroma of brand colors but not the
14+
// hue in dynamic color themes.
15+
16+
import 'package:flex_color_scheme/flex_color_scheme.dart';
17+
import 'package:flutter/material.dart';
18+
import 'package:todoapp_vanilla/src/presentation/themes/custom_flex_tones.dart';
19+
20+
Color mySeed = Colors.indigoAccent;
21+
22+
23+
24+
25+
26+
27+
ColorScheme customLightColorScheme = SeedColorScheme.fromSeeds(
28+
29+
primaryKey: mySeed ,
30+
primary: mySeed,
31+
tones: myLightTones,
32+
33+
);
34+
35+
ColorScheme customDarkColorScheme = SeedColorScheme.fromSeeds(
36+
brightness: Brightness.dark,
37+
primaryKey: mySeed,
38+
tones: myDarkTones,
39+
40+
);
41+
42+
ColorScheme customLightHCColorScheme = SeedColorScheme.fromSeeds(
43+
44+
primaryKey: mySeed,
45+
primary: mySeed,
46+
tones: myLightHCTones,
47+
48+
);
49+
50+
ColorScheme cusgtomDarkHCColorScheme = SeedColorScheme.fromSeeds (
51+
brightness: Brightness.dark,
52+
primaryKey: mySeed,
53+
tones: myDarkHCTones,
54+
55+
56+
);

0 commit comments

Comments
 (0)