-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add switch to allow toggling to use material 3
- Loading branch information
Showing
12 changed files
with
235 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:appainter/advanced_theme/advanced_theme.dart'; | ||
import 'package:appainter/basic_theme/basic_theme.dart'; | ||
import 'package:appainter/home/home.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
class Material3Switch extends StatelessWidget { | ||
const Material3Switch({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
children: [ | ||
Text( | ||
'Material 3 (beta)', | ||
style: Theme.of(context).textTheme.subtitle2, | ||
), | ||
const _Switch(), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _Switch extends StatelessWidget { | ||
const _Switch({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final editMode = context.watch<HomeCubit>().state.editMode; | ||
final basicThemeUseMaterial3 = | ||
context.watch<BasicThemeCubit>().state.useMaterial3; | ||
final advancedThemeUseMaterial3 = | ||
context.watch<AdvancedThemeCubit>().state.useMaterial3; | ||
|
||
return Switch( | ||
activeColor: Colors.blueGrey, | ||
onChanged: (value) => _onChanged(context, editMode, value), | ||
value: editMode == EditMode.basic | ||
? basicThemeUseMaterial3 | ||
: advancedThemeUseMaterial3, | ||
); | ||
} | ||
|
||
void _onChanged(BuildContext context, EditMode editMode, bool value) { | ||
if (editMode == EditMode.basic) { | ||
context.read<BasicThemeCubit>().useMaterial3Changed(value); | ||
} else { | ||
context.read<AdvancedThemeCubit>().useMaterial3Changed(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
export 'import_button.dart'; | ||
export 'app_theme_mode_button.dart'; | ||
export 'export_button.dart'; | ||
export 'usage_button.dart'; | ||
export 'github_button.dart'; | ||
export 'import_button.dart'; | ||
export 'material3_switch.dart'; | ||
export 'random_theme_button.dart'; | ||
export 'reset_theme_button.dart'; | ||
export 'theme_brightness_switch.dart'; | ||
export 'app_theme_mode_button.dart'; | ||
export 'usage_button.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.