Add more prompts for review

This commit is contained in:
Hillel Coren 2023-03-01 23:31:05 +02:00
parent 0731b07847
commit 0ba5b435f9
8 changed files with 108 additions and 5 deletions

View File

@ -233,7 +233,7 @@ Future<AppState> _initialState(bool isTesting) async {
prefState = serializers.deserializeWith( prefState = serializers.deserializeWith(
PrefState.serializer, json.decode(prefString)); PrefState.serializer, json.decode(prefString));
} catch (e) { } catch (e) {
print('Failed to load prefs: $e'); print('## Error: Failed to load prefs: $e');
} }
} }

View File

@ -105,6 +105,10 @@ class DismissGatewayWarningPermanently implements PersistUI, PersistPrefs {}
class DismissReviewAppPermanently implements PersistUI, PersistPrefs {} class DismissReviewAppPermanently implements PersistUI, PersistPrefs {}
class DismissOneYearReviewAppPermanently implements PersistUI, PersistPrefs {}
class DismissTwoYearReviewAppPermanently implements PersistUI, PersistPrefs {}
class ViewMainScreen { class ViewMainScreen {
ViewMainScreen({this.addDelay = false}); ViewMainScreen({this.addDelay = false});

View File

@ -192,6 +192,14 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
return color.isNotEmpty; return color.isNotEmpty;
} }
bool get showReviewApp => !prefState.hideReviewApp && company.daysActive > 60;
bool get showOneYearReviewApp =>
!prefState.hideOneYearReviewApp && company.daysActive > 365;
bool get showTwoYearReviewApp =>
!prefState.hideTwoYearReviewApp && company.daysActive > 730;
Color get linkColor => prefState.enableDarkMode Color get linkColor => prefState.enableDarkMode
? convertHexStringToColor('#FFFFFF') ? convertHexStringToColor('#FFFFFF')
: accentColor; : accentColor;

View File

@ -67,6 +67,10 @@ PrefState prefReducer(
..hideGatewayWarning = ..hideGatewayWarning =
hideGatewayWarningReducer(state.hideGatewayWarning, action) hideGatewayWarningReducer(state.hideGatewayWarning, action)
..hideReviewApp = hideReviewAppReducer(state.hideReviewApp, action) ..hideReviewApp = hideReviewAppReducer(state.hideReviewApp, action)
..hideOneYearReviewApp =
hideOneYearReviewAppReducer(state.hideOneYearReviewApp, action)
..hideTwoYearReviewApp =
hideTwoYearReviewAppReducer(state.hideTwoYearReviewApp, action)
..textScaleFactor = textScaleFactorReducer(state.textScaleFactor, action) ..textScaleFactor = textScaleFactorReducer(state.textScaleFactor, action)
..isMenuVisible = menuVisibleReducer(state.isMenuVisible, action) ..isMenuVisible = menuVisibleReducer(state.isMenuVisible, action)
..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action) ..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action)
@ -253,6 +257,27 @@ Reducer<bool> hideReviewAppReducer = combineReducers([
TypedReducer<bool, DismissReviewAppPermanently>((filter, action) { TypedReducer<bool, DismissReviewAppPermanently>((filter, action) {
return true; return true;
}), }),
TypedReducer<bool, DismissOneYearReviewAppPermanently>((filter, action) {
return true;
}),
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]);
Reducer<bool> hideOneYearReviewAppReducer = combineReducers([
TypedReducer<bool, DismissOneYearReviewAppPermanently>((filter, action) {
return true;
}),
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]);
Reducer<bool> hideTwoYearReviewAppReducer = combineReducers([
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]); ]);
Reducer<int> filterClearedAtReducer = combineReducers([ Reducer<int> filterClearedAtReducer = combineReducers([

View File

@ -40,6 +40,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
hideDesktopWarning: false, hideDesktopWarning: false,
hideGatewayWarning: false, hideGatewayWarning: false,
hideReviewApp: false, hideReviewApp: false,
hideOneYearReviewApp: false,
hideTwoYearReviewApp: false,
showKanban: false, showKanban: false,
showPdfPreview: true, showPdfPreview: true,
showPdfPreviewSideBySide: false, showPdfPreviewSideBySide: false,
@ -151,6 +153,10 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
bool get hideReviewApp; bool get hideReviewApp;
bool get hideOneYearReviewApp;
bool get hideTwoYearReviewApp;
bool get editAfterSaving; bool get editAfterSaving;
double get textScaleFactor; double get textScaleFactor;
@ -233,6 +239,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..hideDesktopWarning = false ..hideDesktopWarning = false
..hideGatewayWarning = false ..hideGatewayWarning = false
..hideReviewApp = false ..hideReviewApp = false
..hideOneYearReviewApp = false
..hideTwoYearReviewApp = false
..tapSelectedToEdit = false ..tapSelectedToEdit = false
..persistData = false ..persistData = false
..persistUI = true ..persistUI = true

View File

@ -200,6 +200,12 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'hideReviewApp', 'hideReviewApp',
serializers.serialize(object.hideReviewApp, serializers.serialize(object.hideReviewApp,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'hideOneYearReviewApp',
serializers.serialize(object.hideOneYearReviewApp,
specifiedType: const FullType(bool)),
'hideTwoYearReviewApp',
serializers.serialize(object.hideTwoYearReviewApp,
specifiedType: const FullType(bool)),
'editAfterSaving', 'editAfterSaving',
serializers.serialize(object.editAfterSaving, serializers.serialize(object.editAfterSaving,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
@ -349,6 +355,14 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.hideReviewApp = serializers.deserialize(value, result.hideReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'hideOneYearReviewApp':
result.hideOneYearReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'hideTwoYearReviewApp':
result.hideTwoYearReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'editAfterSaving': case 'editAfterSaving':
result.editAfterSaving = serializers.deserialize(value, result.editAfterSaving = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -658,6 +672,10 @@ class _$PrefState extends PrefState {
@override @override
final bool hideReviewApp; final bool hideReviewApp;
@override @override
final bool hideOneYearReviewApp;
@override
final bool hideTwoYearReviewApp;
@override
final bool editAfterSaving; final bool editAfterSaving;
@override @override
final double textScaleFactor; final double textScaleFactor;
@ -698,6 +716,8 @@ class _$PrefState extends PrefState {
this.hideDesktopWarning, this.hideDesktopWarning,
this.hideGatewayWarning, this.hideGatewayWarning,
this.hideReviewApp, this.hideReviewApp,
this.hideOneYearReviewApp,
this.hideTwoYearReviewApp,
this.editAfterSaving, this.editAfterSaving,
this.textScaleFactor, this.textScaleFactor,
this.sortFields, this.sortFields,
@ -757,6 +777,10 @@ class _$PrefState extends PrefState {
hideGatewayWarning, r'PrefState', 'hideGatewayWarning'); hideGatewayWarning, r'PrefState', 'hideGatewayWarning');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
hideReviewApp, r'PrefState', 'hideReviewApp'); hideReviewApp, r'PrefState', 'hideReviewApp');
BuiltValueNullFieldError.checkNotNull(
hideOneYearReviewApp, r'PrefState', 'hideOneYearReviewApp');
BuiltValueNullFieldError.checkNotNull(
hideTwoYearReviewApp, r'PrefState', 'hideTwoYearReviewApp');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
editAfterSaving, r'PrefState', 'editAfterSaving'); editAfterSaving, r'PrefState', 'editAfterSaving');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -806,6 +830,8 @@ class _$PrefState extends PrefState {
hideDesktopWarning == other.hideDesktopWarning && hideDesktopWarning == other.hideDesktopWarning &&
hideGatewayWarning == other.hideGatewayWarning && hideGatewayWarning == other.hideGatewayWarning &&
hideReviewApp == other.hideReviewApp && hideReviewApp == other.hideReviewApp &&
hideOneYearReviewApp == other.hideOneYearReviewApp &&
hideTwoYearReviewApp == other.hideTwoYearReviewApp &&
editAfterSaving == other.editAfterSaving && editAfterSaving == other.editAfterSaving &&
textScaleFactor == other.textScaleFactor && textScaleFactor == other.textScaleFactor &&
sortFields == other.sortFields && sortFields == other.sortFields &&
@ -845,6 +871,8 @@ class _$PrefState extends PrefState {
_$hash = $jc(_$hash, hideDesktopWarning.hashCode); _$hash = $jc(_$hash, hideDesktopWarning.hashCode);
_$hash = $jc(_$hash, hideGatewayWarning.hashCode); _$hash = $jc(_$hash, hideGatewayWarning.hashCode);
_$hash = $jc(_$hash, hideReviewApp.hashCode); _$hash = $jc(_$hash, hideReviewApp.hashCode);
_$hash = $jc(_$hash, hideOneYearReviewApp.hashCode);
_$hash = $jc(_$hash, hideTwoYearReviewApp.hashCode);
_$hash = $jc(_$hash, editAfterSaving.hashCode); _$hash = $jc(_$hash, editAfterSaving.hashCode);
_$hash = $jc(_$hash, textScaleFactor.hashCode); _$hash = $jc(_$hash, textScaleFactor.hashCode);
_$hash = $jc(_$hash, sortFields.hashCode); _$hash = $jc(_$hash, sortFields.hashCode);
@ -884,6 +912,8 @@ class _$PrefState extends PrefState {
..add('hideDesktopWarning', hideDesktopWarning) ..add('hideDesktopWarning', hideDesktopWarning)
..add('hideGatewayWarning', hideGatewayWarning) ..add('hideGatewayWarning', hideGatewayWarning)
..add('hideReviewApp', hideReviewApp) ..add('hideReviewApp', hideReviewApp)
..add('hideOneYearReviewApp', hideOneYearReviewApp)
..add('hideTwoYearReviewApp', hideTwoYearReviewApp)
..add('editAfterSaving', editAfterSaving) ..add('editAfterSaving', editAfterSaving)
..add('textScaleFactor', textScaleFactor) ..add('textScaleFactor', textScaleFactor)
..add('sortFields', sortFields) ..add('sortFields', sortFields)
@ -1032,6 +1062,16 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
set hideReviewApp(bool hideReviewApp) => set hideReviewApp(bool hideReviewApp) =>
_$this._hideReviewApp = hideReviewApp; _$this._hideReviewApp = hideReviewApp;
bool _hideOneYearReviewApp;
bool get hideOneYearReviewApp => _$this._hideOneYearReviewApp;
set hideOneYearReviewApp(bool hideOneYearReviewApp) =>
_$this._hideOneYearReviewApp = hideOneYearReviewApp;
bool _hideTwoYearReviewApp;
bool get hideTwoYearReviewApp => _$this._hideTwoYearReviewApp;
set hideTwoYearReviewApp(bool hideTwoYearReviewApp) =>
_$this._hideTwoYearReviewApp = hideTwoYearReviewApp;
bool _editAfterSaving; bool _editAfterSaving;
bool get editAfterSaving => _$this._editAfterSaving; bool get editAfterSaving => _$this._editAfterSaving;
set editAfterSaving(bool editAfterSaving) => set editAfterSaving(bool editAfterSaving) =>
@ -1089,6 +1129,8 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_hideDesktopWarning = $v.hideDesktopWarning; _hideDesktopWarning = $v.hideDesktopWarning;
_hideGatewayWarning = $v.hideGatewayWarning; _hideGatewayWarning = $v.hideGatewayWarning;
_hideReviewApp = $v.hideReviewApp; _hideReviewApp = $v.hideReviewApp;
_hideOneYearReviewApp = $v.hideOneYearReviewApp;
_hideTwoYearReviewApp = $v.hideTwoYearReviewApp;
_editAfterSaving = $v.editAfterSaving; _editAfterSaving = $v.editAfterSaving;
_textScaleFactor = $v.textScaleFactor; _textScaleFactor = $v.textScaleFactor;
_sortFields = $v.sortFields.toBuilder(); _sortFields = $v.sortFields.toBuilder();
@ -1153,6 +1195,8 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, r'PrefState', 'hideDesktopWarning'), hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, r'PrefState', 'hideDesktopWarning'),
hideGatewayWarning: BuiltValueNullFieldError.checkNotNull(hideGatewayWarning, r'PrefState', 'hideGatewayWarning'), hideGatewayWarning: BuiltValueNullFieldError.checkNotNull(hideGatewayWarning, r'PrefState', 'hideGatewayWarning'),
hideReviewApp: BuiltValueNullFieldError.checkNotNull(hideReviewApp, r'PrefState', 'hideReviewApp'), hideReviewApp: BuiltValueNullFieldError.checkNotNull(hideReviewApp, r'PrefState', 'hideReviewApp'),
hideOneYearReviewApp: BuiltValueNullFieldError.checkNotNull(hideOneYearReviewApp, r'PrefState', 'hideOneYearReviewApp'),
hideTwoYearReviewApp: BuiltValueNullFieldError.checkNotNull(hideTwoYearReviewApp, r'PrefState', 'hideTwoYearReviewApp'),
editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, r'PrefState', 'editAfterSaving'), editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, r'PrefState', 'editAfterSaving'),
textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, r'PrefState', 'textScaleFactor'), textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, r'PrefState', 'textScaleFactor'),
sortFields: sortFields.build(), sortFields: sortFields.build(),

View File

@ -21,6 +21,7 @@ class _ReviewAppState extends State<ReviewApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state;
if (kIsWeb || isLinux()) { if (kIsWeb || isLinux()) {
return SizedBox(); return SizedBox();
@ -53,7 +54,13 @@ class _ReviewAppState extends State<ReviewApp> {
AppReview.openStoreListing(); AppReview.openStoreListing();
} }
store.dispatch(DismissReviewAppPermanently()); if (state.showTwoYearReviewApp) {
store.dispatch(DismissTwoYearReviewAppPermanently());
} else if (state.showOneYearReviewApp) {
store.dispatch(DismissOneYearReviewAppPermanently());
} else if (state.showReviewApp) {
store.dispatch(DismissReviewAppPermanently());
}
}, },
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100), constraints: const BoxConstraints(minWidth: 100),
@ -68,7 +75,13 @@ class _ReviewAppState extends State<ReviewApp> {
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
store.dispatch(DismissReviewAppPermanently()); if (state.showTwoYearReviewApp) {
store.dispatch(DismissTwoYearReviewAppPermanently());
} else if (state.showOneYearReviewApp) {
store.dispatch(DismissOneYearReviewAppPermanently());
} else if (state.showReviewApp) {
store.dispatch(DismissReviewAppPermanently());
}
}, },
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100), constraints: const BoxConstraints(minWidth: 100),

View File

@ -459,8 +459,9 @@ class DashboardPanels extends StatelessWidget {
case DashboardSections.messages: case DashboardSections.messages:
return Column( return Column(
children: [ children: [
if (!state.prefState.hideReviewApp && if (state.showReviewApp ||
state.company.daysActive > (isMobileOS() ? 60 : 120)) state.showOneYearReviewApp ||
state.showTwoYearReviewApp)
ReviewApp(), ReviewApp(),
if (state.userCompany.isAdmin && if (state.userCompany.isAdmin &&
state.company.daysActive < 30 && state.company.daysActive < 30 &&