Code refactor

This commit is contained in:
Hillel Coren 2020-07-16 20:23:17 +03:00
parent f78d1b812d
commit c2e3e46ac8
18 changed files with 33 additions and 33 deletions

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/ui/app/icon_text.dart';
class ElevatedButton extends StatelessWidget {
const ElevatedButton({
class AppButton extends StatelessWidget {
const AppButton({
@required this.label,
@required this.onPressed,
this.iconData,

View File

@ -42,7 +42,7 @@ class DocumentGrid extends StatelessWidget {
children: <Widget>[
if (!kIsWeb)
Expanded(
child: ElevatedButton(
child: AppButton(
iconData: Icons.camera_alt,
label: localization.takePicture,
onPressed: () async {
@ -59,7 +59,7 @@ class DocumentGrid extends StatelessWidget {
width: 14,
),
Expanded(
child: ElevatedButton(
child: AppButton(
iconData: Icons.insert_drive_file,
label: localization.uploadFile,
onPressed: () async {

View File

@ -151,7 +151,7 @@ class _DateRangePickerState extends State<DateRangePicker> {
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
ElevatedButton(
AppButton(
label: localization.done,
onPressed: () {
// TODO replace with form validation

View File

@ -25,7 +25,7 @@ class ProgressButton extends StatelessWidget {
child: CircularProgressIndicator(),
),
)
: ElevatedButton(
: AppButton(
width: double.infinity,
label: label,
onPressed: () => onPressed(),

View File

@ -224,7 +224,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
onTap: () => redeemPurchase(purchase),
)),
if (_purchases != null)
ElevatedButton(
AppButton(
label: _showPastPurchases
? localization.back
: localization.pastPurchases,

View File

@ -649,7 +649,7 @@ class _LoginState extends State<LoginView> {
if (isOneTimePassword && !viewModel.isLoading)
Padding(
padding: EdgeInsets.only(top: 12.0, bottom: 12.0),
child: ElevatedButton(
child: AppButton(
label: localization.cancel.toUpperCase(),
color: Colors.grey,
onPressed: () {

View File

@ -130,7 +130,7 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress> {
client.hasShippingAddress && client.areAddressesDifferent
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
child: AppButton(
label: localization.copyShipping.toUpperCase(),
onPressed: () {
viewModel.copyShippingAddress();

View File

@ -89,7 +89,7 @@ class _ClientEditContactsState extends State<ClientEditContacts> {
..addAll(contacts)
..add(Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
child: AppButton(
label: localization.addContact.toUpperCase(),
onPressed: () => viewModel.onAddContactPressed(),
),
@ -256,7 +256,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
Expanded(
child: Container(),
),
ElevatedButton(
AppButton(
color: Colors.red,
iconData: Icons.delete,
label: localization.remove,
@ -271,7 +271,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
SizedBox(
width: 10.0,
),
ElevatedButton(
AppButton(
iconData: Icons.check_circle,
label: localization.done,
onPressed: () {

View File

@ -127,7 +127,7 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
client.hasBillingAddress && client.areAddressesDifferent
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
child: AppButton(
label: localization.copyBilling.toUpperCase(),
onPressed: () {
viewModel.copyBillingAddress();

View File

@ -46,7 +46,7 @@ class _GroupViewState extends State<GroupView> {
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: localization.configureSettings.toUpperCase(),
iconData: Icons.settings,
onPressed: () =>

View File

@ -208,7 +208,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
AppButton(
color: Colors.red,
iconData: Icons.delete,
label: localization.remove,
@ -220,7 +220,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
SizedBox(
width: 10.0,
),
ElevatedButton(
AppButton(
iconData: Icons.check_circle,
label: localization.done,
onPressed: () {

View File

@ -285,7 +285,7 @@ class ReportsScreen extends StatelessWidget {
children: [
Builder(builder: (BuildContext context) {
return Expanded(
child: ElevatedButton(
child: AppButton(
label: localization.columns,
onPressed: () {
multiselectDialog(
@ -304,7 +304,7 @@ class ReportsScreen extends StatelessWidget {
}),
SizedBox(width: kGutterWidth),
Expanded(
child: ElevatedButton(
child: AppButton(
label: localization.export,
onPressed: () {
viewModel.onExportPressed(context);

View File

@ -132,7 +132,7 @@ class _AccountOverview extends StatelessWidget {
SizedBox(height: 14),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: localization.manageTokens.toUpperCase(),
iconData: getEntityIcon(EntityType.token),
onPressed: () {
@ -145,7 +145,7 @@ class _AccountOverview extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: localization.manageWebhooks.toUpperCase(),
iconData: getEntityIcon(EntityType.webhook),
onPressed: () {
@ -185,7 +185,7 @@ class _AccountOverview extends StatelessWidget {
*/
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: localization.purchaseLicense.toUpperCase(),
iconData: Icons.cloud_download,
onPressed: () async {
@ -197,7 +197,7 @@ class _AccountOverview extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: localization.applyLicense.toUpperCase(),
iconData: Icons.cloud_done,
onPressed: () {
@ -231,7 +231,7 @@ class _AccountOverview extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
child: AppButton(
label: companies.length == 1
? localization.cancelAccount.toUpperCase()
: localization.deleteCompany.toUpperCase(),

View File

@ -327,7 +327,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
children: <Widget>[
if ('${settings.companyLogo ?? ''}'.isNotEmpty) ...[
Expanded(
child: ElevatedButton(
child: AppButton(
width: double.infinity,
color: Colors.redAccent,
label: localization.delete,
@ -343,7 +343,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
SizedBox(width: 20),
],
Expanded(
child: ElevatedButton(
child: AppButton(
width: double.infinity,
label: localization.uploadLogo,
iconData: Icons.cloud_upload,
@ -475,7 +475,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
if (!state.uiState.settingsUIState.isFiltered)
Padding(
padding: const EdgeInsets.only(top: 25, bottom: 10),
child: ElevatedButton(
child: AppButton(
iconData: Icons.settings,
label: localization.configurePaymentTerms.toUpperCase(),
onPressed: () =>

View File

@ -115,7 +115,7 @@ class _InvoiceDesignState extends State<InvoiceDesign>
Padding(
padding: const EdgeInsets.only(
top: 20, right: 16, bottom: 10, left: 16),
child: ElevatedButton(
child: AppButton(
label: localization.customizeAndPreview.toUpperCase(),
iconData: Icons.settings,
onPressed: () => state.designState.customDesigns.isEmpty

View File

@ -119,7 +119,7 @@ class _TaxSettingsState extends State<TaxSettings> {
if (!state.uiState.settingsUIState.isFiltered)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
child: AppButton(
iconData: Icons.settings,
label: localization.configureRates.toUpperCase(),
onPressed: () => viewModel.onConfigureRatesPressed(context),

View File

@ -142,7 +142,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
AppButton(
color: Colors.red,
iconData: Icons.delete,
label: localization.remove,
@ -154,7 +154,7 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
SizedBox(
width: 10.0,
),
ElevatedButton(
AppButton(
iconData: Icons.check_circle,
label: localization.done,
onPressed: () {

View File

@ -85,7 +85,7 @@ class _VendorEditContactsState extends State<VendorEditContacts> {
..addAll(contacts)
..add(Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
child: AppButton(
label: localization.addContact.toUpperCase(),
onPressed: () => viewModel.onAddContactPressed(),
),
@ -233,7 +233,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
Expanded(
child: Container(),
),
ElevatedButton(
AppButton(
color: Colors.red,
iconData: Icons.delete,
label: localization.remove,
@ -248,7 +248,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
SizedBox(
width: 10.0,
),
ElevatedButton(
AppButton(
iconData: Icons.check_circle,
label: localization.done,
onPressed: () {