mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Cleanup
This commit is contained in:
parent
74e6315a57
commit
d918079440
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit ef139565bba4fcd5889aa242a0062827eab5eceb
|
Subproject commit c342d99f068f8ac662dfb729fea0b5867aac1cc6
|
@ -83,24 +83,4 @@ class InvenTreePreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InvenTreePreferences._internal();
|
InvenTreePreferences._internal();
|
||||||
|
|
||||||
// Load saved login details, and attempt connection
|
|
||||||
void loadLoginDetails(BuildContext context) async {
|
|
||||||
|
|
||||||
print("Loading login details");
|
|
||||||
|
|
||||||
await InvenTreeAPI().connectToServer(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveLoginDetails(BuildContext context, String server, String username, String password) async {
|
|
||||||
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
|
|
||||||
await prefs.setString(_SERVER, server);
|
|
||||||
await prefs.setString(_USERNAME, username);
|
|
||||||
await prefs.setString(_PASSWORD, password);
|
|
||||||
|
|
||||||
// Reconnect the API
|
|
||||||
await InvenTreeAPI().connectToServer(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -166,7 +166,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _selectProfile(UserProfile profile) async {
|
void _selectProfile(BuildContext context, UserProfile profile) async {
|
||||||
|
|
||||||
// Mark currently selected profile as unselected
|
// Mark currently selected profile as unselected
|
||||||
final selected = await UserProfileDBManager().getSelectedProfile();
|
final selected = await UserProfileDBManager().getSelectedProfile();
|
||||||
@ -180,6 +180,9 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
await UserProfileDBManager().updateProfile(profile);
|
await UserProfileDBManager().updateProfile(profile);
|
||||||
|
|
||||||
_reload();
|
_reload();
|
||||||
|
|
||||||
|
// Attempt server login (this will load the newly selected profile
|
||||||
|
InvenTreeAPI().connect(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _deleteProfile(UserProfile profile) async {
|
void _deleteProfile(UserProfile profile) async {
|
||||||
@ -219,8 +222,8 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
|
|
||||||
List<Widget> children = [];
|
List<Widget> children = [];
|
||||||
|
|
||||||
|
if (profiles.length > 0) {
|
||||||
for (int idx = 0; idx < profiles.length; idx++) {
|
for (int idx = 0; idx < profiles.length; idx++) {
|
||||||
|
|
||||||
UserProfile profile = profiles[idx];
|
UserProfile profile = profiles[idx];
|
||||||
|
|
||||||
children.add(ListTile(
|
children.add(ListTile(
|
||||||
@ -228,41 +231,51 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
profile.name,
|
profile.name,
|
||||||
),
|
),
|
||||||
subtitle: Text(profile.server),
|
subtitle: Text(profile.server),
|
||||||
trailing: profile.selected ? FaIcon(FontAwesomeIcons.checkCircle) : null,
|
trailing: profile.selected
|
||||||
|
? FaIcon(FontAwesomeIcons.checkCircle)
|
||||||
|
: null,
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return SimpleDialog(
|
return SimpleDialog(
|
||||||
title: Text(profile.name),
|
title: Text(profile.name),
|
||||||
children: <Widget> [
|
children: <Widget>[
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_selectProfile(profile);
|
_selectProfile(context, profile);
|
||||||
},
|
},
|
||||||
child: Text(I18N.of(context).profileSelect),
|
child: Text(I18N
|
||||||
|
.of(context)
|
||||||
|
.profileSelect),
|
||||||
),
|
),
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_editProfile(context, userProfile: profile);
|
_editProfile(context, userProfile: profile);
|
||||||
},
|
},
|
||||||
child: Text(I18N.of(context).profileEdit),
|
child: Text(I18N
|
||||||
|
.of(context)
|
||||||
|
.profileEdit),
|
||||||
),
|
),
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Navigator.of(context, rootNavigator: true).pop();
|
// Navigator.of(context, rootNavigator: true).pop();
|
||||||
confirmationDialog(
|
confirmationDialog(
|
||||||
context,
|
context,
|
||||||
I18N.of(context).delete,
|
I18N
|
||||||
|
.of(context)
|
||||||
|
.delete,
|
||||||
"Delete this profile?",
|
"Delete this profile?",
|
||||||
onAccept: () {
|
onAccept: () {
|
||||||
_deleteProfile(profile);
|
_deleteProfile(profile);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(I18N.of(context).profileDelete),
|
child: Text(I18N
|
||||||
|
.of(context)
|
||||||
|
.profileDelete),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -274,6 +287,14 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// No profile available!
|
||||||
|
children.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text("No profiles available"),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -30,15 +30,15 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("InvenTree Settings"),
|
title: Text(I18N.of(context).settings),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(I18N.of(context).serverSettings),
|
title: Text(I18N.of(context).profile),
|
||||||
subtitle: Text("Configure server and login settings"),
|
subtitle: Text("Configure user profile settings"),
|
||||||
leading: FaIcon(FontAwesomeIcons.server),
|
leading: FaIcon(FontAwesomeIcons.user),
|
||||||
onTap: _editServerSettings,
|
onTap: _editServerSettings,
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
|
@ -3,6 +3,7 @@ import 'package:InvenTree/barcode.dart';
|
|||||||
import 'package:InvenTree/widget/company_list.dart';
|
import 'package:InvenTree/widget/company_list.dart';
|
||||||
import 'package:InvenTree/widget/search.dart';
|
import 'package:InvenTree/widget/search.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
|
||||||
@ -155,7 +156,7 @@ class InvenTreeDrawer extends StatelessWidget {
|
|||||||
*/
|
*/
|
||||||
new Divider(),
|
new Divider(),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
title: new Text("Settings"),
|
title: new Text(I18N.of(context).settings),
|
||||||
leading: new Icon(Icons.settings),
|
leading: new Icon(Icons.settings),
|
||||||
onTap: _settings,
|
onTap: _settings,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user