mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Cleanup settings page(s)
- New separate directory - Separate view for About information
This commit is contained in:
parent
31fc5cb80b
commit
4b33f9c65c
@ -14,7 +14,7 @@ import 'barcode.dart';
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'settings.dart';
|
import 'settings/settings.dart';
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
import 'preferences.dart';
|
import 'preferences.dart';
|
||||||
|
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
|
||||||
import 'login_settings.dart';
|
|
||||||
|
|
||||||
import 'package:package_info/package_info.dart';
|
|
||||||
|
|
||||||
class InvenTreeSettingsWidget extends StatefulWidget {
|
|
||||||
// InvenTree settings view
|
|
||||||
|
|
||||||
@override
|
|
||||||
_InvenTreeSettingsState createState() => _InvenTreeSettingsState();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text("InvenTree Settings"),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
ListTile(
|
|
||||||
title: Text("Server Settings"),
|
|
||||||
subtitle: Text("Configure server and login settings"),
|
|
||||||
onTap: _editServerSettings,
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text("About"),
|
|
||||||
subtitle: Text("App details"),
|
|
||||||
onTap: _about,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _editServerSettings() async {
|
|
||||||
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget(prefs)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _about() async {
|
|
||||||
|
|
||||||
PackageInfo.fromPlatform().then((PackageInfo info) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
child: new SimpleDialog(
|
|
||||||
title: new Text("About InvenTree"),
|
|
||||||
children: <Widget>[
|
|
||||||
ListTile(
|
|
||||||
title: Text("Server Version"),
|
|
||||||
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : "Not connected"),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Server Instance"),
|
|
||||||
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : "Not connected"),
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text("App Name"),
|
|
||||||
subtitle: Text("${info.appName}"),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Package Name"),
|
|
||||||
subtitle: Text("${info.packageName}"),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text("App Version"),
|
|
||||||
subtitle: Text("${info.version}"),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Build Number"),
|
|
||||||
subtitle: Text("${info.buildNumber}")
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Submit Bug Report"),
|
|
||||||
subtitle: Text("Submit a bug report or feature request at:\n https://github.com/inventree/inventree-app/issues/"),
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
64
lib/settings/about.dart
Normal file
64
lib/settings/about.dart
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import 'package:InvenTree/api.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
|
class InvenTreeAboutWidget extends StatelessWidget {
|
||||||
|
|
||||||
|
final PackageInfo info;
|
||||||
|
|
||||||
|
InvenTreeAboutWidget(this.info) : super();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text("About InvenTree"),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
title: Text("Server Address"),
|
||||||
|
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : "Not connected"),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Server Version"),
|
||||||
|
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : "Not connected"),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Server Instance"),
|
||||||
|
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : "Not connected"),
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text("App Name"),
|
||||||
|
subtitle: Text("${info.appName}"),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Package Name"),
|
||||||
|
subtitle: Text("${info.packageName}"),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("App Version"),
|
||||||
|
subtitle: Text("${info.version}"),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Build Number"),
|
||||||
|
subtitle: Text("${info.buildNumber}")
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text("Submit Bug Report"),
|
||||||
|
subtitle: Text("https://github.com/inventree/inventree-app/issues/"),
|
||||||
|
onTap: () {
|
||||||
|
// TODO - Open the URL in an external webpage?
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import 'api.dart';
|
import '../api.dart';
|
||||||
import 'preferences.dart';
|
import '../preferences.dart';
|
||||||
|
|
||||||
class InvenTreeLoginSettingsWidget extends StatefulWidget {
|
class InvenTreeLoginSettingsWidget extends StatefulWidget {
|
||||||
|
|
||||||
@ -81,7 +81,6 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
initialValue: _server,
|
initialValue: _server,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: "127.0.0.1:8000",
|
hintText: "127.0.0.1:8000",
|
||||||
labelText: "Server:Port",
|
|
||||||
),
|
),
|
||||||
validator: _validateServer,
|
validator: _validateServer,
|
||||||
onSaved: (String value) {
|
onSaved: (String value) {
|
||||||
@ -89,7 +88,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
Text("Login Details"),
|
Text("Account Details"),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
initialValue: _username,
|
initialValue: _username,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
62
lib/settings/settings.dart
Normal file
62
lib/settings/settings.dart
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import 'package:InvenTree/settings/about.dart';
|
||||||
|
import 'package:InvenTree/settings/login.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'package:InvenTree/api.dart';
|
||||||
|
import 'login.dart';
|
||||||
|
|
||||||
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
|
class InvenTreeSettingsWidget extends StatefulWidget {
|
||||||
|
// InvenTree settings view
|
||||||
|
|
||||||
|
@override
|
||||||
|
_InvenTreeSettingsState createState() => _InvenTreeSettingsState();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text("InvenTree Settings"),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
title: Text("Server Settings"),
|
||||||
|
subtitle: Text("Configure server and login settings"),
|
||||||
|
onTap: _editServerSettings,
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
ListTile(
|
||||||
|
title: Text("About"),
|
||||||
|
subtitle: Text("App details"),
|
||||||
|
onTap: _about,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _editServerSettings() async {
|
||||||
|
|
||||||
|
var prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget(prefs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _about() async {
|
||||||
|
|
||||||
|
PackageInfo.fromPlatform().then((PackageInfo info) {
|
||||||
|
Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ import 'package:InvenTree/api.dart';
|
|||||||
import 'package:InvenTree/widget/category_display.dart';
|
import 'package:InvenTree/widget/category_display.dart';
|
||||||
import 'package:InvenTree/widget/location_display.dart';
|
import 'package:InvenTree/widget/location_display.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/settings.dart';
|
import 'package:InvenTree/settings/settings.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
class InvenTreeDrawer extends StatelessWidget {
|
class InvenTreeDrawer extends StatelessWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user