Compare commits
3 Commits
a957126d90
...
b6ded4d026
Author | SHA1 | Date | |
---|---|---|---|
b6ded4d026 | |||
e19e606a96 | |||
734f2d3ffe |
@ -1,2 +1,3 @@
|
|||||||
cupertino
|
cupertino
|
||||||
cupertinoicons
|
cupertinoicons
|
||||||
|
onetwothree
|
@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:repertory/constants.dart' as constants;
|
import 'package:repertory/constants.dart' as constants;
|
||||||
|
import 'package:repertory/helpers.dart';
|
||||||
import 'package:repertory/models/mount_list.dart';
|
import 'package:repertory/models/mount_list.dart';
|
||||||
|
import 'package:repertory/types/mount_config.dart';
|
||||||
import 'package:repertory/widgets/mount_list_widget.dart';
|
import 'package:repertory/widgets/mount_list_widget.dart';
|
||||||
import 'package:repertory/widgets/mount_settings.dart';
|
import 'package:repertory/widgets/mount_settings.dart';
|
||||||
|
|
||||||
@ -24,10 +26,14 @@ class MyApp extends StatelessWidget {
|
|||||||
routes: {'/': (context) => const MyHomePage(title: constants.appTitle)},
|
routes: {'/': (context) => const MyHomePage(title: constants.appTitle)},
|
||||||
onGenerateRoute: (settings) {
|
onGenerateRoute: (settings) {
|
||||||
if (settings.name == '/settings') {
|
if (settings.name == '/settings') {
|
||||||
// final args = settings.arguments as ScreenArguments;
|
final mountConfig = settings.arguments as MountConfig;
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return MountSettingsWidget(title: constants.appTitle);
|
return MountSettingsWidget(
|
||||||
|
title:
|
||||||
|
'${initialCaps(mountConfig.type)} [${formatMountName(mountConfig.type, mountConfig.name)}] Settings',
|
||||||
|
config: mountConfig,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,82 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:repertory/types/mount_config.dart';
|
||||||
import 'package:settings_ui/settings_ui.dart';
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
|
|
||||||
class MountSettingsWidget extends StatelessWidget {
|
class MountSettingsWidget extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
const MountSettingsWidget({super.key, required this.title});
|
final MountConfig config;
|
||||||
|
const MountSettingsWidget({
|
||||||
|
super.key,
|
||||||
|
required this.config,
|
||||||
|
required this.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MountSettingsWidget> createState() => _MountSettingsWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
||||||
|
MountConfig? config;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
List<SettingsTile> commonSettings = [];
|
||||||
|
config?.settings.forEach((key, value) {
|
||||||
|
if (key == "ApiAuth") {
|
||||||
|
commonSettings.add(
|
||||||
|
SettingsTile.navigation(
|
||||||
|
leading: Icon(Icons.password),
|
||||||
|
title: Text(key),
|
||||||
|
value: Text('*' * (value as String).length),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (key == "ApiPort") {
|
||||||
|
commonSettings.add(
|
||||||
|
SettingsTile.navigation(
|
||||||
|
leading: Icon(Icons.onetwothree),
|
||||||
|
title: Text(key),
|
||||||
|
value: Text((value as int).toString()),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (key == "ApiUser") {
|
||||||
|
commonSettings.add(
|
||||||
|
SettingsTile.navigation(
|
||||||
|
leading: Icon(Icons.person),
|
||||||
|
title: Text(key),
|
||||||
|
value: Text(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (key == "DatabaseType") {
|
||||||
|
commonSettings.add(
|
||||||
|
SettingsTile.navigation(
|
||||||
|
leading: Icon(Icons.dataset),
|
||||||
|
title: Text(key),
|
||||||
|
value: Text(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
title: Text(title),
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: SettingsList(
|
body: SettingsList(
|
||||||
shrinkWrap: false,
|
shrinkWrap: false,
|
||||||
sections: [
|
sections: [
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: Text('Common'),
|
title: Text('Common Settings'),
|
||||||
tiles: <SettingsTile>[
|
tiles: commonSettings.toList(),
|
||||||
SettingsTile.navigation(
|
|
||||||
leading: Icon(Icons.language),
|
|
||||||
title: Text('Language'),
|
|
||||||
value: Text('English'),
|
|
||||||
),
|
|
||||||
SettingsTile.switchTile(
|
|
||||||
onToggle: (value) {},
|
|
||||||
initialValue: true,
|
|
||||||
leading: Icon(Icons.format_paint),
|
|
||||||
title: Text('Enable custom theme'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
config = widget.config;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,11 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(Icons.settings, color: textColor),
|
icon: Icon(Icons.settings, color: textColor),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, '/settings');
|
Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
'/settings',
|
||||||
|
arguments: mount.mountConfig,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
subtitle:
|
subtitle:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user