Code refactor
This commit is contained in:
parent
f78d1b812d
commit
c2e3e46ac8
|
|
@ -1,8 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/icon_text.dart';
|
import 'package:invoiceninja_flutter/ui/app/icon_text.dart';
|
||||||
|
|
||||||
class ElevatedButton extends StatelessWidget {
|
class AppButton extends StatelessWidget {
|
||||||
const ElevatedButton({
|
const AppButton({
|
||||||
@required this.label,
|
@required this.label,
|
||||||
@required this.onPressed,
|
@required this.onPressed,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class DocumentGrid extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (!kIsWeb)
|
if (!kIsWeb)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
iconData: Icons.camera_alt,
|
iconData: Icons.camera_alt,
|
||||||
label: localization.takePicture,
|
label: localization.takePicture,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|
@ -59,7 +59,7 @@ class DocumentGrid extends StatelessWidget {
|
||||||
width: 14,
|
width: 14,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
iconData: Icons.insert_drive_file,
|
iconData: Icons.insert_drive_file,
|
||||||
label: localization.uploadFile,
|
label: localization.uploadFile,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ class _DateRangePickerState extends State<DateRangePicker> {
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// TODO replace with form validation
|
// TODO replace with form validation
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class ProgressButton extends StatelessWidget {
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ElevatedButton(
|
: AppButton(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
label: label,
|
label: label,
|
||||||
onPressed: () => onPressed(),
|
onPressed: () => onPressed(),
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
onTap: () => redeemPurchase(purchase),
|
onTap: () => redeemPurchase(purchase),
|
||||||
)),
|
)),
|
||||||
if (_purchases != null)
|
if (_purchases != null)
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
label: _showPastPurchases
|
label: _showPastPurchases
|
||||||
? localization.back
|
? localization.back
|
||||||
: localization.pastPurchases,
|
: localization.pastPurchases,
|
||||||
|
|
|
||||||
|
|
@ -649,7 +649,7 @@ class _LoginState extends State<LoginView> {
|
||||||
if (isOneTimePassword && !viewModel.isLoading)
|
if (isOneTimePassword && !viewModel.isLoading)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 12.0, bottom: 12.0),
|
padding: EdgeInsets.only(top: 12.0, bottom: 12.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.cancel.toUpperCase(),
|
label: localization.cancel.toUpperCase(),
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress> {
|
||||||
client.hasShippingAddress && client.areAddressesDifferent
|
client.hasShippingAddress && client.areAddressesDifferent
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.copyShipping.toUpperCase(),
|
label: localization.copyShipping.toUpperCase(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.copyShippingAddress();
|
viewModel.copyShippingAddress();
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class _ClientEditContactsState extends State<ClientEditContacts> {
|
||||||
..addAll(contacts)
|
..addAll(contacts)
|
||||||
..add(Padding(
|
..add(Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.addContact.toUpperCase(),
|
label: localization.addContact.toUpperCase(),
|
||||||
onPressed: () => viewModel.onAddContactPressed(),
|
onPressed: () => viewModel.onAddContactPressed(),
|
||||||
),
|
),
|
||||||
|
|
@ -256,7 +256,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(),
|
child: Container(),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
iconData: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
|
|
@ -271,7 +271,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
iconData: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
|
||||||
client.hasBillingAddress && client.areAddressesDifferent
|
client.hasBillingAddress && client.areAddressesDifferent
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.copyBilling.toUpperCase(),
|
label: localization.copyBilling.toUpperCase(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.copyBillingAddress();
|
viewModel.copyBillingAddress();
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class _GroupViewState extends State<GroupView> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.configureSettings.toUpperCase(),
|
label: localization.configureSettings.toUpperCase(),
|
||||||
iconData: Icons.settings,
|
iconData: Icons.settings,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
iconData: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
|
|
@ -220,7 +220,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
iconData: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ class ReportsScreen extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Builder(builder: (BuildContext context) {
|
Builder(builder: (BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.columns,
|
label: localization.columns,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
multiselectDialog(
|
multiselectDialog(
|
||||||
|
|
@ -304,7 +304,7 @@ class ReportsScreen extends StatelessWidget {
|
||||||
}),
|
}),
|
||||||
SizedBox(width: kGutterWidth),
|
SizedBox(width: kGutterWidth),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.export,
|
label: localization.export,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
viewModel.onExportPressed(context);
|
viewModel.onExportPressed(context);
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ class _AccountOverview extends StatelessWidget {
|
||||||
SizedBox(height: 14),
|
SizedBox(height: 14),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.manageTokens.toUpperCase(),
|
label: localization.manageTokens.toUpperCase(),
|
||||||
iconData: getEntityIcon(EntityType.token),
|
iconData: getEntityIcon(EntityType.token),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
@ -145,7 +145,7 @@ class _AccountOverview extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.manageWebhooks.toUpperCase(),
|
label: localization.manageWebhooks.toUpperCase(),
|
||||||
iconData: getEntityIcon(EntityType.webhook),
|
iconData: getEntityIcon(EntityType.webhook),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
@ -185,7 +185,7 @@ class _AccountOverview extends StatelessWidget {
|
||||||
*/
|
*/
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.purchaseLicense.toUpperCase(),
|
label: localization.purchaseLicense.toUpperCase(),
|
||||||
iconData: Icons.cloud_download,
|
iconData: Icons.cloud_download,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|
@ -197,7 +197,7 @@ class _AccountOverview extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.applyLicense.toUpperCase(),
|
label: localization.applyLicense.toUpperCase(),
|
||||||
iconData: Icons.cloud_done,
|
iconData: Icons.cloud_done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
@ -231,7 +231,7 @@ class _AccountOverview extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: companies.length == 1
|
label: companies.length == 1
|
||||||
? localization.cancelAccount.toUpperCase()
|
? localization.cancelAccount.toUpperCase()
|
||||||
: localization.deleteCompany.toUpperCase(),
|
: localization.deleteCompany.toUpperCase(),
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if ('${settings.companyLogo ?? ''}'.isNotEmpty) ...[
|
if ('${settings.companyLogo ?? ''}'.isNotEmpty) ...[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
color: Colors.redAccent,
|
color: Colors.redAccent,
|
||||||
label: localization.delete,
|
label: localization.delete,
|
||||||
|
|
@ -343,7 +343,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
||||||
SizedBox(width: 20),
|
SizedBox(width: 20),
|
||||||
],
|
],
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
label: localization.uploadLogo,
|
label: localization.uploadLogo,
|
||||||
iconData: Icons.cloud_upload,
|
iconData: Icons.cloud_upload,
|
||||||
|
|
@ -475,7 +475,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
||||||
if (!state.uiState.settingsUIState.isFiltered)
|
if (!state.uiState.settingsUIState.isFiltered)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 25, bottom: 10),
|
padding: const EdgeInsets.only(top: 25, bottom: 10),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
iconData: Icons.settings,
|
iconData: Icons.settings,
|
||||||
label: localization.configurePaymentTerms.toUpperCase(),
|
label: localization.configurePaymentTerms.toUpperCase(),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ class _InvoiceDesignState extends State<InvoiceDesign>
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 20, right: 16, bottom: 10, left: 16),
|
top: 20, right: 16, bottom: 10, left: 16),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.customizeAndPreview.toUpperCase(),
|
label: localization.customizeAndPreview.toUpperCase(),
|
||||||
iconData: Icons.settings,
|
iconData: Icons.settings,
|
||||||
onPressed: () => state.designState.customDesigns.isEmpty
|
onPressed: () => state.designState.customDesigns.isEmpty
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class _TaxSettingsState extends State<TaxSettings> {
|
||||||
if (!state.uiState.settingsUIState.isFiltered)
|
if (!state.uiState.settingsUIState.isFiltered)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
iconData: Icons.settings,
|
iconData: Icons.settings,
|
||||||
label: localization.configureRates.toUpperCase(),
|
label: localization.configureRates.toUpperCase(),
|
||||||
onPressed: () => viewModel.onConfigureRatesPressed(context),
|
onPressed: () => viewModel.onConfigureRatesPressed(context),
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
iconData: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
|
|
@ -154,7 +154,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
iconData: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class _VendorEditContactsState extends State<VendorEditContacts> {
|
||||||
..addAll(contacts)
|
..addAll(contacts)
|
||||||
..add(Padding(
|
..add(Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: ElevatedButton(
|
child: AppButton(
|
||||||
label: localization.addContact.toUpperCase(),
|
label: localization.addContact.toUpperCase(),
|
||||||
onPressed: () => viewModel.onAddContactPressed(),
|
onPressed: () => viewModel.onAddContactPressed(),
|
||||||
),
|
),
|
||||||
|
|
@ -233,7 +233,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(),
|
child: Container(),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
iconData: Icons.delete,
|
iconData: Icons.delete,
|
||||||
label: localization.remove,
|
label: localization.remove,
|
||||||
|
|
@ -248,7 +248,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 10.0,
|
width: 10.0,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
AppButton(
|
||||||
iconData: Icons.check_circle,
|
iconData: Icons.check_circle,
|
||||||
label: localization.done,
|
label: localization.done,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue