Code clean up
This commit is contained in:
parent
75eaaea15f
commit
372932fdaf
|
|
@ -22,7 +22,6 @@ class ViewScaffold extends StatelessWidget {
|
|||
const ViewScaffold({
|
||||
@required this.body,
|
||||
@required this.entity,
|
||||
this.floatingActionButton,
|
||||
this.appBarBottom,
|
||||
this.isFilter = false,
|
||||
this.onBackPressed,
|
||||
|
|
@ -34,7 +33,6 @@ class ViewScaffold extends StatelessWidget {
|
|||
final BaseEntity entity;
|
||||
final Widget body;
|
||||
final Function onBackPressed;
|
||||
final Widget floatingActionButton;
|
||||
final Widget appBarBottom;
|
||||
final String title;
|
||||
final bool isEditable;
|
||||
|
|
|
|||
|
|
@ -198,98 +198,6 @@ class _ClientViewState extends State<ClientView>
|
|||
],
|
||||
);
|
||||
}),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'client_view_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
showDialog<SimpleDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => SimpleDialog(children: <Widget>[
|
||||
userCompany.canViewCreateOrEdit(EntityType.client)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.invoice),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
handleClientAction(
|
||||
context, [client], EntityAction.newInvoice);
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
userCompany.canViewCreateOrEdit(EntityType.payment)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.payment),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
handleClientAction(
|
||||
context, [client], EntityAction.newPayment);
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
userCompany.canViewCreateOrEdit(EntityType.quote)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.quote),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
handleClientAction(
|
||||
context, [client], EntityAction.newQuote);
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
userCompany.canViewCreateOrEdit(EntityType.project)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.project),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
handleClientAction(
|
||||
context, [client], EntityAction.newProject);
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
userCompany.canViewCreateOrEdit(EntityType.task)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.task),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
handleClientAction(
|
||||
context, [client], EntityAction.newTask);
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
userCompany.canViewCreateOrEdit(EntityType.expense)
|
||||
? ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.add_circle_outline),
|
||||
title: Text(localization.expense),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: ExpenseEntity(
|
||||
state: store.state,
|
||||
client: client,
|
||||
));
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
]),
|
||||
);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: localization.create,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,44 +161,6 @@ class _ExpenseViewState extends State<ExpenseView>
|
|||
],
|
||||
);
|
||||
}),
|
||||
floatingActionButton: viewModel.state.isEnterprisePlan
|
||||
? Builder(builder: (BuildContext context) {
|
||||
return FloatingActionButton(
|
||||
heroTag: 'expense_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () async {
|
||||
MultipartFile multipartFile;
|
||||
if (kIsWeb) {
|
||||
multipartFile = await pickFile();
|
||||
} else {
|
||||
final status = await Permission.camera.request();
|
||||
if (status == PermissionStatus.granted) {
|
||||
final image = await ImagePicker()
|
||||
.pickImage(source: ImageSource.camera);
|
||||
if (image != null && image.path != null) {
|
||||
final croppedFile = await ImageCropper()
|
||||
.cropImage(sourcePath: image.path);
|
||||
final bytes = await croppedFile.readAsBytes();
|
||||
multipartFile = MultipartFile.fromBytes('file', bytes,
|
||||
filename: image.path.split('/').last);
|
||||
}
|
||||
} else {
|
||||
openAppSettings();
|
||||
}
|
||||
}
|
||||
if (multipartFile != null) {
|
||||
viewModel.onUploadDocument(
|
||||
navigatorKey.currentContext, multipartFile);
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
Icons.camera_alt,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: localization.create,
|
||||
);
|
||||
})
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,16 +128,6 @@ class _ProjectViewState extends State<ProjectView>
|
|||
],
|
||||
);
|
||||
}),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'project_view_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () => viewModel.onAddTaskPressed(context),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: localization.newTask,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,21 +137,6 @@ class _TaskViewState extends State<TaskView>
|
|||
],
|
||||
);
|
||||
}),
|
||||
floatingActionButton: Builder(builder: (BuildContext context) {
|
||||
return task.isInvoiced || task.isDeleted
|
||||
? SizedBox()
|
||||
: FloatingActionButton(
|
||||
heroTag: 'task_view_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () => viewModel.onFabPressed(context),
|
||||
child: Icon(
|
||||
task.isRunning ? Icons.stop : Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip:
|
||||
task.isRunning ? localization.stop : localization.start,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,16 +172,6 @@ class _VendorViewState extends State<VendorView>
|
|||
],
|
||||
);
|
||||
}),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'vendor_view_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () => viewModel.onAddExpensePressed(context),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: localization.create,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue