some little refactor

This commit is contained in:
ALEZ-DEV 2024-05-15 21:33:28 +02:00
parent 94f3128932
commit cd457941b1
2 changed files with 33 additions and 23 deletions

View File

@ -13,15 +13,15 @@ class StyleSettingsPage extends StatefulWidget {
} }
class _StyleSettingsPageState extends State<StyleSettingsPage> { class _StyleSettingsPageState extends State<StyleSettingsPage> {
late int _radioValue; late BackgroundType _radioValue;
void setBackgroundValue( void setBackgroundValue(
BuildContext context, BuildContext context,
SettingsProvider provider, SettingsProvider provider,
int? value, BackgroundType? value,
) { ) {
if (value != null) { if (value != null) {
provider.setSelectedBackgroundType = Settings.backgoundList[value]; provider.setSelectedBackgroundType = value;
setState(() { setState(() {
_radioValue = value; _radioValue = value;
}); });
@ -31,30 +31,39 @@ class _StyleSettingsPageState extends State<StyleSettingsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final provider = Provider.of<SettingsProvider>(context, listen: false); final provider = Provider.of<SettingsProvider>(context, listen: false);
_radioValue = Settings.backgoundList.indexWhere( _radioValue = provider.getSelectedBackgroundType;
(element) => element == provider.getSelectedBackgroundType,
);
return Center( return Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: SizedBox(
child: YaruSection( child: YaruSection(
headline: const Text('Background video'), headline: const Text('Background video'),
child: Column( child: Column(
children: [ children: Settings.backgoundList
for (int i = 0; i < Settings.backgoundList.length; i++) .map(
YaruRadioListTile( (b) => YaruRadioListTile(
value: i, value: b,
groupValue: _radioValue, groupValue: _radioValue,
onChanged: (v) => setBackgroundValue(context, provider, v), onChanged: (v) =>
setBackgroundValue(context, provider, v),
toggleable: true, toggleable: true,
title: Text( title: Text(
Settings.getStringNameOfBackgroundType( Settings.getStringNameOfBackgroundType(
Settings.backgoundList[i], b,
),
),
),
)
.toList(),
),
), ),
), ),
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -32,7 +32,8 @@ class _SettingsScreenState extends State<SettingsScreen>
return Center( return Center(
child: Column( child: Column(
children: [ children: [
SizedBox( Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: YaruTabBar( child: YaruTabBar(
tabController: tabController, tabController: tabController,
tabs: SettingsPage.tabItems(), tabs: SettingsPage.tabItems(),