mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +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();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
void _selectProfile(UserProfile profile) async {
|
||||
void _selectProfile(BuildContext context, UserProfile profile) async {
|
||||
|
||||
// Mark currently selected profile as unselected
|
||||
final selected = await UserProfileDBManager().getSelectedProfile();
|
||||
@ -180,6 +180,9 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
||||
await UserProfileDBManager().updateProfile(profile);
|
||||
|
||||
_reload();
|
||||
|
||||
// Attempt server login (this will load the newly selected profile
|
||||
InvenTreeAPI().connect(context);
|
||||
}
|
||||
|
||||
void _deleteProfile(UserProfile profile) async {
|
||||
@ -219,60 +222,78 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
||||
|
||||
List<Widget> children = [];
|
||||
|
||||
for (int idx = 0; idx < profiles.length; idx++) {
|
||||
if (profiles.length > 0) {
|
||||
for (int idx = 0; idx < profiles.length; idx++) {
|
||||
UserProfile profile = profiles[idx];
|
||||
|
||||
UserProfile profile = profiles[idx];
|
||||
|
||||
children.add(ListTile(
|
||||
title: Text(
|
||||
children.add(ListTile(
|
||||
title: Text(
|
||||
profile.name,
|
||||
),
|
||||
subtitle: Text(profile.server),
|
||||
trailing: profile.selected ? FaIcon(FontAwesomeIcons.checkCircle) : null,
|
||||
onLongPress: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: Text(profile.name),
|
||||
children: <Widget> [
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_selectProfile(profile);
|
||||
},
|
||||
child: Text(I18N.of(context).profileSelect),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_editProfile(context, userProfile: profile);
|
||||
},
|
||||
child: Text(I18N.of(context).profileEdit),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
// Navigator.of(context, rootNavigator: true).pop();
|
||||
confirmationDialog(
|
||||
context,
|
||||
I18N.of(context).delete,
|
||||
"Delete this profile?",
|
||||
onAccept: () {
|
||||
_deleteProfile(profile);
|
||||
}
|
||||
);
|
||||
},
|
||||
child: Text(I18N.of(context).profileDelete),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
onTap: () {
|
||||
),
|
||||
subtitle: Text(profile.server),
|
||||
trailing: profile.selected
|
||||
? FaIcon(FontAwesomeIcons.checkCircle)
|
||||
: null,
|
||||
onLongPress: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: Text(profile.name),
|
||||
children: <Widget>[
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_selectProfile(context, profile);
|
||||
},
|
||||
child: Text(I18N
|
||||
.of(context)
|
||||
.profileSelect),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_editProfile(context, userProfile: profile);
|
||||
},
|
||||
child: Text(I18N
|
||||
.of(context)
|
||||
.profileEdit),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
// Navigator.of(context, rootNavigator: true).pop();
|
||||
confirmationDialog(
|
||||
context,
|
||||
I18N
|
||||
.of(context)
|
||||
.delete,
|
||||
"Delete this profile?",
|
||||
onAccept: () {
|
||||
_deleteProfile(profile);
|
||||
}
|
||||
);
|
||||
},
|
||||
child: Text(I18N
|
||||
.of(context)
|
||||
.profileDelete),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
onTap: () {
|
||||
|
||||
},
|
||||
));
|
||||
},
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// No profile available!
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text("No profiles available"),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
|
@ -30,15 +30,15 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("InvenTree Settings"),
|
||||
title: Text(I18N.of(context).settings),
|
||||
),
|
||||
body: Center(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(I18N.of(context).serverSettings),
|
||||
subtitle: Text("Configure server and login settings"),
|
||||
leading: FaIcon(FontAwesomeIcons.server),
|
||||
title: Text(I18N.of(context).profile),
|
||||
subtitle: Text("Configure user profile settings"),
|
||||
leading: FaIcon(FontAwesomeIcons.user),
|
||||
onTap: _editServerSettings,
|
||||
),
|
||||
Divider(),
|
||||
|
@ -3,6 +3,7 @@ import 'package:InvenTree/barcode.dart';
|
||||
import 'package:InvenTree/widget/company_list.dart';
|
||||
import 'package:InvenTree/widget/search.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
@ -155,7 +156,7 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
*/
|
||||
new Divider(),
|
||||
new ListTile(
|
||||
title: new Text("Settings"),
|
||||
title: new Text(I18N.of(context).settings),
|
||||
leading: new Icon(Icons.settings),
|
||||
onTap: _settings,
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user