Tasks
This commit is contained in:
parent
97e772825f
commit
67d372f996
|
|
@ -14,6 +14,7 @@ const String kSharedPrefUrl = 'url';
|
|||
const String kSharedPrefSecret = 'secret';
|
||||
const String kSharedPrefEnableDarkMode = 'enable_dark_mode';
|
||||
const String kSharedPrefEmailPayment = 'email_payment';
|
||||
const String kSharedPrefManualTimer = 'manual_timer';
|
||||
const String kSharedPrefAppVersion = 'app_version';
|
||||
const String kSharedPrefRequireAuthentication = 'require_authentication';
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class TaskTime {
|
|||
abstract class TaskEntity extends Object
|
||||
with BaseEntity, SelectableEntity
|
||||
implements Built<TaskEntity, TaskEntityBuilder> {
|
||||
factory TaskEntity() {
|
||||
factory TaskEntity({bool isRunning = false}) {
|
||||
return _$TaskEntity._(
|
||||
id: --TaskEntity.counter,
|
||||
description: '',
|
||||
|
|
@ -77,7 +77,9 @@ abstract class TaskEntity extends Object
|
|||
invoiceId: null,
|
||||
clientId: null,
|
||||
projectId: null,
|
||||
timeLog: '[[${(DateTime.now().millisecondsSinceEpoch / 1000).floor()},0]]',
|
||||
timeLog: isRunning
|
||||
? '[[${(DateTime.now().millisecondsSinceEpoch / 1000).floor()},0]]'
|
||||
: '',
|
||||
isRunning: false,
|
||||
customValue1: '',
|
||||
customValue2: '',
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ class LoadStaticSuccess {
|
|||
|
||||
class UserSettingsChanged implements PersistUI {
|
||||
UserSettingsChanged(
|
||||
{this.enableDarkMode, this.emailPayment, this.requireAuthentication});
|
||||
{this.enableDarkMode,
|
||||
this.emailPayment,
|
||||
this.requireAuthentication,
|
||||
this.manualTimer});
|
||||
|
||||
final bool enableDarkMode;
|
||||
final bool emailPayment;
|
||||
final bool requireAuthentication;
|
||||
final bool manualTimer;
|
||||
}
|
||||
|
||||
class LoadDataSuccess {
|
||||
|
|
|
|||
|
|
@ -47,13 +47,15 @@ void _loadAuthLocal(Store<AppState> store, dynamic action) async {
|
|||
|
||||
final bool enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false;
|
||||
final bool emailPayment = prefs.getBool(kSharedPrefEmailPayment) ?? false;
|
||||
final bool manualTimer = prefs.getBool(kSharedPrefManualTimer) ?? false;
|
||||
final bool requireAuthentication =
|
||||
prefs.getBool(kSharedPrefRequireAuthentication) ?? false;
|
||||
|
||||
store.dispatch(UserSettingsChanged(
|
||||
enableDarkMode: enableDarkMode,
|
||||
emailPayment: emailPayment,
|
||||
requireAuthentication: requireAuthentication));
|
||||
requireAuthentication: requireAuthentication,
|
||||
manualTimer: manualTimer));
|
||||
}
|
||||
|
||||
Middleware<AppState> _createLoginInit() {
|
||||
|
|
|
|||
|
|
@ -27,15 +27,14 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
|
|||
enableDarkMode: enableDarkMode ?? false,
|
||||
requireAuthentication: requireAuthentication ?? false,
|
||||
emailPayment: false,
|
||||
manualTimer: false,
|
||||
dashboardUIState: DashboardUIState(),
|
||||
productUIState: ProductUIState(),
|
||||
clientUIState: ClientUIState(),
|
||||
invoiceUIState: InvoiceUIState(),
|
||||
// STARTER: constructor - do not remove comment
|
||||
taskUIState: TaskUIState(),
|
||||
|
||||
projectUIState: ProjectUIState(),
|
||||
|
||||
paymentUIState: PaymentUIState(company),
|
||||
quoteUIState: QuoteUIState(),
|
||||
);
|
||||
|
|
@ -53,6 +52,8 @@ projectUIState: ProjectUIState(),
|
|||
|
||||
bool get emailPayment;
|
||||
|
||||
bool get manualTimer;
|
||||
|
||||
DashboardUIState get dashboardUIState;
|
||||
|
||||
ProductUIState get productUIState;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
|
|||
'emailPayment',
|
||||
serializers.serialize(object.emailPayment,
|
||||
specifiedType: const FullType(bool)),
|
||||
'manualTimer',
|
||||
serializers.serialize(object.manualTimer,
|
||||
specifiedType: const FullType(bool)),
|
||||
'dashboardUIState',
|
||||
serializers.serialize(object.dashboardUIState,
|
||||
specifiedType: const FullType(DashboardUIState)),
|
||||
|
|
@ -112,6 +115,10 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
|
|||
result.emailPayment = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
case 'manualTimer':
|
||||
result.manualTimer = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
case 'dashboardUIState':
|
||||
result.dashboardUIState.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(DashboardUIState))
|
||||
|
|
@ -168,6 +175,8 @@ class _$UIState extends UIState {
|
|||
@override
|
||||
final bool emailPayment;
|
||||
@override
|
||||
final bool manualTimer;
|
||||
@override
|
||||
final DashboardUIState dashboardUIState;
|
||||
@override
|
||||
final ProductUIState productUIState;
|
||||
|
|
@ -195,6 +204,7 @@ class _$UIState extends UIState {
|
|||
this.enableDarkMode,
|
||||
this.requireAuthentication,
|
||||
this.emailPayment,
|
||||
this.manualTimer,
|
||||
this.dashboardUIState,
|
||||
this.productUIState,
|
||||
this.clientUIState,
|
||||
|
|
@ -220,6 +230,9 @@ class _$UIState extends UIState {
|
|||
if (emailPayment == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'emailPayment');
|
||||
}
|
||||
if (manualTimer == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'manualTimer');
|
||||
}
|
||||
if (dashboardUIState == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'dashboardUIState');
|
||||
}
|
||||
|
|
@ -262,6 +275,7 @@ class _$UIState extends UIState {
|
|||
enableDarkMode == other.enableDarkMode &&
|
||||
requireAuthentication == other.requireAuthentication &&
|
||||
emailPayment == other.emailPayment &&
|
||||
manualTimer == other.manualTimer &&
|
||||
dashboardUIState == other.dashboardUIState &&
|
||||
productUIState == other.productUIState &&
|
||||
clientUIState == other.clientUIState &&
|
||||
|
|
@ -287,15 +301,20 @@ class _$UIState extends UIState {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
0,
|
||||
selectedCompanyIndex
|
||||
.hashCode),
|
||||
currentRoute.hashCode),
|
||||
enableDarkMode.hashCode),
|
||||
requireAuthentication.hashCode),
|
||||
currentRoute
|
||||
.hashCode),
|
||||
enableDarkMode
|
||||
.hashCode),
|
||||
requireAuthentication
|
||||
.hashCode),
|
||||
emailPayment.hashCode),
|
||||
manualTimer.hashCode),
|
||||
dashboardUIState.hashCode),
|
||||
productUIState.hashCode),
|
||||
clientUIState.hashCode),
|
||||
|
|
@ -315,6 +334,7 @@ class _$UIState extends UIState {
|
|||
..add('enableDarkMode', enableDarkMode)
|
||||
..add('requireAuthentication', requireAuthentication)
|
||||
..add('emailPayment', emailPayment)
|
||||
..add('manualTimer', manualTimer)
|
||||
..add('dashboardUIState', dashboardUIState)
|
||||
..add('productUIState', productUIState)
|
||||
..add('clientUIState', clientUIState)
|
||||
|
|
@ -354,6 +374,10 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
bool get emailPayment => _$this._emailPayment;
|
||||
set emailPayment(bool emailPayment) => _$this._emailPayment = emailPayment;
|
||||
|
||||
bool _manualTimer;
|
||||
bool get manualTimer => _$this._manualTimer;
|
||||
set manualTimer(bool manualTimer) => _$this._manualTimer = manualTimer;
|
||||
|
||||
DashboardUIStateBuilder _dashboardUIState;
|
||||
DashboardUIStateBuilder get dashboardUIState =>
|
||||
_$this._dashboardUIState ??= new DashboardUIStateBuilder();
|
||||
|
|
@ -415,6 +439,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
_enableDarkMode = _$v.enableDarkMode;
|
||||
_requireAuthentication = _$v.requireAuthentication;
|
||||
_emailPayment = _$v.emailPayment;
|
||||
_manualTimer = _$v.manualTimer;
|
||||
_dashboardUIState = _$v.dashboardUIState?.toBuilder();
|
||||
_productUIState = _$v.productUIState?.toBuilder();
|
||||
_clientUIState = _$v.clientUIState?.toBuilder();
|
||||
|
|
@ -453,6 +478,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
enableDarkMode: enableDarkMode,
|
||||
requireAuthentication: requireAuthentication,
|
||||
emailPayment: emailPayment,
|
||||
manualTimer: manualTimer,
|
||||
dashboardUIState: dashboardUIState.build(),
|
||||
productUIState: productUIState.build(),
|
||||
clientUIState: clientUIState.build(),
|
||||
|
|
|
|||
|
|
@ -235,7 +235,9 @@ class AppDrawer extends StatelessWidget {
|
|||
onTap: () => store.dispatch(ViewTaskList(context)),
|
||||
onCreateTap: () {
|
||||
navigator.pop();
|
||||
store.dispatch(EditTask(task: TaskEntity(), context: context));
|
||||
store.dispatch(EditTask(
|
||||
task: TaskEntity(isRunning: !state.uiState.manualTimer),
|
||||
context: context));
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
|
|
|||
|
|
@ -141,7 +141,9 @@ class _ClientViewState extends State<ClientView>
|
|||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
store.dispatch(EditTask(
|
||||
task: TaskEntity()
|
||||
task: TaskEntity(
|
||||
isRunning:
|
||||
!store.state.uiState.manualTimer)
|
||||
.rebuild((b) => b.clientId = client.id),
|
||||
context: context));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ class ProjectViewVM {
|
|||
},
|
||||
onAddTaskPressed: (context) => store.dispatch(EditTask(
|
||||
context: context,
|
||||
task: TaskEntity().rebuild((b) => b
|
||||
task: TaskEntity(isRunning: !state.uiState.manualTimer)
|
||||
.rebuild((b) => b
|
||||
..projectId = project.id
|
||||
..clientId = project.clientId))),
|
||||
onBackPressed: () {
|
||||
|
|
|
|||
|
|
@ -71,8 +71,10 @@ class TaskScreen extends StatelessWidget {
|
|||
//key: Key(TaskKeys.taskScreenFABKeyString),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
store.dispatch(
|
||||
EditTask(task: TaskEntity(), context: context));
|
||||
store.dispatch(EditTask(
|
||||
task: TaskEntity(
|
||||
isRunning: !store.state.uiState.manualTimer),
|
||||
context: context));
|
||||
},
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
|
|
|
|||
Loading…
Reference in New Issue