-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
317c96c
commit a413ca5
Showing
7 changed files
with
178 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
import 'package:yaru_widgets/yaru_widgets.dart'; | ||
import 'package:yaru_widgets_example/theme.dart'; | ||
|
||
class ColorDiskPage extends StatefulWidget { | ||
const ColorDiskPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<ColorDiskPage> createState() => _ColorDiskPageState(); | ||
} | ||
|
||
class _ColorDiskPageState extends State<ColorDiskPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
final lightTheme = context.read<LightTheme>(); | ||
final darkTheme = context.read<DarkTheme>(); | ||
return YaruPage(children: [ | ||
SingleChildScrollView( | ||
scrollDirection: Axis.horizontal, | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
for (var globalTheme in globalThemeList) | ||
YaruColorDisk( | ||
onPressed: () { | ||
lightTheme.value = globalTheme.lightTheme; | ||
darkTheme.value = globalTheme.darkTheme; | ||
}, | ||
color: globalTheme.primaryColor, | ||
selected: | ||
Theme.of(context).primaryColor == globalTheme.primaryColor, | ||
), | ||
], | ||
), | ||
) | ||
]); | ||
} | ||
} | ||
|
||
final List<GlobalTheme> globalThemeList = [ | ||
GlobalTheme( | ||
lightTheme: yaruLight, | ||
darkTheme: yaruDark, | ||
primaryColor: YaruColors.ubuntuOrange, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruSageLight, | ||
darkTheme: yaruSageDark, | ||
primaryColor: sageMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruBarkLight, | ||
darkTheme: yaruBarkDark, | ||
primaryColor: barkMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruOliveLight, | ||
darkTheme: yaruOliveDark, | ||
primaryColor: oliveMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruViridianLight, | ||
darkTheme: yaruViridianDark, | ||
primaryColor: viridianMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruPrussianGreenLight, | ||
darkTheme: yaruPrussianGreenDark, | ||
primaryColor: prussianGreenMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruBlueLight, | ||
darkTheme: yaruBlueDark, | ||
primaryColor: blueMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruPurpleLight, | ||
darkTheme: yaruPurpleDark, | ||
primaryColor: purpleMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yarMagentaLight, | ||
darkTheme: yaruMagentaDark, | ||
primaryColor: magentaMaterialColor, | ||
), | ||
GlobalTheme( | ||
lightTheme: yaruRedLight, | ||
darkTheme: yaruRedDark, | ||
primaryColor: lightRedMaterialColor, | ||
), | ||
]; | ||
|
||
class GlobalTheme { | ||
final ThemeData lightTheme; | ||
final ThemeData darkTheme; | ||
final MaterialColor primaryColor; | ||
|
||
GlobalTheme({ | ||
required this.lightTheme, | ||
required this.darkTheme, | ||
required this.primaryColor, | ||
}); | ||
} |
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,9 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class LightTheme extends ValueNotifier<ThemeData> { | ||
LightTheme(ThemeData value) : super(value); | ||
} | ||
|
||
class DarkTheme extends ValueNotifier<ThemeData> { | ||
DarkTheme(ThemeData value) : super(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
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,43 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class YaruColorDisk extends StatelessWidget { | ||
const YaruColorDisk( | ||
{Key? key, | ||
required this.onPressed, | ||
required this.color, | ||
required this.selected}) | ||
: super(key: key); | ||
|
||
final VoidCallback onPressed; | ||
final Color color; | ||
final bool selected; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: 42, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: TextButton( | ||
style: TextButton.styleFrom( | ||
padding: const EdgeInsets.all(0), | ||
shape: CircleBorder( | ||
side: BorderSide( | ||
color: selected | ||
? Theme.of(context).primaryColor | ||
: Colors.transparent)), | ||
), | ||
onPressed: onPressed, | ||
child: SizedBox( | ||
height: 20, | ||
width: 20, | ||
child: DecoratedBox( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(100), color: color), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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