2019-08-31 23:55:32 +03:00
part of ' ../main.dart ' ;
class StartupUserMessagesManager {
static final StartupUserMessagesManager _instance = StartupUserMessagesManager
. _internal ( ) ;
factory StartupUserMessagesManager ( ) {
return _instance ;
}
2020-02-12 23:13:49 +02:00
StartupUserMessagesManager . _internal ( ) ;
2019-08-31 23:55:32 +03:00
bool _supportAppDevelopmentMessageShown ;
2019-09-09 14:24:54 +03:00
bool _whatsNewMessageShown ;
2019-09-01 23:19:26 +03:00
static final _supportAppDevelopmentMessageKey = " user-message-shown-support-development_3 " ;
2020-04-29 00:43:48 +03:00
static final _whatsNewMessageKey = " user-message-shown-whats-new-894 " ;
2019-08-31 23:55:32 +03:00
void checkMessagesToShow ( ) async {
SharedPreferences prefs = await SharedPreferences . getInstance ( ) ;
await prefs . reload ( ) ;
_supportAppDevelopmentMessageShown = prefs . getBool ( _supportAppDevelopmentMessageKey ) ? ? false ;
2019-09-09 14:24:54 +03:00
_whatsNewMessageShown = prefs . getBool ( _whatsNewMessageKey ) ? ? false ;
if ( ! _whatsNewMessageShown ) {
_showWhatsNewMessage ( ) ;
} else if ( ! _supportAppDevelopmentMessageShown ) {
2019-08-31 23:55:32 +03:00
_showSupportAppDevelopmentMessage ( ) ;
}
}
void _showSupportAppDevelopmentMessage ( ) {
eventBus . fire ( ShowPopupDialogEvent (
title: " Hi! " ,
2019-09-05 00:09:40 +03:00
body: " As you may have noticed this app contains no ads. Also all app features are available for you for free. I'm not planning to change this in nearest future, but still you can support this application development materially. There is one-time payment available as well as several subscription options. Thanks. " ,
positiveText: " Show options " ,
negativeText: " Cancel " ,
2019-08-31 23:55:32 +03:00
onPositive: ( ) {
SharedPreferences . getInstance ( ) . then ( ( prefs ) {
prefs . setBool ( _supportAppDevelopmentMessageKey , true ) ;
2019-09-01 23:19:26 +03:00
eventBus . fire ( ShowPageEvent ( path: " /putchase " ) ) ;
2019-08-31 23:55:32 +03:00
} ) ;
} ,
onNegative: ( ) {
SharedPreferences . getInstance ( ) . then ( ( prefs ) {
prefs . setBool ( _supportAppDevelopmentMessageKey , true ) ;
} ) ;
}
) ) ;
}
2019-09-09 14:24:54 +03:00
void _showWhatsNewMessage ( ) {
2019-09-15 20:23:03 +03:00
SharedPreferences . getInstance ( ) . then ( ( prefs ) {
prefs . setBool ( _whatsNewMessageKey , true ) ;
eventBus . fire ( ShowPageEvent ( path: " /whats-new " ) ) ;
} ) ;
2019-09-09 14:24:54 +03:00
}
2019-08-31 23:55:32 +03:00
}