mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-01 19:30:44 +00:00
Format Code and Add Format Checks to CI (#643)
* Remove unused lib/generated/i18n.dart * Use `fvm dart format .` * Add contributing guidelines * Enforce dart format * Add `dart format off` directive to generated files
This commit is contained in:
@ -13,34 +13,30 @@ import "package:url_launcher/url_launcher.dart";
|
||||
const String DOCS_URL = "https://docs.inventree.org/app";
|
||||
|
||||
class InvenTreeAboutWidget extends StatelessWidget {
|
||||
|
||||
const InvenTreeAboutWidget(this.info) : super();
|
||||
|
||||
final PackageInfo info;
|
||||
|
||||
Future <void> _releaseNotes(BuildContext context) async {
|
||||
|
||||
Future<void> _releaseNotes(BuildContext context) async {
|
||||
// Load release notes from external file
|
||||
String notes = await rootBundle.loadString("assets/release_notes.md");
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ReleaseNotesWidget(notes))
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ReleaseNotesWidget(notes)),
|
||||
);
|
||||
}
|
||||
|
||||
Future <void> _credits(BuildContext context) async {
|
||||
|
||||
Future<void> _credits(BuildContext context) async {
|
||||
String notes = await rootBundle.loadString("assets/credits.md");
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => CreditsWidget(notes))
|
||||
MaterialPageRoute(builder: (context) => CreditsWidget(notes)),
|
||||
);
|
||||
}
|
||||
|
||||
Future <void> _openDocs() async {
|
||||
|
||||
Future<void> _openDocs() async {
|
||||
var docsUrl = Uri.parse(DOCS_URL);
|
||||
|
||||
if (await canLaunchUrl(docsUrl)) {
|
||||
@ -48,23 +44,24 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Future <void> _reportBug(BuildContext context) async {
|
||||
|
||||
Future<void> _reportBug(BuildContext context) async {
|
||||
var url = Uri(
|
||||
scheme: "https",
|
||||
host: "github.com",
|
||||
path: "inventree/inventree-app/issues/new?title=Enter+bug+description");
|
||||
scheme: "https",
|
||||
host: "github.com",
|
||||
path: "inventree/inventree-app/issues/new?title=Enter+bug+description",
|
||||
);
|
||||
|
||||
if (await canLaunchUrl(url)) {
|
||||
await launchUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
Future <void> _translate() async {
|
||||
Future<void> _translate() async {
|
||||
var url = Uri(
|
||||
scheme: "https",
|
||||
host: "crowdin.com",
|
||||
path: "/project/inventree");
|
||||
scheme: "https",
|
||||
host: "crowdin.com",
|
||||
path: "/project/inventree",
|
||||
);
|
||||
|
||||
if (await canLaunchUrl(url)) {
|
||||
await launchUrl(url);
|
||||
@ -73,7 +70,6 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
@ -82,41 +78,57 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
L10().serverDetails,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
if (InvenTreeAPI().isConnected()) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().address),
|
||||
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : L10().notConnected),
|
||||
leading: Icon(TablerIcons.globe),
|
||||
trailing: InvenTreeAPI().isConnected() ? Icon(TablerIcons.circle_check, color: COLOR_SUCCESS) : Icon(TablerIcons.circle_x, color: COLOR_DANGER),
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().address),
|
||||
subtitle: Text(
|
||||
InvenTreeAPI().baseUrl.isNotEmpty
|
||||
? InvenTreeAPI().baseUrl
|
||||
: L10().notConnected,
|
||||
),
|
||||
leading: Icon(TablerIcons.globe),
|
||||
trailing: InvenTreeAPI().isConnected()
|
||||
? Icon(TablerIcons.circle_check, color: COLOR_SUCCESS)
|
||||
: Icon(TablerIcons.circle_x, color: COLOR_DANGER),
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().username),
|
||||
subtitle: Text(InvenTreeAPI().username),
|
||||
leading: InvenTreeAPI().username.isNotEmpty ? Icon(TablerIcons.user) : Icon(TablerIcons.user_cancel, color: COLOR_DANGER),
|
||||
)
|
||||
leading: InvenTreeAPI().username.isNotEmpty
|
||||
? Icon(TablerIcons.user)
|
||||
: Icon(TablerIcons.user_cancel, color: COLOR_DANGER),
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().version),
|
||||
subtitle: Text(InvenTreeAPI().serverVersion.isNotEmpty ? InvenTreeAPI().serverVersion : L10().notConnected),
|
||||
subtitle: Text(
|
||||
InvenTreeAPI().serverVersion.isNotEmpty
|
||||
? InvenTreeAPI().serverVersion
|
||||
: L10().notConnected,
|
||||
),
|
||||
leading: Icon(TablerIcons.info_circle),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().serverInstance),
|
||||
subtitle: Text(InvenTreeAPI().serverInstance.isNotEmpty ? InvenTreeAPI().serverInstance : L10().notConnected),
|
||||
subtitle: Text(
|
||||
InvenTreeAPI().serverInstance.isNotEmpty
|
||||
? InvenTreeAPI().serverInstance
|
||||
: L10().notConnected,
|
||||
),
|
||||
leading: Icon(TablerIcons.server),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
// Display extra tile if the server supports plugins
|
||||
@ -125,9 +137,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
title: Text(L10().pluginSupport),
|
||||
subtitle: Text(L10().pluginSupportDetail),
|
||||
leading: Icon(TablerIcons.plug),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
@ -136,8 +147,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
L10().serverNotConnected,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
leading: Icon(TablerIcons.exclamation_circle)
|
||||
)
|
||||
leading: Icon(TablerIcons.exclamation_circle),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -147,23 +158,23 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
L10().appDetails,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().packageName),
|
||||
subtitle: Text("${info.packageName}"),
|
||||
leading: Icon(TablerIcons.box)
|
||||
)
|
||||
leading: Icon(TablerIcons.box),
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().version),
|
||||
subtitle: Text("${info.version} - Build ${info.buildNumber}"),
|
||||
leading: Icon(TablerIcons.info_circle)
|
||||
)
|
||||
leading: Icon(TablerIcons.info_circle),
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
@ -174,7 +185,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
_releaseNotes(context);
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
@ -184,8 +195,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
leading: Icon(TablerIcons.balloon, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
_credits(context);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
@ -196,7 +207,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
_openDocs();
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
@ -206,8 +217,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
leading: Icon(TablerIcons.language, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
_translate();
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
@ -216,9 +227,9 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
subtitle: Text(L10().reportBugDescription),
|
||||
leading: Icon(TablerIcons.bug, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
_reportBug(context);
|
||||
_reportBug(context);
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
@ -227,11 +238,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: ListView(
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: tiles,
|
||||
).toList(),
|
||||
)
|
||||
children: ListTile.divideTiles(context: context, tiles: tiles).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,16 @@ import "package:inventree/preferences.dart";
|
||||
import "package:inventree/widget/dialogs.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
|
||||
|
||||
class InvenTreeAppSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreeAppSettingsState createState() => _InvenTreeAppSettingsState();
|
||||
}
|
||||
|
||||
class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
|
||||
_InvenTreeAppSettingsState();
|
||||
|
||||
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>();
|
||||
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey =
|
||||
GlobalKey<_InvenTreeAppSettingsState>();
|
||||
|
||||
// Sound settings
|
||||
bool barcodeSounds = true;
|
||||
@ -48,16 +47,33 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
loadSettings(OneContext().context!);
|
||||
}
|
||||
|
||||
Future <void> loadSettings(BuildContext context) async {
|
||||
|
||||
Future<void> loadSettings(BuildContext context) async {
|
||||
showLoadingOverlay();
|
||||
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool;
|
||||
serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||
reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||
strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool;
|
||||
screenOrientation = await InvenTreeSettingsManager().getValue(INV_SCREEN_ORIENTATION, SCREEN_ORIENTATION_SYSTEM) as int;
|
||||
enableLabelPrinting = await InvenTreeSettingsManager().getValue(INV_ENABLE_LABEL_PRINTING, true) as bool;
|
||||
barcodeSounds =
|
||||
await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true)
|
||||
as bool;
|
||||
serverSounds =
|
||||
await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true)
|
||||
as bool;
|
||||
reportErrors =
|
||||
await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true)
|
||||
as bool;
|
||||
strictHttps =
|
||||
await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false)
|
||||
as bool;
|
||||
screenOrientation =
|
||||
await InvenTreeSettingsManager().getValue(
|
||||
INV_SCREEN_ORIENTATION,
|
||||
SCREEN_ORIENTATION_SYSTEM,
|
||||
)
|
||||
as int;
|
||||
enableLabelPrinting =
|
||||
await InvenTreeSettingsManager().getValue(
|
||||
INV_ENABLE_LABEL_PRINTING,
|
||||
true,
|
||||
)
|
||||
as bool;
|
||||
|
||||
darkMode = AdaptiveTheme.of(context).mode.isDark;
|
||||
|
||||
@ -71,19 +87,15 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
}
|
||||
|
||||
Future<void> _selectLocale(BuildContext context) async {
|
||||
|
||||
List<Map<String, dynamic>> options = [
|
||||
{
|
||||
"display_name": L10().languageDefault,
|
||||
"value": null,
|
||||
}
|
||||
{"display_name": L10().languageDefault, "value": null},
|
||||
];
|
||||
|
||||
// Construct a list of available locales
|
||||
for (var locale in supported_locales) {
|
||||
options.add({
|
||||
"display_name": LocaleNames.of(context)!.nameOf(locale.toString()),
|
||||
"value": locale.toString()
|
||||
"value": locale.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -93,7 +105,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
"type": "choice",
|
||||
"choices": options,
|
||||
"value": locale?.toString(),
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
@ -103,7 +115,6 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
fields,
|
||||
icon: TablerIcons.circle_check,
|
||||
onSuccess: (Map<String, dynamic> data) async {
|
||||
|
||||
String locale_name = (data["locale"] ?? "") as String;
|
||||
Locale? selected_locale;
|
||||
|
||||
@ -124,18 +135,18 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
|
||||
// Clear the cached status label information
|
||||
InvenTreeAPI().clearStatusCodeData();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
String languageName = L10().languageDefault;
|
||||
|
||||
if (locale != null) {
|
||||
languageName = LocaleNames.of(context)!.nameOf(locale.toString()) ?? L10().languageDefault;
|
||||
languageName =
|
||||
LocaleNames.of(context)!.nameOf(locale.toString()) ??
|
||||
L10().languageDefault;
|
||||
}
|
||||
|
||||
IconData orientationIcon = Icons.screen_rotation;
|
||||
@ -154,7 +165,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
key: _settingsKey,
|
||||
appBar: AppBar(
|
||||
title: Text(L10().appSettings),
|
||||
backgroundColor: COLOR_APP_BAR
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
@ -183,8 +194,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
setState(() {
|
||||
darkMode = value;
|
||||
});
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: ListTile(
|
||||
@ -198,26 +209,43 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
L10().orientation,
|
||||
[
|
||||
ListTile(
|
||||
leading: Icon(Icons.screen_rotation, color: screenOrientation == SCREEN_ORIENTATION_SYSTEM ? COLOR_ACTION : null),
|
||||
leading: Icon(
|
||||
Icons.screen_rotation,
|
||||
color: screenOrientation == SCREEN_ORIENTATION_SYSTEM
|
||||
? COLOR_ACTION
|
||||
: null,
|
||||
),
|
||||
title: Text(L10().orientationSystem),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.screen_lock_portrait, color: screenOrientation == SCREEN_ORIENTATION_PORTRAIT ? COLOR_ACTION : null),
|
||||
leading: Icon(
|
||||
Icons.screen_lock_portrait,
|
||||
color: screenOrientation == SCREEN_ORIENTATION_PORTRAIT
|
||||
? COLOR_ACTION
|
||||
: null,
|
||||
),
|
||||
title: Text(L10().orientationPortrait),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.screen_lock_landscape, color: screenOrientation == SCREEN_ORIENTATION_LANDSCAPE ? COLOR_ACTION : null),
|
||||
leading: Icon(
|
||||
Icons.screen_lock_landscape,
|
||||
color: screenOrientation == SCREEN_ORIENTATION_LANDSCAPE
|
||||
? COLOR_ACTION
|
||||
: null,
|
||||
),
|
||||
title: Text(L10().orientationLandscape),
|
||||
)
|
||||
),
|
||||
],
|
||||
onSelected: (idx) async {
|
||||
screenOrientation = idx as int;
|
||||
|
||||
InvenTreeSettingsManager().setValue(INV_SCREEN_ORIENTATION, screenOrientation);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_SCREEN_ORIENTATION,
|
||||
screenOrientation,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -228,11 +256,14 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: enableLabelPrinting,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_ENABLE_LABEL_PRINTING, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_ENABLE_LABEL_PRINTING,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
enableLabelPrinting = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@ -271,7 +302,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().sounds,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
@ -300,7 +331,10 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: barcodeSounds,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SOUNDS_BARCODE, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_SOUNDS_BARCODE,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
barcodeSounds = value;
|
||||
});
|
||||
@ -308,9 +342,9 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,44 +7,52 @@ import "package:inventree/app_colors.dart";
|
||||
|
||||
import "package:inventree/widget/dialogs.dart";
|
||||
|
||||
|
||||
class InvenTreeBarcodeSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreeBarcodeSettingsState createState() => _InvenTreeBarcodeSettingsState();
|
||||
_InvenTreeBarcodeSettingsState createState() =>
|
||||
_InvenTreeBarcodeSettingsState();
|
||||
}
|
||||
|
||||
class _InvenTreeBarcodeSettingsState
|
||||
extends State<InvenTreeBarcodeSettingsWidget> {
|
||||
_InvenTreeBarcodeSettingsState();
|
||||
|
||||
class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidget> {
|
||||
int barcodeScanDelay = 500;
|
||||
int barcodeScanType = BARCODE_CONTROLLER_CAMERA;
|
||||
bool barcodeScanSingle = false;
|
||||
|
||||
_InvenTreeBarcodeSettingsState();
|
||||
final TextEditingController _barcodeScanDelayController =
|
||||
TextEditingController();
|
||||
|
||||
int barcodeScanDelay = 500;
|
||||
int barcodeScanType = BARCODE_CONTROLLER_CAMERA;
|
||||
bool barcodeScanSingle = false;
|
||||
|
||||
final TextEditingController _barcodeScanDelayController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loadSettings();
|
||||
}
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
barcodeScanDelay = await InvenTreeSettingsManager().getValue(INV_BARCODE_SCAN_DELAY, 500) as int;
|
||||
barcodeScanType = await InvenTreeSettingsManager().getValue(INV_BARCODE_SCAN_TYPE, BARCODE_CONTROLLER_CAMERA) as int;
|
||||
barcodeScanSingle = await InvenTreeSettingsManager().getBool(INV_BARCODE_SCAN_SINGLE, false);
|
||||
barcodeScanDelay =
|
||||
await InvenTreeSettingsManager().getValue(INV_BARCODE_SCAN_DELAY, 500)
|
||||
as int;
|
||||
barcodeScanType =
|
||||
await InvenTreeSettingsManager().getValue(
|
||||
INV_BARCODE_SCAN_TYPE,
|
||||
BARCODE_CONTROLLER_CAMERA,
|
||||
)
|
||||
as int;
|
||||
barcodeScanSingle = await InvenTreeSettingsManager().getBool(
|
||||
INV_BARCODE_SCAN_SINGLE,
|
||||
false,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
// Callback function to edit the barcode scan delay value
|
||||
// TODO: Next time any new settings are added, refactor this into a generic function
|
||||
Future<void> _editBarcodeScanDelay(BuildContext context) async {
|
||||
|
||||
_barcodeScanDelayController.text = barcodeScanDelay.toString();
|
||||
|
||||
return showDialog(
|
||||
@ -56,9 +64,7 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
onChanged: (value) {},
|
||||
controller: _barcodeScanDelayController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
hintText: L10().barcodeScanDelayDetail,
|
||||
),
|
||||
decoration: InputDecoration(hintText: L10().barcodeScanDelayDetail),
|
||||
),
|
||||
actions: <Widget>[
|
||||
MaterialButton(
|
||||
@ -76,13 +82,18 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
textColor: Colors.white,
|
||||
child: Text(L10().ok),
|
||||
onPressed: () async {
|
||||
int delay = int.tryParse(_barcodeScanDelayController.text) ?? barcodeScanDelay;
|
||||
int delay =
|
||||
int.tryParse(_barcodeScanDelayController.text) ??
|
||||
barcodeScanDelay;
|
||||
|
||||
// Apply limits
|
||||
if (delay < 100) delay = 100;
|
||||
if (delay > 2500) delay = 2500;
|
||||
|
||||
InvenTreeSettingsManager().setValue(INV_BARCODE_SCAN_DELAY, delay);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_BARCODE_SCAN_DELAY,
|
||||
delay,
|
||||
);
|
||||
setState(() {
|
||||
barcodeScanDelay = delay;
|
||||
Navigator.pop(context);
|
||||
@ -91,13 +102,12 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
// Construct an icon for the barcode scanner input
|
||||
Widget? barcodeInputIcon;
|
||||
|
||||
@ -112,7 +122,7 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().barcodeSettings),
|
||||
backgroundColor: COLOR_APP_BAR
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
@ -135,17 +145,20 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
title: Text(L10().scannerExternal),
|
||||
subtitle: Text(L10().scannerExternalDetail),
|
||||
leading: Icon(Icons.barcode_reader),
|
||||
)
|
||||
),
|
||||
],
|
||||
onSelected: (idx) async {
|
||||
barcodeScanType = idx as int;
|
||||
InvenTreeSettingsManager().setValue(INV_BARCODE_SCAN_TYPE, barcodeScanType);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_BARCODE_SCAN_TYPE,
|
||||
barcodeScanType,
|
||||
);
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().barcodeScanDelay),
|
||||
@ -165,17 +178,19 @@ class _InvenTreeBarcodeSettingsState extends State<InvenTreeBarcodeSettingsWidge
|
||||
trailing: Switch(
|
||||
value: barcodeScanSingle,
|
||||
onChanged: (bool v) {
|
||||
InvenTreeSettingsManager().setValue(INV_BARCODE_SCAN_SINGLE, v);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_BARCODE_SCAN_SINGLE,
|
||||
v,
|
||||
);
|
||||
setState(() {
|
||||
barcodeScanSingle = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
@ -12,10 +11,10 @@ class HomeScreenSettingsWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeScreenSettingsState extends State<HomeScreenSettingsWidget> {
|
||||
|
||||
_HomeScreenSettingsState();
|
||||
|
||||
final GlobalKey<_HomeScreenSettingsState> _settingsKey = GlobalKey<_HomeScreenSettingsState>();
|
||||
final GlobalKey<_HomeScreenSettingsState> _settingsKey =
|
||||
GlobalKey<_HomeScreenSettingsState>();
|
||||
|
||||
// Home screen settings
|
||||
bool homeShowSubscribed = true;
|
||||
@ -32,92 +31,113 @@ class _HomeScreenSettingsState extends State<HomeScreenSettingsWidget> {
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
Future <void> loadSettings() async {
|
||||
|
||||
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;
|
||||
homeShowSo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SO, 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;
|
||||
homeShowSubscribed =
|
||||
await InvenTreeSettingsManager().getValue(
|
||||
INV_HOME_SHOW_SUBSCRIBED,
|
||||
true,
|
||||
)
|
||||
as bool;
|
||||
homeShowPo =
|
||||
await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_PO, true)
|
||||
as bool;
|
||||
homeShowSo =
|
||||
await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SO, 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(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
key: _settingsKey,
|
||||
appBar: AppBar(
|
||||
title: Text(L10().homeScreen),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSubscribed),
|
||||
subtitle: Text(L10().homeShowSubscribedDescription),
|
||||
leading: Icon(TablerIcons.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: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: homeShowPo,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_PO, value);
|
||||
setState(() {
|
||||
homeShowPo = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSo),
|
||||
subtitle: Text(L10().homeShowSoDescription),
|
||||
leading: Icon(TablerIcons.truck),
|
||||
trailing: Switch(
|
||||
value: homeShowSo,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SO, value);
|
||||
setState(() {
|
||||
homeShowSo = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSuppliers),
|
||||
subtitle: Text(L10().homeShowSuppliersDescription),
|
||||
leading: Icon(TablerIcons.building),
|
||||
trailing: Switch(
|
||||
value: homeShowSuppliers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUPPLIERS, value);
|
||||
setState(() {
|
||||
homeShowSuppliers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
// TODO: When these features are improved, add them back in!
|
||||
// Currently, the company display does not provide any value
|
||||
/*
|
||||
key: _settingsKey,
|
||||
appBar: AppBar(
|
||||
title: Text(L10().homeScreen),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSubscribed),
|
||||
subtitle: Text(L10().homeShowSubscribedDescription),
|
||||
leading: Icon(TablerIcons.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: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: homeShowPo,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_PO, value);
|
||||
setState(() {
|
||||
homeShowPo = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSo),
|
||||
subtitle: Text(L10().homeShowSoDescription),
|
||||
leading: Icon(TablerIcons.truck),
|
||||
trailing: Switch(
|
||||
value: homeShowSo,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SO, value);
|
||||
setState(() {
|
||||
homeShowSo = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSuppliers),
|
||||
subtitle: Text(L10().homeShowSuppliersDescription),
|
||||
leading: Icon(TablerIcons.building),
|
||||
trailing: Switch(
|
||||
value: homeShowSuppliers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_HOME_SHOW_SUPPLIERS,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
homeShowSuppliers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
// TODO: When these features are improved, add them back in!
|
||||
// Currently, the company display does not provide any value
|
||||
/*
|
||||
ListTile(
|
||||
title: Text(L10().homeShowManufacturers),
|
||||
subtitle: Text(L10().homeShowManufacturersDescription),
|
||||
@ -133,23 +153,26 @@ class _HomeScreenSettingsState extends State<HomeScreenSettingsWidget> {
|
||||
),
|
||||
),
|
||||
*/
|
||||
ListTile(
|
||||
title: Text(L10().homeShowCustomers),
|
||||
subtitle: Text(L10().homeShowCustomersDescription),
|
||||
leading: Icon(TablerIcons.user),
|
||||
trailing: Switch(
|
||||
value: homeShowCustomers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_CUSTOMERS, value);
|
||||
setState(() {
|
||||
homeShowCustomers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().homeShowCustomers),
|
||||
subtitle: Text(L10().homeShowCustomersDescription),
|
||||
leading: Icon(TablerIcons.user),
|
||||
trailing: Switch(
|
||||
value: homeShowCustomers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_HOME_SHOW_CUSTOMERS,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
homeShowCustomers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -9,21 +8,16 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/widget/dialogs.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
|
||||
|
||||
class InvenTreeLoginWidget extends StatefulWidget {
|
||||
|
||||
const InvenTreeLoginWidget(this.profile) : super();
|
||||
|
||||
final UserProfile profile;
|
||||
|
||||
@override
|
||||
_InvenTreeLoginState createState() => _InvenTreeLoginState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
String username = "";
|
||||
@ -35,14 +29,12 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
|
||||
// Attempt login
|
||||
Future<void> _doLogin(BuildContext context) async {
|
||||
|
||||
// Save form
|
||||
formKey.currentState?.save();
|
||||
|
||||
bool valid = formKey.currentState?.validate() ?? false;
|
||||
|
||||
if (valid) {
|
||||
|
||||
// Dismiss the keyboard
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
|
||||
@ -53,7 +45,11 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
showLoadingOverlay();
|
||||
|
||||
// Attempt login
|
||||
final response = await InvenTreeAPI().fetchToken(widget.profile, username, password);
|
||||
final response = await InvenTreeAPI().fetchToken(
|
||||
widget.profile,
|
||||
username,
|
||||
password,
|
||||
);
|
||||
|
||||
hideLoadingOverlay();
|
||||
|
||||
@ -75,12 +71,10 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> before = [
|
||||
ListTile(
|
||||
title: Text(L10().loginEnter),
|
||||
@ -99,11 +93,13 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
|
||||
if (error.isNotEmpty) {
|
||||
after.add(Divider());
|
||||
after.add(ListTile(
|
||||
leading: Icon(TablerIcons.exclamation_circle, color: COLOR_DANGER),
|
||||
title: Text(L10().error, style: TextStyle(color: COLOR_DANGER)),
|
||||
subtitle: Text(error, style: TextStyle(color: COLOR_DANGER)),
|
||||
));
|
||||
after.add(
|
||||
ListTile(
|
||||
leading: Icon(TablerIcons.exclamation_circle, color: COLOR_DANGER),
|
||||
title: Text(L10().error, style: TextStyle(color: COLOR_DANGER)),
|
||||
subtitle: Text(error, style: TextStyle(color: COLOR_DANGER)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@ -115,8 +111,8 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
onPressed: () async {
|
||||
_doLogin(context);
|
||||
},
|
||||
)
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
key: formKey,
|
||||
@ -129,9 +125,9 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
...before,
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: L10().username,
|
||||
labelStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
hintText: L10().enterUsername
|
||||
labelText: L10().username,
|
||||
labelStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
hintText: L10().enterUsername,
|
||||
),
|
||||
initialValue: "",
|
||||
keyboardType: TextInputType.text,
|
||||
@ -147,41 +143,41 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: L10().password,
|
||||
labelStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
hintText: L10().enterPassword,
|
||||
suffixIcon: IconButton(
|
||||
icon: _obscured ? Icon(TablerIcons.eye) : Icon(TablerIcons.eye_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscured = !_obscured;
|
||||
});
|
||||
},
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
labelText: L10().password,
|
||||
labelStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
hintText: L10().enterPassword,
|
||||
suffixIcon: IconButton(
|
||||
icon: _obscured
|
||||
? Icon(TablerIcons.eye)
|
||||
: Icon(TablerIcons.eye_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscured = !_obscured;
|
||||
});
|
||||
},
|
||||
),
|
||||
initialValue: "",
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
obscureText: _obscured,
|
||||
onSaved: (value) {
|
||||
password = value?.trim() ?? "";
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return L10().passwordEmpty;
|
||||
}
|
||||
|
||||
return null;
|
||||
),
|
||||
initialValue: "",
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
obscureText: _obscured,
|
||||
onSaved: (value) {
|
||||
password = value?.trim() ?? "";
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return L10().passwordEmpty;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
),
|
||||
...after,
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.all(16),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -6,15 +5,12 @@ import "package:inventree/l10.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
|
||||
class InvenTreePartSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreePartSettingsState createState() => _InvenTreePartSettingsState();
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
|
||||
_InvenTreePartSettingsState();
|
||||
|
||||
bool partShowParameters = true;
|
||||
@ -32,16 +28,33 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
}
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
partShowParameters = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PARAMETERS, true);
|
||||
partShowBom = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_BOM, true);
|
||||
partShowPricing = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PRICING, true);
|
||||
stockShowHistory = await InvenTreeSettingsManager().getBool(INV_STOCK_SHOW_HISTORY, false);
|
||||
stockShowTests = await InvenTreeSettingsManager().getBool(INV_STOCK_SHOW_TESTS, true);
|
||||
stockConfirmScan = await InvenTreeSettingsManager().getBool(INV_STOCK_CONFIRM_SCAN, false);
|
||||
partShowParameters = await InvenTreeSettingsManager().getBool(
|
||||
INV_PART_SHOW_PARAMETERS,
|
||||
true,
|
||||
);
|
||||
partShowBom = await InvenTreeSettingsManager().getBool(
|
||||
INV_PART_SHOW_BOM,
|
||||
true,
|
||||
);
|
||||
partShowPricing = await InvenTreeSettingsManager().getBool(
|
||||
INV_PART_SHOW_PRICING,
|
||||
true,
|
||||
);
|
||||
stockShowHistory = await InvenTreeSettingsManager().getBool(
|
||||
INV_STOCK_SHOW_HISTORY,
|
||||
false,
|
||||
);
|
||||
stockShowTests = await InvenTreeSettingsManager().getBool(
|
||||
INV_STOCK_SHOW_TESTS,
|
||||
true,
|
||||
);
|
||||
stockConfirmScan = await InvenTreeSettingsManager().getBool(
|
||||
INV_STOCK_CONFIRM_SCAN,
|
||||
false,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +63,7 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().partSettings),
|
||||
backgroundColor: COLOR_APP_BAR
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
@ -62,7 +75,10 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: partShowParameters,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PART_SHOW_PARAMETERS, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_PART_SHOW_PARAMETERS,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
partShowParameters = value;
|
||||
});
|
||||
@ -90,7 +106,10 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: partShowPricing,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PART_SHOW_PRICING, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_PART_SHOW_PRICING,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
partShowPricing = value;
|
||||
});
|
||||
@ -105,7 +124,10 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: stockShowHistory,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_STOCK_SHOW_HISTORY, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_STOCK_SHOW_HISTORY,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
stockShowHistory = value;
|
||||
});
|
||||
@ -115,11 +137,14 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
ListTile(
|
||||
title: Text(L10().testResults),
|
||||
subtitle: Text(L10().testResultsDetail),
|
||||
leading: Icon(TablerIcons.test_pipe),
|
||||
leading: Icon(TablerIcons.test_pipe),
|
||||
trailing: Switch(
|
||||
value: stockShowTests,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_STOCK_SHOW_TESTS, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_STOCK_SHOW_TESTS,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
stockShowTests = value;
|
||||
});
|
||||
@ -133,16 +158,19 @@ class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> {
|
||||
trailing: Switch(
|
||||
value: stockConfirmScan,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_STOCK_CONFIRM_SCAN, value);
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_STOCK_CONFIRM_SCAN,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
stockConfirmScan = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
@ -6,15 +5,14 @@ import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
|
||||
class InvenTreePurchaseOrderSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreePurchaseOrderSettingsState createState() => _InvenTreePurchaseOrderSettingsState();
|
||||
_InvenTreePurchaseOrderSettingsState createState() =>
|
||||
_InvenTreePurchaseOrderSettingsState();
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreePurchaseOrderSettingsState extends State<InvenTreePurchaseOrderSettingsWidget> {
|
||||
|
||||
class _InvenTreePurchaseOrderSettingsState
|
||||
extends State<InvenTreePurchaseOrderSettingsWidget> {
|
||||
_InvenTreePurchaseOrderSettingsState();
|
||||
|
||||
bool poEnable = true;
|
||||
@ -30,70 +28,81 @@ class _InvenTreePurchaseOrderSettingsState extends State<InvenTreePurchaseOrderS
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
poEnable = await InvenTreeSettingsManager().getBool(INV_PO_ENABLE, true);
|
||||
poShowCamera = await InvenTreeSettingsManager().getBool(INV_PO_SHOW_CAMERA, true);
|
||||
poConfirmScan = await InvenTreeSettingsManager().getBool(INV_PO_CONFIRM_SCAN, true);
|
||||
poShowCamera = await InvenTreeSettingsManager().getBool(
|
||||
INV_PO_SHOW_CAMERA,
|
||||
true,
|
||||
);
|
||||
poConfirmScan = await InvenTreeSettingsManager().getBool(
|
||||
INV_PO_CONFIRM_SCAN,
|
||||
true,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().purchaseOrderSettings),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
appBar: AppBar(
|
||||
title: Text(L10().purchaseOrderSettings),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderEnable),
|
||||
subtitle: Text(L10().purchaseOrderEnableDetail),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: poEnable,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PO_ENABLE, value);
|
||||
setState(() {
|
||||
poEnable = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderShowCamera),
|
||||
subtitle: Text(L10().purchaseOrderShowCameraDetail),
|
||||
leading: Icon(TablerIcons.camera),
|
||||
trailing: Switch(
|
||||
value: poShowCamera,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_PO_SHOW_CAMERA,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
poShowCamera = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderConfirmScan),
|
||||
subtitle: Text(L10().purchaseOrderConfirmScanDetail),
|
||||
leading: Icon(TablerIcons.barcode),
|
||||
trailing: Switch(
|
||||
value: poConfirmScan,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_PO_CONFIRM_SCAN,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
poConfirmScan = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderEnable),
|
||||
subtitle: Text(L10().purchaseOrderEnableDetail),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: poEnable,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PO_ENABLE, value);
|
||||
setState(() {
|
||||
poEnable = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderShowCamera),
|
||||
subtitle: Text(L10().purchaseOrderShowCameraDetail),
|
||||
leading: Icon(TablerIcons.camera),
|
||||
trailing: Switch(
|
||||
value: poShowCamera,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PO_SHOW_CAMERA, value);
|
||||
setState(() {
|
||||
poShowCamera = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrderConfirmScan),
|
||||
subtitle: Text(L10().purchaseOrderConfirmScanDetail),
|
||||
leading: Icon(TablerIcons.barcode),
|
||||
trailing: Switch (
|
||||
value: poConfirmScan,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PO_CONFIRM_SCAN, value);
|
||||
setState(() {
|
||||
poConfirmScan = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,13 @@ import "package:url_launcher/url_launcher.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
|
||||
|
||||
class ReleaseNotesWidget extends StatelessWidget {
|
||||
|
||||
const ReleaseNotesWidget(this.releaseNotes);
|
||||
|
||||
final String releaseNotes;
|
||||
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().releaseNotes),
|
||||
@ -29,21 +27,18 @@ class ReleaseNotesWidget extends StatelessWidget {
|
||||
openLink(link);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CreditsWidget extends StatelessWidget {
|
||||
|
||||
const CreditsWidget(this.credits);
|
||||
|
||||
final String credits;
|
||||
|
||||
// Callback function when a link is clicked in the markdown
|
||||
Future<void> openLink(String url) async {
|
||||
|
||||
final link = Uri.parse(url);
|
||||
|
||||
if (await canLaunchUrl(link)) {
|
||||
@ -52,7 +47,7 @@ class CreditsWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().credits),
|
||||
@ -67,7 +62,7 @@ class CreditsWidget extends StatelessWidget {
|
||||
openLink(link);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -6,15 +5,14 @@ import "package:inventree/l10.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
|
||||
class InvenTreeSalesOrderSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreeSalesOrderSettingsState createState() => _InvenTreeSalesOrderSettingsState();
|
||||
_InvenTreeSalesOrderSettingsState createState() =>
|
||||
_InvenTreeSalesOrderSettingsState();
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreeSalesOrderSettingsState extends State<InvenTreeSalesOrderSettingsWidget> {
|
||||
|
||||
class _InvenTreeSalesOrderSettingsState
|
||||
extends State<InvenTreeSalesOrderSettingsWidget> {
|
||||
_InvenTreeSalesOrderSettingsState();
|
||||
|
||||
bool soEnable = true;
|
||||
@ -29,55 +27,60 @@ class _InvenTreeSalesOrderSettingsState extends State<InvenTreeSalesOrderSetting
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
soEnable = await InvenTreeSettingsManager().getBool(INV_SO_ENABLE, true);
|
||||
soShowCamera = await InvenTreeSettingsManager().getBool(INV_SO_SHOW_CAMERA, true);
|
||||
soShowCamera = await InvenTreeSettingsManager().getBool(
|
||||
INV_SO_SHOW_CAMERA,
|
||||
true,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10().salesOrderSettings),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
appBar: AppBar(
|
||||
title: Text(L10().salesOrderSettings),
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().salesOrderEnable),
|
||||
subtitle: Text(L10().salesOrderEnableDetail),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: soEnable,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SO_ENABLE, value);
|
||||
setState(() {
|
||||
soEnable = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().salesOrderShowCamera),
|
||||
subtitle: Text(L10().salesOrderShowCameraDetail),
|
||||
leading: Icon(TablerIcons.camera),
|
||||
trailing: Switch(
|
||||
value: soShowCamera,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(
|
||||
INV_SO_SHOW_CAMERA,
|
||||
value,
|
||||
);
|
||||
setState(() {
|
||||
soShowCamera = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().salesOrderEnable),
|
||||
subtitle: Text(L10().salesOrderEnableDetail),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Switch(
|
||||
value: soEnable,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SO_ENABLE, value);
|
||||
setState(() {
|
||||
soEnable = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().salesOrderShowCamera),
|
||||
subtitle: Text(L10().salesOrderShowCameraDetail),
|
||||
leading: Icon(TablerIcons.camera),
|
||||
trailing: Switch(
|
||||
value: soShowCamera,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SO_SHOW_CAMERA, value);
|
||||
setState(() {
|
||||
soShowCamera = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,39 +12,37 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/user_profile.dart";
|
||||
|
||||
class InvenTreeSelectServerWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
_InvenTreeSelectServerState createState() => _InvenTreeSelectServerState();
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
|
||||
_InvenTreeSelectServerState() {
|
||||
_reload();
|
||||
}
|
||||
|
||||
final GlobalKey<_InvenTreeSelectServerState> _loginKey = GlobalKey<_InvenTreeSelectServerState>();
|
||||
final GlobalKey<_InvenTreeSelectServerState> _loginKey =
|
||||
GlobalKey<_InvenTreeSelectServerState>();
|
||||
|
||||
List<UserProfile> profiles = [];
|
||||
|
||||
Future <void> _reload() async {
|
||||
|
||||
Future<void> _reload() async {
|
||||
profiles = await UserProfileDBManager().getAllProfiles();
|
||||
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/*
|
||||
* Logout the selected profile (delete the stored token)
|
||||
*/
|
||||
Future<void> _logoutProfile(BuildContext context, {UserProfile? userProfile}) async {
|
||||
|
||||
Future<void> _logoutProfile(
|
||||
BuildContext context, {
|
||||
UserProfile? userProfile,
|
||||
}) async {
|
||||
if (userProfile != null) {
|
||||
userProfile.token = "";
|
||||
await UserProfileDBManager().updateProfile(userProfile);
|
||||
@ -54,26 +52,25 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
|
||||
InvenTreeAPI().disconnectFromServer();
|
||||
_reload();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Edit the selected profile
|
||||
*/
|
||||
void _editProfile(BuildContext context, {UserProfile? userProfile, bool createNew = false}) {
|
||||
|
||||
void _editProfile(
|
||||
BuildContext context, {
|
||||
UserProfile? userProfile,
|
||||
bool createNew = false,
|
||||
}) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ProfileEditWidget(userProfile)
|
||||
)
|
||||
MaterialPageRoute(builder: (context) => ProfileEditWidget(userProfile)),
|
||||
).then((context) {
|
||||
_reload();
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> _selectProfile(BuildContext context, UserProfile profile) async {
|
||||
|
||||
Future<void> _selectProfile(BuildContext context, UserProfile profile) async {
|
||||
// Disconnect InvenTree
|
||||
InvenTreeAPI().disconnectFromServer();
|
||||
|
||||
@ -94,8 +91,9 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
// First check if the profile has an associate token
|
||||
if (!prf.hasToken) {
|
||||
// Redirect user to login screen
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => InvenTreeLoginWidget(profile))
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => InvenTreeLoginWidget(profile)),
|
||||
).then((value) async {
|
||||
_reload();
|
||||
// Reload profile
|
||||
@ -125,8 +123,7 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
_reload();
|
||||
}
|
||||
|
||||
Future <void> _deleteProfile(UserProfile profile) async {
|
||||
|
||||
Future<void> _deleteProfile(UserProfile profile) async {
|
||||
await UserProfileDBManager().deleteProfile(profile);
|
||||
|
||||
if (!mounted) {
|
||||
@ -135,13 +132,13 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
|
||||
_reload();
|
||||
|
||||
if (InvenTreeAPI().isConnected() && profile.key == (InvenTreeAPI().profile?.key ?? "")) {
|
||||
if (InvenTreeAPI().isConnected() &&
|
||||
profile.key == (InvenTreeAPI().profile?.key ?? "")) {
|
||||
InvenTreeAPI().disconnectFromServer();
|
||||
}
|
||||
}
|
||||
|
||||
Widget? _getProfileIcon(UserProfile profile) {
|
||||
|
||||
// Not selected? No icon for you!
|
||||
if (!profile.selected) return null;
|
||||
|
||||
@ -152,45 +149,38 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
|
||||
// Reflect the connection status of the server
|
||||
if (InvenTreeAPI().isConnected()) {
|
||||
return Icon(
|
||||
TablerIcons.circle_check,
|
||||
color: COLOR_SUCCESS
|
||||
);
|
||||
return Icon(TablerIcons.circle_check, color: COLOR_SUCCESS);
|
||||
} else if (InvenTreeAPI().isConnecting()) {
|
||||
return Spinner(
|
||||
icon: TablerIcons.loader_2,
|
||||
color: COLOR_PROGRESS,
|
||||
);
|
||||
return Spinner(icon: TablerIcons.loader_2, color: COLOR_PROGRESS);
|
||||
} else {
|
||||
return Icon(
|
||||
TablerIcons.circle_x,
|
||||
color: COLOR_DANGER,
|
||||
);
|
||||
return Icon(TablerIcons.circle_x, color: COLOR_DANGER);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> children = [];
|
||||
|
||||
if (profiles.isNotEmpty) {
|
||||
for (int idx = 0; idx < profiles.length; idx++) {
|
||||
UserProfile profile = profiles[idx];
|
||||
|
||||
children.add(ListTile(
|
||||
title: Text(
|
||||
profile.name,
|
||||
),
|
||||
tileColor: profile.selected ? Theme.of(context).secondaryHeaderColor : null,
|
||||
subtitle: Text("${profile.server}"),
|
||||
leading: profile.hasToken ? Icon(TablerIcons.user_check, color: COLOR_SUCCESS) : Icon(TablerIcons.user_cancel, color: COLOR_WARNING),
|
||||
trailing: _getProfileIcon(profile),
|
||||
onTap: () {
|
||||
_selectProfile(context, profile);
|
||||
},
|
||||
onLongPress: () {
|
||||
OneContext().showDialog(
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(profile.name),
|
||||
tileColor: profile.selected
|
||||
? Theme.of(context).secondaryHeaderColor
|
||||
: null,
|
||||
subtitle: Text("${profile.server}"),
|
||||
leading: profile.hasToken
|
||||
? Icon(TablerIcons.user_check, color: COLOR_SUCCESS)
|
||||
: Icon(TablerIcons.user_cancel, color: COLOR_WARNING),
|
||||
trailing: _getProfileIcon(profile),
|
||||
onTap: () {
|
||||
_selectProfile(context, profile);
|
||||
},
|
||||
onLongPress: () {
|
||||
OneContext().showDialog(
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: Text(profile.name),
|
||||
@ -204,7 +194,7 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
child: ListTile(
|
||||
title: Text(L10().profileConnect),
|
||||
leading: Icon(TablerIcons.server),
|
||||
)
|
||||
),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
@ -213,8 +203,8 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().profileEdit),
|
||||
leading: Icon(TablerIcons.edit)
|
||||
)
|
||||
leading: Icon(TablerIcons.edit),
|
||||
),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
@ -224,7 +214,7 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
child: ListTile(
|
||||
title: Text(L10().profileLogout),
|
||||
leading: Icon(TablerIcons.logout),
|
||||
)
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
SimpleDialogOption(
|
||||
@ -238,28 +228,28 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
icon: TablerIcons.trash,
|
||||
onAccept: () {
|
||||
_deleteProfile(profile);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().profileDelete, style: TextStyle(color: Colors.red)),
|
||||
title: Text(
|
||||
L10().profileDelete,
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
leading: Icon(TablerIcons.trash, color: Colors.red),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// No profile available!
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().profileNone),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(title: Text(L10().profileNone)));
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
@ -273,27 +263,25 @@ class _InvenTreeSelectServerState extends State<InvenTreeSelectServerWidget> {
|
||||
onPressed: () {
|
||||
_editProfile(context, createNew: true);
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: children
|
||||
tiles: children,
|
||||
).toList(),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Widget for editing server details
|
||||
*/
|
||||
class ProfileEditWidget extends StatefulWidget {
|
||||
|
||||
const ProfileEditWidget(this.profile) : super();
|
||||
|
||||
final UserProfile? profile;
|
||||
@ -303,7 +291,6 @@ class ProfileEditWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
|
||||
_ProfileEditState() : super();
|
||||
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@ -316,7 +303,9 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: COLOR_APP_BAR,
|
||||
title: Text(widget.profile == null ? L10().profileAdd : L10().profileEdit),
|
||||
title: Text(
|
||||
widget.profile == null ? L10().profileAdd : L10().profileEdit,
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.circle_check),
|
||||
@ -327,14 +316,10 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
UserProfile? prf = widget.profile;
|
||||
|
||||
if (prf == null) {
|
||||
UserProfile profile = UserProfile(
|
||||
name: name,
|
||||
server: server,
|
||||
);
|
||||
UserProfile profile = UserProfile(name: name, server: server);
|
||||
|
||||
await UserProfileDBManager().addProfile(profile);
|
||||
} else {
|
||||
|
||||
prf.name = name;
|
||||
prf.server = server;
|
||||
|
||||
@ -345,8 +330,8 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
)
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
key: formKey,
|
||||
@ -373,7 +358,7 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
@ -398,7 +383,8 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
return L10().invalidHost;
|
||||
}
|
||||
|
||||
if (!value.startsWith("http:") && !value.startsWith("https:")) {
|
||||
if (!value.startsWith("http:") &&
|
||||
!value.startsWith("https:")) {
|
||||
// return L10().serverStart;
|
||||
}
|
||||
|
||||
@ -410,7 +396,10 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
Uri uri = Uri.parse(value);
|
||||
|
||||
if (uri.hasScheme) {
|
||||
if (!["http", "https"].contains(uri.scheme.toLowerCase())) {
|
||||
if (![
|
||||
"http",
|
||||
"https",
|
||||
].contains(uri.scheme.toLowerCase())) {
|
||||
return L10().serverStart;
|
||||
}
|
||||
} else {
|
||||
@ -422,12 +411,11 @@ class _ProfileEditState extends State<ProfileEditWidget> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.all(16),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,11 @@ import "package:inventree/settings/sales_order_settings.dart";
|
||||
|
||||
// InvenTree settings view
|
||||
class InvenTreeSettingsWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
_InvenTreeSettingsState createState() => _InvenTreeSettingsState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
/*
|
||||
@ -32,8 +28,10 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||
*/
|
||||
Future<void> _about() async {
|
||||
PackageInfo.fromPlatform().then((PackageInfo info) {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info)));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => InvenTreeAboutWidget(info)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -48,72 +46,108 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||
body: Center(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(L10().server),
|
||||
subtitle: Text(L10().configureServer),
|
||||
leading: Icon(TablerIcons.server, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSelectServerWidget()));
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text(L10().appSettings),
|
||||
subtitle: Text(L10().appSettingsDetails),
|
||||
leading: Icon(TablerIcons.settings, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget()));
|
||||
}
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeScreen),
|
||||
subtitle: Text(L10().homeScreenSettings),
|
||||
leading: Icon(TablerIcons.home, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreenSettingsWidget()));
|
||||
}
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().barcodes),
|
||||
subtitle: Text(L10().barcodeSettings),
|
||||
leading: Icon(TablerIcons.barcode, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeBarcodeSettingsWidget()));
|
||||
}
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().part),
|
||||
subtitle: Text(L10().partSettings),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreePartSettingsWidget()));
|
||||
}
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrder),
|
||||
subtitle: Text(L10().purchaseOrderSettings),
|
||||
leading: Icon(TablerIcons.shopping_cart, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreePurchaseOrderSettingsWidget()));
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().salesOrder),
|
||||
subtitle: Text(L10().salesOrderSettings),
|
||||
leading: Icon(TablerIcons.truck, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSalesOrderSettingsWidget()));
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text(L10().about),
|
||||
leading: Icon(TablerIcons.info_circle, color: COLOR_ACTION),
|
||||
onTap: _about,
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().server),
|
||||
subtitle: Text(L10().configureServer),
|
||||
leading: Icon(TablerIcons.server, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreeSelectServerWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text(L10().appSettings),
|
||||
subtitle: Text(L10().appSettingsDetails),
|
||||
leading: Icon(TablerIcons.settings, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreeAppSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeScreen),
|
||||
subtitle: Text(L10().homeScreenSettings),
|
||||
leading: Icon(TablerIcons.home, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => HomeScreenSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().barcodes),
|
||||
subtitle: Text(L10().barcodeSettings),
|
||||
leading: Icon(TablerIcons.barcode, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreeBarcodeSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().part),
|
||||
subtitle: Text(L10().partSettings),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreePartSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrder),
|
||||
subtitle: Text(L10().purchaseOrderSettings),
|
||||
leading: Icon(TablerIcons.shopping_cart, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
InvenTreePurchaseOrderSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().salesOrder),
|
||||
subtitle: Text(L10().salesOrderSettings),
|
||||
leading: Icon(TablerIcons.truck, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreeSalesOrderSettingsWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text(L10().about),
|
||||
leading: Icon(TablerIcons.info_circle, color: COLOR_ACTION),
|
||||
onTap: _about,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user