mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-04 00:08:53 +00:00
Merge pull request #83 from SchrodingersGat/settings
Reorganize settings:
This commit is contained in:
commit
8e5021cef9
@ -19,6 +19,7 @@ const String INV_PART_SUBCATEGORY = "partSubcategory";
|
|||||||
|
|
||||||
const String INV_STOCK_SUBLOCATION = "stockSublocation";
|
const String INV_STOCK_SUBLOCATION = "stockSublocation";
|
||||||
|
|
||||||
|
const String INV_REPORT_ERRORS = "reportErrors";
|
||||||
|
|
||||||
class InvenTreeSettingsManager {
|
class InvenTreeSettingsManager {
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import "dart:io";
|
import "dart:io";
|
||||||
|
|
||||||
import "package:device_info_plus/device_info_plus.dart";
|
import "package:device_info_plus/device_info_plus.dart";
|
||||||
|
import "package:inventree/app_settings.dart";
|
||||||
import "package:package_info_plus/package_info_plus.dart";
|
import "package:package_info_plus/package_info_plus.dart";
|
||||||
import "package:sentry_flutter/sentry_flutter.dart";
|
import "package:sentry_flutter/sentry_flutter.dart";
|
||||||
|
|
||||||
@ -94,6 +95,13 @@ Future<bool> sentryReportMessage(String message, {Map<String, String>? context})
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final upload = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||||
|
|
||||||
|
if (!upload) {
|
||||||
|
print("----- Error reporting disabled -----");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Sentry.configureScope((scope) {
|
Sentry.configureScope((scope) {
|
||||||
scope.setExtra("server", server_info);
|
scope.setExtra("server", server_info);
|
||||||
scope.setExtra("app", app_info);
|
scope.setExtra("app", app_info);
|
||||||
@ -129,6 +137,13 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final upload = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||||
|
|
||||||
|
if (!upload) {
|
||||||
|
print("----- Error reporting disabled -----");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final server_info = getServerInfo();
|
final server_info = getServerInfo();
|
||||||
final app_info = await getAppInfo();
|
final app_info = await getAppInfo();
|
||||||
final device_info = await getDeviceInfo();
|
final device_info = await getDeviceInfo();
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit e49ca8618d79e734c054beaa289798c968fa6a5c
|
Subproject commit 1ba291fe1f5c7109a4817bb6cd5caac26c0a9d82
|
@ -9,6 +9,7 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
|||||||
import "package:package_info_plus/package_info_plus.dart";
|
import "package:package_info_plus/package_info_plus.dart";
|
||||||
|
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
import "package:url_launcher/url_launcher.dart";
|
||||||
|
|
||||||
class InvenTreeAboutWidget extends StatelessWidget {
|
class InvenTreeAboutWidget extends StatelessWidget {
|
||||||
|
|
||||||
@ -37,6 +38,32 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future <void> _openDocs() async {
|
||||||
|
|
||||||
|
const String docsUrl = "https://inventree.readthedocs.io/en/latest/app/app/";
|
||||||
|
|
||||||
|
if (await canLaunch(docsUrl)) {
|
||||||
|
await launch(docsUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future <void> _reportBug(BuildContext context) async {
|
||||||
|
|
||||||
|
const String url = "https://github.com/inventree/InvenTree/issues/new?assignees=&labels=app%2C+bug&title=%5BApp%5D+Enter+bug+description";
|
||||||
|
|
||||||
|
if (await canLaunch(url)) {
|
||||||
|
await launch(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future <void> _translate() async {
|
||||||
|
const String url = "https://crowdin.com/project/inventree";
|
||||||
|
|
||||||
|
if (await canLaunch(url)) {
|
||||||
|
await launch(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
@ -135,6 +162,39 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().documentation),
|
||||||
|
subtitle: Text("https://inventree.readthedocs.io"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.book, color: COLOR_CLICK),
|
||||||
|
onTap: () {
|
||||||
|
_openDocs();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().translate),
|
||||||
|
subtitle: Text(L10().translateHelp),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.language, color: COLOR_CLICK),
|
||||||
|
onTap: () {
|
||||||
|
_translate();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().reportBug),
|
||||||
|
subtitle: Text(L10().reportBugDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.bug, color: COLOR_CLICK),
|
||||||
|
onTap: () {
|
||||||
|
_reportBug(context);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10().appAbout),
|
title: Text(L10().appAbout),
|
||||||
|
@ -19,13 +19,6 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
|
|
||||||
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>();
|
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>();
|
||||||
|
|
||||||
// Home screen settings
|
|
||||||
bool homeShowSubscribed = true;
|
|
||||||
bool homeShowPo = true;
|
|
||||||
bool homeShowSuppliers = true;
|
|
||||||
bool homeShowManufacturers = true;
|
|
||||||
bool homeShowCustomers = true;
|
|
||||||
|
|
||||||
// Sound settings
|
// Sound settings
|
||||||
bool barcodeSounds = true;
|
bool barcodeSounds = true;
|
||||||
bool serverSounds = true;
|
bool serverSounds = true;
|
||||||
@ -36,6 +29,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
// Stock settings
|
// Stock settings
|
||||||
bool stockSublocation = false;
|
bool stockSublocation = false;
|
||||||
|
|
||||||
|
bool reportErrors = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -47,12 +42,6 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
|
|
||||||
// Load initial settings
|
// Load initial settings
|
||||||
|
|
||||||
homeShowSubscribed = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUBSCRIBED, true) as bool;
|
|
||||||
homeShowPo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_PO, true) as bool;
|
|
||||||
homeShowManufacturers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_MANUFACTURERS, true) as bool;
|
|
||||||
homeShowCustomers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_CUSTOMERS, true) as bool;
|
|
||||||
homeShowSuppliers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUPPLIERS, true) as bool;
|
|
||||||
|
|
||||||
barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool;
|
barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool;
|
||||||
serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||||
|
|
||||||
@ -60,6 +49,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
|
|
||||||
stockSublocation = await InvenTreeSettingsManager().getValue(INV_STOCK_SUBLOCATION, true) as bool;
|
stockSublocation = await InvenTreeSettingsManager().getValue(INV_STOCK_SUBLOCATION, true) as bool;
|
||||||
|
|
||||||
|
reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,90 +66,12 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
body: Container(
|
body: Container(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
/* Home Screen Settings */
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
L10().homeScreen,
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().homeShowSubscribed),
|
|
||||||
subtitle: Text(L10().homeShowSubscribedDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.bell),
|
|
||||||
trailing: Switch(
|
|
||||||
value: homeShowSubscribed,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUBSCRIBED, value);
|
|
||||||
setState(() {
|
|
||||||
homeShowSubscribed = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().homeShowPo),
|
|
||||||
subtitle: Text(L10().homeShowPoDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
|
||||||
trailing: Switch(
|
|
||||||
value: homeShowPo,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_PO, value);
|
|
||||||
setState(() {
|
|
||||||
homeShowPo = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().homeShowSuppliers),
|
|
||||||
subtitle: Text(L10().homeShowSuppliersDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.building),
|
|
||||||
trailing: Switch(
|
|
||||||
value: homeShowSuppliers,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUPPLIERS, value);
|
|
||||||
setState(() {
|
|
||||||
homeShowSuppliers = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().homeShowManufacturers),
|
|
||||||
subtitle: Text(L10().homeShowManufacturersDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.industry),
|
|
||||||
trailing: Switch(
|
|
||||||
value: homeShowManufacturers,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_MANUFACTURERS, value);
|
|
||||||
setState(() {
|
|
||||||
homeShowManufacturers = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().homeShowCustomers),
|
|
||||||
subtitle: Text(L10().homeShowCustomersDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.userTie),
|
|
||||||
trailing: Switch(
|
|
||||||
value: homeShowCustomers,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_CUSTOMERS, value);
|
|
||||||
setState(() {
|
|
||||||
homeShowCustomers = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
/* Part Settings */
|
|
||||||
Divider(height: 3),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
L10().parts,
|
L10().parts,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().includeSubcategories),
|
title: Text(L10().includeSubcategories),
|
||||||
@ -180,6 +93,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
title: Text(L10().stock,
|
title: Text(L10().stock,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.boxes),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().includeSublocations),
|
title: Text(L10().includeSublocations),
|
||||||
@ -233,6 +147,27 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(height: 1),
|
Divider(height: 1),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
L10().errorReporting,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.bug),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().errorReportUpload),
|
||||||
|
subtitle: Text(L10().errorReportUploadDetails),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.cloudUploadAlt),
|
||||||
|
trailing: Switch(
|
||||||
|
value: reportErrors,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_REPORT_ERRORS, value);
|
||||||
|
setState(() {
|
||||||
|
reportErrors = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
136
lib/settings/home_settings.dart
Normal file
136
lib/settings/home_settings.dart
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
|
||||||
|
import "package:flutter/material.dart";
|
||||||
|
import "package:flutter/cupertino.dart";
|
||||||
|
|
||||||
|
import "package:inventree/l10.dart";
|
||||||
|
|
||||||
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||||
|
|
||||||
|
import "package:inventree/app_settings.dart";
|
||||||
|
|
||||||
|
class HomeScreenSettingsWidget extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_HomeScreenSettingsState createState() => _HomeScreenSettingsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeScreenSettingsState extends State<HomeScreenSettingsWidget> {
|
||||||
|
|
||||||
|
_HomeScreenSettingsState();
|
||||||
|
|
||||||
|
final GlobalKey<_HomeScreenSettingsState> _settingsKey = GlobalKey<_HomeScreenSettingsState>();
|
||||||
|
|
||||||
|
// Home screen settings
|
||||||
|
bool homeShowSubscribed = true;
|
||||||
|
bool homeShowPo = true;
|
||||||
|
bool homeShowSuppliers = true;
|
||||||
|
bool homeShowManufacturers = true;
|
||||||
|
bool homeShowCustomers = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future <void> loadSettings() async {
|
||||||
|
|
||||||
|
// Load initial settings
|
||||||
|
|
||||||
|
homeShowSubscribed = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUBSCRIBED, true) as bool;
|
||||||
|
homeShowPo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_PO, true) as bool;
|
||||||
|
homeShowManufacturers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_MANUFACTURERS, true) as bool;
|
||||||
|
homeShowCustomers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_CUSTOMERS, true) as bool;
|
||||||
|
homeShowSuppliers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUPPLIERS, true) as bool;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
key: _settingsKey,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(L10().homeScreen),
|
||||||
|
),
|
||||||
|
body: Container(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeShowSubscribed),
|
||||||
|
subtitle: Text(L10().homeShowSubscribedDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.bell),
|
||||||
|
trailing: Switch(
|
||||||
|
value: homeShowSubscribed,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUBSCRIBED, value);
|
||||||
|
setState(() {
|
||||||
|
homeShowSubscribed = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeShowPo),
|
||||||
|
subtitle: Text(L10().homeShowPoDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
||||||
|
trailing: Switch(
|
||||||
|
value: homeShowPo,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_PO, value);
|
||||||
|
setState(() {
|
||||||
|
homeShowPo = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeShowSuppliers),
|
||||||
|
subtitle: Text(L10().homeShowSuppliersDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.building),
|
||||||
|
trailing: Switch(
|
||||||
|
value: homeShowSuppliers,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUPPLIERS, value);
|
||||||
|
setState(() {
|
||||||
|
homeShowSuppliers = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeShowManufacturers),
|
||||||
|
subtitle: Text(L10().homeShowManufacturersDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.industry),
|
||||||
|
trailing: Switch(
|
||||||
|
value: homeShowManufacturers,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_MANUFACTURERS, value);
|
||||||
|
setState(() {
|
||||||
|
homeShowManufacturers = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeShowCustomers),
|
||||||
|
subtitle: Text(L10().homeShowCustomersDescription),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.userTie),
|
||||||
|
trailing: Switch(
|
||||||
|
value: homeShowCustomers,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_CUSTOMERS, value);
|
||||||
|
setState(() {
|
||||||
|
homeShowCustomers = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,12 @@
|
|||||||
import "package:inventree/app_colors.dart";
|
import "package:inventree/app_colors.dart";
|
||||||
import "package:inventree/settings/about.dart";
|
|
||||||
import "package:inventree/settings/app_settings.dart";
|
import "package:inventree/settings/app_settings.dart";
|
||||||
|
import "package:inventree/settings/home_settings.dart";
|
||||||
import "package:inventree/settings/login.dart";
|
import "package:inventree/settings/login.dart";
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
|
||||||
import "package:url_launcher/url_launcher.dart";
|
|
||||||
|
|
||||||
import "package:package_info_plus/package_info_plus.dart";
|
|
||||||
|
|
||||||
class InvenTreeSettingsWidget extends StatefulWidget {
|
class InvenTreeSettingsWidget extends StatefulWidget {
|
||||||
// InvenTree settings view
|
// InvenTree settings view
|
||||||
@ -24,8 +21,6 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|||||||
|
|
||||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
final String docsUrl = "https://inventree.readthedocs.io/en/latest/app/app/";
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -44,46 +39,18 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|||||||
leading: FaIcon(FontAwesomeIcons.server, color: COLOR_CLICK),
|
leading: FaIcon(FontAwesomeIcons.server, color: COLOR_CLICK),
|
||||||
onTap: _editServerSettings,
|
onTap: _editServerSettings,
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().homeScreen),
|
||||||
|
subtitle: Text(L10().homeScreenSettings),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.home, color: COLOR_CLICK),
|
||||||
|
onTap: _editHomeScreenSettings,
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().appSettings),
|
title: Text(L10().appSettings),
|
||||||
subtitle: Text(L10().appSettingsDetails),
|
subtitle: Text(L10().appSettingsDetails),
|
||||||
leading: FaIcon(FontAwesomeIcons.cogs, color: COLOR_CLICK),
|
leading: FaIcon(FontAwesomeIcons.cogs, color: COLOR_CLICK),
|
||||||
onTap: _editAppSettings,
|
onTap: _editAppSettings,
|
||||||
),
|
),
|
||||||
ListTile(
|
|
||||||
title: Text(L10().about),
|
|
||||||
subtitle: Text(L10().appDetails),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.infoCircle, color: COLOR_CLICK),
|
|
||||||
onTap: _about,
|
|
||||||
),
|
|
||||||
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().documentation),
|
|
||||||
subtitle: Text("https://inventree.readthedocs.io"),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.book, color: COLOR_CLICK),
|
|
||||||
onTap: () {
|
|
||||||
_openDocs();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().translate),
|
|
||||||
subtitle: Text(L10().translateHelp),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.language, color: COLOR_CLICK),
|
|
||||||
onTap: () {
|
|
||||||
_translate();
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
ListTile(
|
|
||||||
title: Text(L10().reportBug),
|
|
||||||
subtitle: Text(L10().reportBugDescription),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.bug, color: COLOR_CLICK),
|
|
||||||
onTap: () {
|
|
||||||
_reportBug(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
]
|
]
|
||||||
).toList()
|
).toList()
|
||||||
)
|
)
|
||||||
@ -91,45 +58,17 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future <void> _openDocs() async {
|
|
||||||
if (await canLaunch(docsUrl)) {
|
|
||||||
await launch(docsUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future <void> _translate() async {
|
|
||||||
const String url = "https://crowdin.com/project/inventree";
|
|
||||||
|
|
||||||
if (await canLaunch(url)) {
|
|
||||||
await launch(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future <void> _editServerSettings() async {
|
Future <void> _editServerSettings() async {
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _editHomeScreenSettings() async {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreenSettingsWidget()));
|
||||||
|
}
|
||||||
|
|
||||||
Future <void> _editAppSettings() async {
|
Future <void> _editAppSettings() async {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future <void> _about() async {
|
|
||||||
|
|
||||||
PackageInfo.fromPlatform().then((PackageInfo info) {
|
|
||||||
Navigator.push(context,
|
|
||||||
MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future <void> _reportBug(BuildContext context) async {
|
|
||||||
|
|
||||||
const String url = "https://github.com/inventree/InvenTree/issues/new?assignees=&labels=app%2C+bug&title=%5BApp%5D+Enter+bug+description";
|
|
||||||
|
|
||||||
if (await canLaunch(url)) {
|
|
||||||
await launch(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,10 +2,12 @@ import "package:inventree/api.dart";
|
|||||||
import "package:inventree/barcode.dart";
|
import "package:inventree/barcode.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
import "package:inventree/settings/about.dart";
|
||||||
|
|
||||||
import "package:inventree/settings/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";
|
||||||
import "package:inventree/widget/search.dart";
|
import "package:inventree/widget/search.dart";
|
||||||
|
import "package:package_info_plus/package_info_plus.dart";
|
||||||
|
|
||||||
class InvenTreeDrawer extends StatelessWidget {
|
class InvenTreeDrawer extends StatelessWidget {
|
||||||
|
|
||||||
@ -63,6 +65,18 @@ class InvenTreeDrawer extends StatelessWidget {
|
|||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSettingsWidget()));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSettingsWidget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load "About" widget
|
||||||
|
*/
|
||||||
|
Future<void> _about() async {
|
||||||
|
_closeDrawer();
|
||||||
|
|
||||||
|
PackageInfo.fromPlatform().then((PackageInfo info) {
|
||||||
|
Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
@ -94,6 +108,11 @@ class InvenTreeDrawer extends StatelessWidget {
|
|||||||
leading: Icon(Icons.settings),
|
leading: Icon(Icons.settings),
|
||||||
onTap: _settings,
|
onTap: _settings,
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().about),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.infoCircle),
|
||||||
|
onTap: _about,
|
||||||
|
)
|
||||||
]
|
]
|
||||||
).toList(),
|
).toList(),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user