forked from firka/firka
fix: dynamic icon switching
This commit is contained in:
@@ -52,8 +52,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
));
|
||||
}
|
||||
|
||||
List<Widget> createWidgetTree(
|
||||
Iterable<SettingsItem> items, SettingsStore settings) {
|
||||
List<Widget> createWidgetTree(Iterable<SettingsItem> items,
|
||||
SettingsStore settings) {
|
||||
var widgets = List<Widget>.empty(growable: true);
|
||||
|
||||
for (var item in items) {
|
||||
@@ -83,7 +83,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
widgets.add(Text(
|
||||
item.title,
|
||||
style:
|
||||
appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary),
|
||||
appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary),
|
||||
));
|
||||
|
||||
continue;
|
||||
@@ -188,9 +188,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
Checkbox(
|
||||
value: true,
|
||||
fillColor: WidgetStateProperty.resolveWith<Color>(
|
||||
(Set<WidgetState> states) {
|
||||
return appStyle.colors.secondary;
|
||||
}),
|
||||
(Set<WidgetState> states) {
|
||||
return appStyle.colors.secondary;
|
||||
}),
|
||||
onChanged: (_) async {
|
||||
setState(() {
|
||||
item.activeIndex = i;
|
||||
@@ -235,7 +235,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
fit: BoxFit.cover),
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
@@ -244,7 +247,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(16.0)),
|
||||
const BorderRadius.all(Radius.circular(16.0)),
|
||||
child: Image.asset(
|
||||
"assets/images/icons/$activeIcon.png",
|
||||
width: 74,
|
||||
@@ -278,39 +281,41 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
GestureDetector(
|
||||
child: active
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12.0)),
|
||||
child: Image.asset(
|
||||
"assets/images/icons/$icon.png",
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(16.0)),
|
||||
child: Image.asset(
|
||||
"assets/images/icons/$icon.png",
|
||||
width: 54,
|
||||
height: 54,
|
||||
),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12.0)),
|
||||
child: Image.asset(
|
||||
"assets/images/icons/$icon.png",
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(16.0)),
|
||||
child: Image.asset(
|
||||
"assets/images/icons/$icon.png",
|
||||
width: 54,
|
||||
height: 54,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (settingAppIcon) return;
|
||||
|
||||
setState(() {
|
||||
activeIcon = icon;
|
||||
});
|
||||
@@ -328,7 +333,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
pWidgets.add(Text(
|
||||
group,
|
||||
style:
|
||||
appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary),
|
||||
appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary),
|
||||
));
|
||||
pWidgets.add(SizedBox(height: 12));
|
||||
pWidgets.add(SizedBox(
|
||||
@@ -342,12 +347,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
}
|
||||
|
||||
widgets.add(SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.7,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height / 1.7,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: pWidgets,
|
||||
)),
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: pWidgets,
|
||||
)),
|
||||
));
|
||||
|
||||
widgets.add(Row(
|
||||
@@ -413,7 +421,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: SafeArea(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
@@ -441,11 +452,15 @@ void showSetDoubleSheet(BuildContext context, SettingsDouble setting,
|
||||
backgroundColor: Colors.transparent,
|
||||
barrierColor: appStyle.colors.a15p,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.13,
|
||||
maxHeight: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height * 0.13,
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, setState) => Stack(
|
||||
builder: (BuildContext context, setState) =>
|
||||
Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
@@ -460,7 +475,7 @@ void showSetDoubleSheet(BuildContext context, SettingsDouble setting,
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius:
|
||||
BorderRadius.vertical(top: Radius.circular(16)),
|
||||
BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
@@ -469,9 +484,9 @@ void showSetDoubleSheet(BuildContext context, SettingsDouble setting,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
setting.title,
|
||||
style: appStyle.fonts.B_14R,
|
||||
)),
|
||||
setting.title,
|
||||
style: appStyle.fonts.B_14R,
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 0, horizontal: 40),
|
||||
|
||||
Reference in New Issue
Block a user