Account management
This commit is contained in:
parent
16d71bb71c
commit
7b6e17bec5
|
|
@ -5,12 +5,12 @@ class ElevatedButton extends StatelessWidget {
|
||||||
const ElevatedButton(
|
const ElevatedButton(
|
||||||
{@required this.label,
|
{@required this.label,
|
||||||
@required this.onPressed,
|
@required this.onPressed,
|
||||||
this.icon,
|
this.iconData,
|
||||||
this.color,
|
this.color,
|
||||||
this.width});
|
this.width});
|
||||||
|
|
||||||
final Color color;
|
final Color color;
|
||||||
final IconData icon;
|
final IconData iconData;
|
||||||
final String label;
|
final String label;
|
||||||
final Function onPressed;
|
final Function onPressed;
|
||||||
final double width;
|
final double width;
|
||||||
|
|
@ -22,9 +22,9 @@ class ElevatedButton extends StatelessWidget {
|
||||||
child: RaisedButton(
|
child: RaisedButton(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||||
color: color ?? Theme.of(context).buttonColor,
|
color: color ?? Theme.of(context).buttonColor,
|
||||||
child: icon != null
|
child: iconData != null
|
||||||
? IconText(
|
? IconText(
|
||||||
icon: icon,
|
icon: iconData,
|
||||||
text: label,
|
text: label,
|
||||||
)
|
)
|
||||||
: Text(label),
|
: Text(label),
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class DocumentGrid extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
icon: Icons.camera_alt,
|
iconData: Icons.camera_alt,
|
||||||
label: localization.takePicture,
|
label: localization.takePicture,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final image = await ImagePicker.pickImage(
|
final image = await ImagePicker.pickImage(
|
||||||
|
|
@ -56,7 +56,7 @@ class DocumentGrid extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
icon: Icons.insert_drive_file,
|
iconData: Icons.insert_drive_file,
|
||||||
label: localization.uploadFile,
|
label: localization.uploadFile,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final image = await ImagePicker.pickImage(
|
final image = await ImagePicker.pickImage(
|
||||||
|
|
@ -133,7 +133,7 @@ class DocumentTile extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
isFromExpense
|
isFromExpense
|
||||||
? ElevatedButton(
|
? ElevatedButton(
|
||||||
icon: getEntityIcon(EntityType.expense),
|
iconData: getEntityIcon(EntityType.expense),
|
||||||
label: localization.expense,
|
label: localization.expense,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
@ -142,7 +142,7 @@ class DocumentTile extends StatelessWidget {
|
||||||
)
|
)
|
||||||
: ElevatedButton(
|
: ElevatedButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.delete,
|
label: localization.delete,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
confirmCallback(
|
confirmCallback(
|
||||||
|
|
@ -157,7 +157,7 @@ class DocumentTile extends StatelessWidget {
|
||||||
width: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
icon: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
onPressed: () => confirmCallback(
|
onPressed: () => confirmCallback(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -264,7 +264,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
icon: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.onDoneContactPressed();
|
viewModel.onDoneContactPressed();
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class _GroupViewState extends State<GroupView> {
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
label: localization.configureSettings.toUpperCase(),
|
label: localization.configureSettings.toUpperCase(),
|
||||||
icon: Icons.settings,
|
iconData: Icons.settings,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
handleGroupAction(context, [group], EntityAction.settings),
|
handleGroupAction(context, [group], EntityAction.settings),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.viewModel.onRemoveInvoiceItemPressed(widget.index);
|
widget.viewModel.onRemoveInvoiceItemPressed(widget.index);
|
||||||
|
|
@ -221,7 +221,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
icon: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.onDoneInvoiceItemPressed();
|
viewModel.onDoneInvoiceItemPressed();
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
class AccountManagement extends StatefulWidget {
|
class AccountManagement extends StatefulWidget {
|
||||||
|
|
@ -16,8 +18,7 @@ class AccountManagement extends StatefulWidget {
|
||||||
final AccountManagementVM viewModel;
|
final AccountManagementVM viewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AccountManagementState createState() =>
|
_AccountManagementState createState() => _AccountManagementState();
|
||||||
_AccountManagementState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AccountManagementState extends State<AccountManagement>
|
class _AccountManagementState extends State<AccountManagement>
|
||||||
|
|
@ -69,38 +70,53 @@ class _AccountManagementState extends State<AccountManagement>
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListView(
|
ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
ElevatedButton(
|
||||||
|
label: localization.deleteCompany,
|
||||||
|
color: Colors.red,
|
||||||
|
iconData: Icons.delete,
|
||||||
|
onPressed: () {
|
||||||
|
confirmCallback(
|
||||||
|
context: context,
|
||||||
|
callback: () {
|
||||||
|
passwordCallback(
|
||||||
|
context: context,
|
||||||
|
callback: (password) {
|
||||||
|
print('delete');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ListView(
|
ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FormCard(
|
FormCard(
|
||||||
// TODO change to kModules.keys
|
// TODO change to kModules.keys
|
||||||
children: kModules.keys.map((module) {
|
children: kModules.keys.map((module) {
|
||||||
final implementedModules = [
|
final implementedModules = [
|
||||||
kModuleQuotes,
|
kModuleQuotes,
|
||||||
kModuleCredits,
|
kModuleCredits,
|
||||||
];
|
];
|
||||||
final isImplemented = implementedModules.contains(module);
|
final isImplemented = implementedModules.contains(module);
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
title: Text(localization.lookup(kModules[module])),
|
title: Text(localization.lookup(kModules[module])),
|
||||||
value: company.enabledModules & module != 0,
|
value: company.enabledModules & module != 0,
|
||||||
activeColor: Theme.of(context).accentColor,
|
activeColor: Theme.of(context).accentColor,
|
||||||
onChanged: isImplemented
|
onChanged: isImplemented
|
||||||
? (value) {
|
? (value) {
|
||||||
int enabledModules = company.enabledModules;
|
int enabledModules = company.enabledModules;
|
||||||
if (value) {
|
if (value) {
|
||||||
enabledModules = enabledModules | module;
|
enabledModules = enabledModules | module;
|
||||||
} else {
|
} else {
|
||||||
enabledModules = enabledModules ^ module;
|
enabledModules = enabledModules ^ module;
|
||||||
|
}
|
||||||
|
viewModel.onCompanyChanged(company.rebuild(
|
||||||
|
(b) => b..enabledModules = enabledModules));
|
||||||
}
|
}
|
||||||
viewModel.onCompanyChanged(company
|
: null,
|
||||||
.rebuild((b) => b..enabledModules = enabledModules));
|
);
|
||||||
}
|
}).toList()),
|
||||||
: null,
|
|
||||||
);
|
|
||||||
}).toList()),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
color: Colors.redAccent,
|
color: Colors.redAccent,
|
||||||
label: localization.delete,
|
label: localization.delete,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
confirmCallback(
|
confirmCallback(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -359,7 +359,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
label: localization.uploadLogo,
|
label: localization.uploadLogo,
|
||||||
icon: Icons.cloud_upload,
|
iconData: Icons.cloud_upload,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
String path;
|
String path;
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.viewModel.onRemoveTaskTimePressed(widget.index);
|
widget.viewModel.onRemoveTaskTimePressed(widget.index);
|
||||||
|
|
@ -155,7 +155,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
icon: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final startDate = DateTime.parse(_date);
|
final startDate = DateTime.parse(_date);
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
onPressed: () => confirmCallback(
|
onPressed: () => confirmCallback(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -253,7 +253,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
icon: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.onDoneContactPressed();
|
viewModel.onDoneContactPressed();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ void showErrorDialog({BuildContext context, String message}) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void confirmCallback({BuildContext context, VoidCallback callback}) {
|
void confirmCallback({
|
||||||
|
@required BuildContext context,
|
||||||
|
@required VoidCallback callback,
|
||||||
|
String message,
|
||||||
|
}) {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
showDialog<AlertDialog>(
|
showDialog<AlertDialog>(
|
||||||
|
|
@ -20,6 +24,7 @@ void confirmCallback({BuildContext context, VoidCallback callback}) {
|
||||||
builder: (BuildContext context) => AlertDialog(
|
builder: (BuildContext context) => AlertDialog(
|
||||||
semanticLabel: localization.areYouSure,
|
semanticLabel: localization.areYouSure,
|
||||||
title: Text(localization.areYouSure),
|
title: Text(localization.areYouSure),
|
||||||
|
content: message == null ? null : Text(message),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(localization.cancel.toUpperCase()),
|
child: Text(localization.cancel.toUpperCase()),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
|
'delete_company': 'Delete Company',
|
||||||
'enable_modules': 'Enable Modules',
|
'enable_modules': 'Enable Modules',
|
||||||
'converted_quote': 'Successfully converted quote',
|
'converted_quote': 'Successfully converted quote',
|
||||||
'credit_design': 'Credit Design',
|
'credit_design': 'Credit Design',
|
||||||
|
|
@ -32853,6 +32854,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
|
|
||||||
String get enableModules => _localizedValues[localeCode]['enable_modules'];
|
String get enableModules => _localizedValues[localeCode]['enable_modules'];
|
||||||
|
|
||||||
|
String get deleteCompany => _localizedValues[localeCode]['delete_company'];
|
||||||
|
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
final lookupKey = toSnakeCase(key);
|
final lookupKey = toSnakeCase(key);
|
||||||
return _localizedValues[localeCode][lookupKey] ??
|
return _localizedValues[localeCode][lookupKey] ??
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue