Skip to content

Commit

Permalink
Merge branch 'master' into refactored-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen authored Sep 28, 2023
2 parents 4d8ef1c + a2e651b commit f71427f
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rename_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "master" ]

jobs:
check_analyzer:
check_rename_project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/strip_boilerplate_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "master" ]

jobs:
check_analyzer:
check_strip_boilerplate_project:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "master" ]

jobs:
check_analyzer:
check_strip_boilerplate_project_remove_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 6 additions & 4 deletions lib/repository/shared_prefs/local/local_storage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_template/repository/secure_storage/auth/auth_storage.dart';
import 'package:flutter_template/util/extension/theme_mode_extension.dart';
import 'package:icapps_architecture/icapps_architecture.dart';
import 'package:injectable/injectable.dart';

Expand Down Expand Up @@ -39,14 +40,15 @@ class _LocalStorage implements LocalStorage {
}

@override
Future<void> updateThemeMode(ThemeMode themeMode) async {
await _sharedPreferences.saveString(key: _appearanceThemeKey, value: themeMode.toString());
}
Future<void> updateThemeMode(ThemeMode themeMode) async => _sharedPreferences.saveString(
key: _appearanceThemeKey,
value: themeMode.stringValue,
);

@override
ThemeMode? getThemeMode() {
final themeString = _sharedPreferences.getString(_appearanceThemeKey);
return ThemeMode.values.find((element) => element.toString() == themeString);
return ThemeMode.values.find((element) => element.stringValue == themeString);
}

@override
Expand Down
9 changes: 9 additions & 0 deletions lib/util/extension/theme_mode_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:flutter/material.dart';

extension ThemeModeExtension on ThemeMode {
String get stringValue => switch (this) {
ThemeMode.dark => 'dark',
ThemeMode.light => 'light',
ThemeMode.system => 'system',
};
}
2 changes: 1 addition & 1 deletion lib/widget/general/text_scale_factor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextScaleFactor extends StatelessWidget {
FlavorConfig.instance.devicePixelRatio = mediaQuery.devicePixelRatio;
if (FlavorConfig.isInTest()) return child;
return MediaQuery(
data: mediaQuery.copyWith(textScaleFactor: mediaQuery.textScaleFactor.clamp(0, 1.6)),
data: mediaQuery.copyWith(textScaleFactor: mediaQuery.textScaleFactor.clamp(0.8, 1.4)),
child: child,
);
}
Expand Down
41 changes: 33 additions & 8 deletions test/util/test_util.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,35 @@ class MockErrorUtil extends _i2.Mock implements _i8.ErrorUtil {
}

@override
void showErrorWithLocaleKey(
String? errorKey, {
String? showError({
required dynamic error,
required _i1.BuildContext? context,
}) =>
(super.noSuchMethod(Invocation.method(
#showError,
[],
{
#error: error,
#context: context,
},
)) as String?);
@override
void showErrorWithLocaleKey({
required String? messageKey,
required _i1.BuildContext? context,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#context: context,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -286,15 +306,20 @@ class MockMainNavigator extends _i2.Mock implements _i9.MainNavigator {
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ class MockMainNavigator extends _i2.Mock implements _i3.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 9 additions & 4 deletions test/viewmodel/debug/debug_viewmodel_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ class MockMainNavigator extends _i2.Mock implements _i3.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 9 additions & 4 deletions test/viewmodel/license/license_viewmodel_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ class MockMainNavigator extends _i2.Mock implements _i3.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 9 additions & 4 deletions test/viewmodel/login/login_viewmodel_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,20 @@ class MockMainNavigator extends _i2.Mock implements _i5.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,20 @@ class MockMainNavigator extends _i2.Mock implements _i8.MainNavigator {
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 9 additions & 4 deletions test/viewmodel/todo/todo_add/todo_add_viewmodel_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ class MockMainNavigator extends _i2.Mock implements _i6.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ class MockMainNavigator extends _i2.Mock implements _i6.MainNavigator {
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
void showErrorWithLocaleKey(
String? errorKey, {
void showErrorWithLocaleKey({
required String? messageKey,
String? titleKey,
List<dynamic>? args,
}) =>
super.noSuchMethod(
Invocation.method(
#showErrorWithLocaleKey,
[errorKey],
{#args: args},
[],
{
#messageKey: messageKey,
#titleKey: titleKey,
#args: args,
},
),
returnValueForMissingStub: null,
);
Expand Down
12 changes: 3 additions & 9 deletions tool/dart_tool/strip_boilerplate_project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,9 @@ void replaceBoilerplateReferences(Directory dir) {

void _replaceHomeScreenLine() {
_replaceInFile(
'lib/screen/home/home_screen.dart',
''' children: const [
TodoListScreen(),
DebugScreen(),
],''',
''' children: const [
SizedBox(),
DebugScreen(),
],''',
'lib/model/bottom_navigation/bottom_navigation_tab.dart',
'BottomNavigationTab.todo => const TodoListScreen(),',
'BottomNavigationTab.todo => const SizedBox.shrink(),',
);
}

Expand Down

0 comments on commit f71427f

Please sign in to comment.