Skip to content

Commit

Permalink
changed modalbottombar with switch
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Jan 27, 2023
1 parent 6ffe4c4 commit 332480b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 84 deletions.
29 changes: 29 additions & 0 deletions lib/customWidgets/setting_switch_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:musify/style/appTheme.dart';

class SettingSwitchBar extends StatelessWidget {
SettingSwitchBar(this.tileName, this.tileIcon, this.value, this.onChanged);

final Function(bool) onChanged;
final bool value;
final String tileName;
final IconData tileIcon;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 8, left: 8, right: 8, bottom: 6),
child: Card(
child: SwitchListTile(
secondary: Icon(tileIcon, color: accent.primary),
title: Text(
tileName,
style: TextStyle(color: accent.primary),
),
value: value,
onChanged: onChanged,
),
),
);
}
}
6 changes: 6 additions & 0 deletions lib/style/appTheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ ThemeData getAppDarkTheme() {
elevation: 2.3,
),
listTileTheme: const ListTileThemeData(textColor: Colors.white),
switchTheme: SwitchThemeData(
trackColor: MaterialStateProperty.all(accent.primary),
),
iconTheme: const IconThemeData(color: Colors.white),
hintColor: Colors.white,
textTheme: const TextTheme(
Expand Down Expand Up @@ -81,6 +84,9 @@ ThemeData getAppLightTheme() {
listTileTheme: ListTileThemeData(
selectedColor: accent.primary.withOpacity(0.4),
),
switchTheme: SwitchThemeData(
trackColor: MaterialStateProperty.all(accent.primary),
),
iconTheme: const IconThemeData(color: Color(0xFF151515)),
hintColor: const Color(0xFF151515),
);
Expand Down
102 changes: 18 additions & 84 deletions lib/ui/morePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hive/hive.dart';
import 'package:musify/customWidgets/setting_bar.dart';
import 'package:musify/customWidgets/setting_switch_bar.dart';
import 'package:musify/helper/flutter_toast.dart';
import 'package:musify/helper/url_launcher.dart';
import 'package:musify/helper/version.dart';
Expand Down Expand Up @@ -334,92 +335,25 @@ class SettingsCards extends StatelessWidget {
),
},
),
SettingBar(
SettingSwitchBar(
AppLocalizations.of(context)!.useSystemColor,
FluentIcons.toggle_left_24_filled,
() => {
showModalBottomSheet(
isDismissible: true,
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) {
return Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: accent.primary,
),
borderRadius: const BorderRadius.all(
Radius.circular(20),
),
),
width: MediaQuery.of(context).copyWith().size.width * 0.90,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Card(
child: ListTile(
title: Text(
AppLocalizations.of(context)!.trueMSG,
style: TextStyle(color: accent.primary),
),
onTap: () {
addOrUpdateData(
'settings',
'useSystemColor',
true,
);
useSystemColor.value = true;
MyApp.setAccentColor(
context,
accent.primary,
true,
);
showToast(
AppLocalizations.of(context)!
.settingChangedMsg,
);
Navigator.pop(context);
},
),
),
),
Padding(
padding: const EdgeInsets.all(10),
child: Card(
child: ListTile(
title: Text(
AppLocalizations.of(context)!.falseMSG,
style: TextStyle(color: accent.primary),
),
onTap: () {
addOrUpdateData(
'settings',
'useSystemColor',
false,
);
useSystemColor.value = false;
MyApp.setAccentColor(
context,
accent.primary,
false,
);
showToast(
AppLocalizations.of(context)!
.settingChangedMsg,
);
Navigator.pop(context);
},
),
),
)
],
),
),
);
},
),
useSystemColor.value,
(value) {
addOrUpdateData(
'settings',
'useSystemColor',
value,
);
useSystemColor.value = value;
MyApp.setAccentColor(
context,
accent.primary,
value,
);
showToast(
AppLocalizations.of(context)!.settingChangedMsg,
);
},
),

Expand Down

0 comments on commit 332480b

Please sign in to comment.