forked from Predidit/Kazumi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Predidit#616 from ErBWs/feat-theme-palette
feat: color palette for theme picker
- Loading branch information
Showing
3 changed files
with
101 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:material_color_utilities/material_color_utilities.dart'; | ||
|
||
class PaletteCard extends StatefulWidget { | ||
final Color color; | ||
final bool selected; | ||
|
||
const PaletteCard({ | ||
super.key, | ||
required this.color, | ||
required this.selected, | ||
}); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _PaletteCardState(); | ||
} | ||
|
||
class _PaletteCardState extends State<PaletteCard> { | ||
@override | ||
Widget build(BuildContext context) { | ||
final Hct hct = Hct.fromInt(widget.color.value); | ||
final primary = Color(Hct.from(hct.hue, 20.0, 90.0).toInt()); | ||
final tertiary = Color(Hct.from(hct.hue + 50, 20.0, 85.0).toInt()); | ||
final primaryContainer = Color(Hct.from(hct.hue, 30.0, 50.0).toInt()); | ||
final checkbox = Color(Hct.from(hct.hue, 30.0, 40.0).toInt()); | ||
return SizedBox( | ||
width: 70, | ||
height: 70, | ||
child: Stack( | ||
children: [ | ||
Card( | ||
elevation: 0, | ||
child: Container( | ||
padding: const EdgeInsets.all(10), | ||
child: ClipOval( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Expanded( | ||
child: Container( | ||
color: primary, | ||
), | ||
), | ||
Expanded( | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Expanded( | ||
child: Container( | ||
color: tertiary, | ||
), | ||
), | ||
Expanded( | ||
child: Container( | ||
color: primaryContainer, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
if (widget.selected) | ||
Center( | ||
child: Container( | ||
width: 25, | ||
height: 25, | ||
decoration: BoxDecoration( | ||
color: checkbox, | ||
shape: BoxShape.circle, | ||
), | ||
child: Icon( | ||
Icons.check_rounded, | ||
color: Theme.of(context).colorScheme.surfaceContainerLow, | ||
size: 12, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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