Skip to content

Commit 7fc463b

Browse files
authored
feat: Integrated theme tailor (#141)
1 parent 75e9207 commit 7fc463b

File tree

13 files changed

+353
-201
lines changed

13 files changed

+353
-201
lines changed

lib/data/interceptor/auth_interceptor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import 'package:flutter_template/data/interceptor/meta_interceptor.dart';
44
import 'package:flutter_template/data/model/auth/auth_tokens.dart';
55
import 'package:flutter_template/data/preferences/auth_preferences.dart';
66
import 'package:flutter_template/data/response_objects/response_error.dart';
7+
import 'package:flutter_template/data/response_objects/tokens_response.dart';
78
import 'package:flutter_template/data/services/http_client/dio_http_client.dart';
89
import 'package:flutter_template/data/services/http_client/http_client.dart';
9-
import 'package:flutter_template/data/response_objects/tokens_response.dart';
1010
import 'package:flutter_template/domain/preferences/user_preferences.dart';
1111

1212
class AuthInterceptor extends InterceptorsWrapper {

lib/injection/dependencies.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:flutter_template/presentation/routes/router.dart';
55
class DependencyManager {
66
static Future<void> inject(AppFlavor flavor) async {
77
injector.registerLazySingleton<AppFlavor>(() => flavor);
8-
injector.registerLazySingleton<AppRouter>(() => AppRouter());
8+
injector.registerLazySingleton<AppRouter>(AppRouter.new);
99

1010
await configureDependencies();
1111
}

lib/presentation/app.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class App extends StatelessWidget {
2020
themeMode: ThemeMode.system,
2121
title: 'Project Name',
2222
builder: (c, widget) {
23-
if (widget == null) return const SizedBox();
23+
if (widget == null) {
24+
return const SizedBox();
25+
}
2426

2527
return NStackWidget(
2628
child: widget,

lib/presentation/extensions/presentation_extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// A set of extensions that can be used on the presentation layer.
1+
/// A set of extensions that can be used on the presentation layer.
22
library presentation_extensions;
33

44
export 'color_extensions.dart';

lib/presentation/features/profile/cubit/profile_cubit.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ final class ProfileCubit extends Cubit<ProfileState> {
2424
try {
2525
final profileName = await _getProfileUseCase();
2626

27-
if (isClosed) return;
27+
if (isClosed) {
28+
return;
29+
}
2830

2931
return emit(
3032
state.copyWith(
@@ -35,7 +37,9 @@ final class ProfileCubit extends Cubit<ProfileState> {
3537
} catch (e) {
3638
final responseError = ResponseError.from(e);
3739

38-
if (isClosed) return;
40+
if (isClosed) {
41+
return;
42+
}
3943

4044
return emit(
4145
state.copyWith(

lib/presentation/features/profile/ui/profile_body.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ProfileBody extends StatelessWidget {
2727
Padding(
2828
padding: const EdgeInsets.all(32.0),
2929
child: status.maybeWhen(
30-
loading: () => AppLoadingIndicator.small(),
30+
loading: AppLoadingIndicator.small,
3131
success: () => AppText.body(
3232
name,
3333
textAlign: TextAlign.center,

lib/presentation/resources/app_colors.dart

Lines changed: 22 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_template/presentation/resources/app_color_palette.dart';
3+
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
34

4-
class AppColors extends ThemeExtension<AppColors> {
5+
part 'app_colors.tailor.dart';
6+
7+
@TailorMixin()
8+
class AppColors extends ThemeExtension<AppColors> with _$AppColorsTailorMixin {
59
static Color get black => AppColorPalette.black;
610
static Color get white => AppColorPalette.white;
711

@@ -26,24 +30,41 @@ class AppColors extends ThemeExtension<AppColors> {
2630
});
2731

2832
// Core colors
33+
@override
2934
final Color primary;
35+
@override
3036
final Color primaryVariant;
37+
@override
3138
final Color secondary;
39+
@override
3240
final Color secondaryVariant;
41+
@override
3342
final Color background;
43+
@override
3444
final Color appBarBackground;
45+
@override
3546
final Color danger;
47+
@override
3648
final Color foregroundOnBackground;
49+
@override
3750
final Color foregroundLightOnBackground;
51+
@override
3852
final Color foregroundOnPrimary;
53+
@override
3954
final Color foregroundOnSecondary;
55+
@override
4056
final Color foregroundOnAppBar;
57+
@override
4158
final Color foregroundOnDanger;
59+
@override
4260
final Color outline;
61+
@override
4362
final Color transparant;
4463

4564
// Other colors
65+
@override
4666
final Color splashColor;
67+
@override
4768
final Color disabledColor;
4869

4970
factory AppColors.fromBrightness(Brightness brightness) =>
@@ -95,148 +116,6 @@ class AppColors extends ThemeExtension<AppColors> {
95116
disabledColor: AppColorPalette.silverPolish,
96117
);
97118
}
98-
99-
@override
100-
ThemeExtension<AppColors> copyWith({
101-
Color? primary,
102-
Color? primaryVariant,
103-
Color? secondary,
104-
Color? secondaryVariant,
105-
Color? background,
106-
Color? appBarBackground,
107-
Color? danger,
108-
Color? foregroundOnBackground,
109-
Color? foregroundLightOnBackground,
110-
Color? foregroundOnPrimary,
111-
Color? foregroundOnSecondary,
112-
Color? foregroundOnAppBar,
113-
Color? foregroundOnDanger,
114-
Color? transparant,
115-
Color? outline,
116-
Color? splashColor,
117-
Color? disabledColor,
118-
}) {
119-
return AppColors(
120-
primary: primary ?? this.primary,
121-
primaryVariant: primaryVariant ?? this.primaryVariant,
122-
secondary: secondary ?? this.secondary,
123-
secondaryVariant: secondaryVariant ?? this.secondaryVariant,
124-
background: background ?? this.background,
125-
appBarBackground: appBarBackground ?? this.appBarBackground,
126-
danger: danger ?? this.danger,
127-
foregroundOnBackground:
128-
foregroundOnBackground ?? this.foregroundOnBackground,
129-
foregroundLightOnBackground:
130-
foregroundLightOnBackground ?? this.foregroundLightOnBackground,
131-
foregroundOnPrimary: foregroundOnPrimary ?? this.foregroundOnPrimary,
132-
foregroundOnSecondary:
133-
foregroundOnSecondary ?? this.foregroundOnSecondary,
134-
foregroundOnAppBar: foregroundOnAppBar ?? this.foregroundOnAppBar,
135-
foregroundOnDanger: foregroundOnDanger ?? this.foregroundOnDanger,
136-
outline: outline ?? this.outline,
137-
transparant: transparant ?? this.transparant,
138-
splashColor: splashColor ?? this.splashColor,
139-
disabledColor: disabledColor ?? this.disabledColor,
140-
);
141-
}
142-
143-
@override
144-
ThemeExtension<AppColors> lerp(
145-
covariant ThemeExtension<AppColors>? other,
146-
double t,
147-
) {
148-
if (other is! AppColors) {
149-
return this;
150-
}
151-
152-
return AppColors(
153-
primary: Color.lerp(
154-
primary,
155-
other.primary,
156-
t,
157-
)!,
158-
primaryVariant: Color.lerp(
159-
primaryVariant,
160-
other.primaryVariant,
161-
t,
162-
)!,
163-
secondary: Color.lerp(
164-
secondary,
165-
other.secondary,
166-
t,
167-
)!,
168-
secondaryVariant: Color.lerp(
169-
secondaryVariant,
170-
other.secondaryVariant,
171-
t,
172-
)!,
173-
background: Color.lerp(
174-
background,
175-
other.background,
176-
t,
177-
)!,
178-
appBarBackground: Color.lerp(
179-
appBarBackground,
180-
other.appBarBackground,
181-
t,
182-
)!,
183-
danger: Color.lerp(
184-
danger,
185-
other.danger,
186-
t,
187-
)!,
188-
foregroundOnBackground: Color.lerp(
189-
foregroundOnBackground,
190-
other.foregroundOnBackground,
191-
t,
192-
)!,
193-
foregroundLightOnBackground: Color.lerp(
194-
foregroundLightOnBackground,
195-
other.foregroundLightOnBackground,
196-
t,
197-
)!,
198-
foregroundOnPrimary: Color.lerp(
199-
foregroundOnPrimary,
200-
other.foregroundOnPrimary,
201-
t,
202-
)!,
203-
foregroundOnSecondary: Color.lerp(
204-
foregroundOnSecondary,
205-
other.foregroundOnSecondary,
206-
t,
207-
)!,
208-
foregroundOnAppBar: Color.lerp(
209-
foregroundOnAppBar,
210-
other.foregroundOnAppBar,
211-
t,
212-
)!,
213-
foregroundOnDanger: Color.lerp(
214-
foregroundOnDanger,
215-
other.foregroundOnDanger,
216-
t,
217-
)!,
218-
outline: Color.lerp(
219-
outline,
220-
other.outline,
221-
t,
222-
)!,
223-
transparant: Color.lerp(
224-
transparant,
225-
other.transparant,
226-
t,
227-
)!,
228-
splashColor: Color.lerp(
229-
splashColor,
230-
other.splashColor,
231-
t,
232-
)!,
233-
disabledColor: Color.lerp(
234-
disabledColor,
235-
other.disabledColor,
236-
t,
237-
)!,
238-
);
239-
}
240119
}
241120

242121
extension AppColorsExtension on BuildContext {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy