Skip to content

Commit 93d199d

Browse files
committed
Improve settings design
1 parent eff24a5 commit 93d199d

File tree

7 files changed

+147
-113
lines changed

7 files changed

+147
-113
lines changed

app/lib/settings/home.dart

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:butterfly/cubits/settings.dart';
21
import 'package:butterfly/settings/behaviors.dart';
32
import 'package:butterfly/settings/inputs/home.dart';
43
import 'package:butterfly/settings/data.dart';
@@ -67,102 +66,103 @@ class SettingsPage extends StatefulWidget {
6766

6867
class _SettingsPageState extends State<SettingsPage> {
6968
SettingsView _view = SettingsView.general;
70-
final ScrollController _scrollController = ScrollController();
71-
72-
@override
73-
void dispose() {
74-
super.dispose();
75-
76-
_scrollController.dispose();
77-
}
7869

7970
@override
8071
Widget build(BuildContext context) {
8172
final size = MediaQuery.sizeOf(context);
8273
final isMobile = size.width < LeapBreakpoints.compact;
83-
final body = _buildBody(context, isMobile);
84-
if (widget.isDialog) {
85-
return body;
86-
}
87-
return Scaffold(
88-
appBar: WindowTitleBar<SettingsCubit, ButterflySettings>(
89-
title: Text(AppLocalizations.of(context).settings),
74+
final content = switch (_view) {
75+
SettingsView.general => const GeneralSettingsPage(inView: true),
76+
SettingsView.data => const DataSettingsPage(inView: true),
77+
SettingsView.behaviors => const BehaviorsSettingsPage(inView: true),
78+
SettingsView.inputs => const InputsSettingsPage(inView: true),
79+
SettingsView.personalization => const PersonalizationSettingsPage(
80+
inView: true,
9081
),
91-
body: body,
92-
);
93-
}
82+
SettingsView.view => const ViewSettingsPage(inView: true),
83+
SettingsView.connections => const ConnectionsSettingsPage(inView: true),
84+
SettingsView.experiments => const ExperimentsSettingsPage(inView: true),
85+
SettingsView.logs => const LogsSettingsPage(inView: true),
86+
};
9487

95-
Widget _buildBody(BuildContext context, bool isMobile) {
96-
void navigateTo(SettingsView view) {
97-
if (isMobile) {
98-
context.push(view.path);
99-
} else {
88+
final drawer = NavigationDrawer(
89+
selectedIndex: SettingsView.values
90+
.where((e) => e.isEnabled)
91+
.toList()
92+
.indexOf(_view),
93+
onDestinationSelected: (index) {
94+
final view = SettingsView.values
95+
.where((e) => e.isEnabled)
96+
.toList()[index];
10097
setState(() {
10198
_view = view;
10299
});
103-
}
104-
}
105-
106-
var navigation = Column(
107-
mainAxisSize: MainAxisSize.min,
100+
if (isMobile) {
101+
Navigator.of(context).pop();
102+
}
103+
},
108104
children: [
109-
if (widget.isDialog)
105+
Padding(
106+
padding: const EdgeInsets.fromLTRB(28, 16, 16, 16),
107+
child: Row(
108+
spacing: 16,
109+
children: [
110+
if (widget.isDialog && !isMobile)
111+
IconButton.outlined(
112+
icon: const PhosphorIcon(PhosphorIconsLight.x),
113+
onPressed: () => Navigator.of(context).pop(),
114+
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
115+
),
116+
Expanded(
117+
child: Text(
118+
AppLocalizations.of(context).settings,
119+
style: TextTheme.of(context).headlineSmall,
120+
),
121+
),
122+
],
123+
),
124+
),
125+
...SettingsView.values.where((e) => e.isEnabled).map((view) {
126+
return NavigationDrawerDestination(
127+
icon: PhosphorIcon(view.icon(PhosphorIconsStyle.light)),
128+
selectedIcon: PhosphorIcon(view.icon(PhosphorIconsStyle.fill)),
129+
label: Text(view.getLocalizedName(context)),
130+
);
131+
}),
132+
],
133+
);
134+
135+
if (isMobile) {
136+
return Column(
137+
mainAxisSize: MainAxisSize.min,
138+
children: [
110139
Header(
111-
title: Text(AppLocalizations.of(context).settings),
112140
leading: IconButton.outlined(
113141
icon: const PhosphorIcon(PhosphorIconsLight.x),
114142
onPressed: () => Navigator.of(context).pop(),
115143
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
116144
),
145+
title: Text(AppLocalizations.of(context).settings),
117146
),
118-
Flexible(
119-
child: Material(
120-
type: MaterialType.transparency,
121-
child: ListView(
122-
controller: _scrollController,
123-
shrinkWrap: true,
124-
children: [
125-
...SettingsView.values.where((e) => e.isEnabled).map((view) {
126-
final selected = _view == view && !isMobile;
127-
return ListTile(
128-
leading: PhosphorIcon(
129-
view.icon(
130-
selected
131-
? PhosphorIconsStyle.fill
132-
: PhosphorIconsStyle.light,
133-
),
134-
),
135-
title: Text(view.getLocalizedName(context)),
136-
onTap: () => navigateTo(view),
137-
selected: selected,
138-
);
139-
}),
140-
],
141-
),
147+
ListView(
148+
shrinkWrap: true,
149+
children: SettingsView.values.where((e) => e.isEnabled).map((view) {
150+
return ListTile(
151+
leading: PhosphorIcon(view.icon(PhosphorIconsStyle.light)),
152+
title: Text(view.getLocalizedName(context)),
153+
onTap: () => context.push(view.path),
154+
);
155+
}).toList(),
142156
),
143-
),
144-
],
145-
);
146-
if (isMobile) {
147-
return navigation;
157+
const SizedBox(height: 16),
158+
],
159+
);
148160
}
149-
final content = switch (_view) {
150-
SettingsView.general => const GeneralSettingsPage(inView: true),
151-
SettingsView.data => const DataSettingsPage(inView: true),
152-
SettingsView.behaviors => const BehaviorsSettingsPage(inView: true),
153-
SettingsView.inputs => const InputsSettingsPage(inView: true),
154-
SettingsView.personalization => const PersonalizationSettingsPage(
155-
inView: true,
156-
),
157-
SettingsView.view => const ViewSettingsPage(inView: true),
158-
SettingsView.connections => const ConnectionsSettingsPage(inView: true),
159-
SettingsView.experiments => const ExperimentsSettingsPage(inView: true),
160-
SettingsView.logs => const LogsSettingsPage(inView: true),
161-
};
161+
162162
return Row(
163163
crossAxisAlignment: CrossAxisAlignment.stretch,
164164
children: [
165-
SizedBox(width: 300, child: navigation),
165+
drawer,
166166
Expanded(child: content),
167167
],
168168
);

app/lib/settings/personalization.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ class PersonalizationSettingsPage extends StatelessWidget {
107107
subtitle: Text(_getDensityName(context, state.density)),
108108
onTap: () => _openDensityModal(context),
109109
),
110-
ListTile(
111-
leading: const PhosphorIcon(PhosphorIconsLight.toolbox),
112-
title: Text(AppLocalizations.of(context).toolbarSize),
113-
subtitle: Text(
114-
state.toolbarSize.getLocalizedName(context),
115-
),
116-
onTap: () => _openToolbarSizeModal(context),
117-
),
118110
SwitchListTile(
119111
secondary: const PhosphorIcon(
120112
PhosphorIconsLight.circleHalf,
@@ -303,25 +295,4 @@ class PersonalizationSettingsPage extends StatelessWidget {
303295
.toList(),
304296
);
305297
}
306-
307-
void _openToolbarSizeModal(BuildContext context) {
308-
final cubit = context.read<SettingsCubit>();
309-
var currentSize = cubit.state.toolbarSize;
310-
showLeapBottomSheet(
311-
context: context,
312-
titleBuilder: (context) => Text(AppLocalizations.of(context).toolbarSize),
313-
childrenBuilder: (context) => ToolbarSize.values
314-
.map(
315-
(e) => ListTile(
316-
title: Text(e.getLocalizedName(context)),
317-
selected: currentSize == e,
318-
onTap: () {
319-
cubit.changeToolbarSize(e);
320-
Navigator.of(context).pop();
321-
},
322-
),
323-
)
324-
.toList(),
325-
);
326-
}
327298
}

app/lib/settings/view.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ class ViewSettingsPage extends StatelessWidget {
7575
),
7676
onTap: () => _openToolbarPositionModal(context),
7777
),
78+
ListTile(
79+
leading: const PhosphorIcon(PhosphorIconsLight.toolbox),
80+
title: Text(AppLocalizations.of(context).toolbarSize),
81+
subtitle: Text(
82+
state.toolbarSize.getLocalizedName(context),
83+
),
84+
onTap: () => _openToolbarSizeModal(context),
85+
),
7886
ExactSlider(
7987
header: Text(AppLocalizations.of(context).toolbarRows),
8088
value: state.toolbarRows.toDouble(),
@@ -247,6 +255,27 @@ class ViewSettingsPage extends StatelessWidget {
247255
);
248256
}
249257

258+
void _openToolbarSizeModal(BuildContext context) {
259+
final cubit = context.read<SettingsCubit>();
260+
var currentSize = cubit.state.toolbarSize;
261+
showLeapBottomSheet(
262+
context: context,
263+
titleBuilder: (context) => Text(AppLocalizations.of(context).toolbarSize),
264+
childrenBuilder: (context) => ToolbarSize.values
265+
.map(
266+
(e) => ListTile(
267+
title: Text(e.getLocalizedName(context)),
268+
selected: currentSize == e,
269+
onTap: () {
270+
cubit.changeToolbarSize(e);
271+
Navigator.of(context).pop();
272+
},
273+
),
274+
)
275+
.toList(),
276+
);
277+
}
278+
250279
void _openSimpleToolbarVisibilityModal(BuildContext context) {
251280
final cubit = context.read<SettingsCubit>();
252281
var currentPos = cubit.state.simpleToolbarVisibility;

app/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import flutter_secure_storage_darwin
1414
import irondash_engine_context
1515
import network_info_plus
1616
import package_info_plus
17-
import path_provider_foundation
1817
import screen_retriever_macos
1918
import share_plus
2019
import shared_preferences_foundation
@@ -32,7 +31,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
3231
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
3332
NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin"))
3433
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
35-
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
3634
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
3735
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
3836
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))

app/pubspec.lock

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ packages:
224224
url: "https://pub.dev"
225225
source: hosted
226226
version: "1.1.2"
227+
code_assets:
228+
dependency: transitive
229+
description:
230+
name: code_assets
231+
sha256: ae0db647e668cbb295a3527f0938e4039e004c80099dce2f964102373f5ce0b5
232+
url: "https://pub.dev"
233+
source: hosted
234+
version: "0.19.10"
227235
code_builder:
228236
dependency: transitive
229237
description:
@@ -623,6 +631,14 @@ packages:
623631
url: "https://pub.dev"
624632
source: hosted
625633
version: "5.3.4"
634+
hooks:
635+
dependency: transitive
636+
description:
637+
name: hooks
638+
sha256: "5410b9f4f6c9f01e8ff0eb81c9801ea13a3c3d39f8f0b1613cda08e27eab3c18"
639+
url: "https://pub.dev"
640+
source: hosted
641+
version: "0.20.5"
626642
html:
627643
dependency: transitive
628644
description:
@@ -837,8 +853,8 @@ packages:
837853
dependency: "direct main"
838854
description:
839855
path: "packages/material_leap"
840-
ref: aee41c83dbdde30e47f1a000fa51224b093df25c
841-
resolved-ref: aee41c83dbdde30e47f1a000fa51224b093df25c
856+
ref: cafd10fa5bc129f98fc123870e612e649150557f
857+
resolved-ref: cafd10fa5bc129f98fc123870e612e649150557f
842858
url: "https://github.com/LinwoodDev/dart_pkgs.git"
843859
source: git
844860
version: "0.0.1"
@@ -874,6 +890,14 @@ packages:
874890
url: "https://pub.dev"
875891
source: hosted
876892
version: "3.16.12"
893+
native_toolchain_c:
894+
dependency: transitive
895+
description:
896+
name: native_toolchain_c
897+
sha256: f8872ea6c7a50ce08db9ae280ca2b8efdd973157ce462826c82f3c3051d154ce
898+
url: "https://pub.dev"
899+
source: hosted
900+
version: "0.17.2"
877901
nested:
878902
dependency: transitive
879903
description:
@@ -933,6 +957,14 @@ packages:
933957
url: "https://pub.dev"
934958
source: hosted
935959
version: "0.5.0"
960+
objective_c:
961+
dependency: transitive
962+
description:
963+
name: objective_c
964+
sha256: "55eb67ede1002d9771b3f9264d2c9d30bc364f0267bc1c6cc0883280d5f0c7cb"
965+
url: "https://pub.dev"
966+
source: hosted
967+
version: "9.2.2"
936968
one_dollar_unistroke_recognizer:
937969
dependency: "direct main"
938970
description:
@@ -1001,10 +1033,10 @@ packages:
10011033
dependency: transitive
10021034
description:
10031035
name: path_provider_foundation
1004-
sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4"
1036+
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
10051037
url: "https://pub.dev"
10061038
source: hosted
1007-
version: "2.5.1"
1039+
version: "2.6.0"
10081040
path_provider_linux:
10091041
dependency: transitive
10101042
description:
@@ -1568,10 +1600,10 @@ packages:
15681600
dependency: transitive
15691601
description:
15701602
name: url_launcher_web
1571-
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
1603+
sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f
15721604
url: "https://pub.dev"
15731605
source: hosted
1574-
version: "2.4.1"
1606+
version: "2.4.2"
15751607
url_launcher_windows:
15761608
dependency: transitive
15771609
description:
@@ -1717,5 +1749,5 @@ packages:
17171749
source: hosted
17181750
version: "3.1.3"
17191751
sdks:
1720-
dart: ">=3.10.0 <4.0.0"
1752+
dart: ">=3.10.3 <4.0.0"
17211753
flutter: ">=3.38.7"

app/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies:
6262
material_leap:
6363
git:
6464
url: https://github.com/LinwoodDev/dart_pkgs.git
65-
ref: aee41c83dbdde30e47f1a000fa51224b093df25c
65+
ref: cafd10fa5bc129f98fc123870e612e649150557f
6666
path: packages/material_leap
6767
lw_sysapi:
6868
git:

0 commit comments

Comments
 (0)