This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/managers/startup_user_messages_manager.class.dart

71 lines
2.7 KiB
Dart
Raw Normal View History

2019-08-31 23:55:32 +03:00
part of '../main.dart';
class StartupUserMessagesManager {
static final StartupUserMessagesManager _instance = StartupUserMessagesManager
._internal();
factory StartupUserMessagesManager() {
return _instance;
}
StartupUserMessagesManager._internal() {}
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";
2019-09-09 14:24:54 +03:00
static final _whatsNewMessageKey = "user-message-shown-whats-new-660";
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() {
eventBus.fire(ShowPopupDialogEvent(
title: "What's new",
body: "You can now share any media url to HA Client via Android share menu. It will try to play that media on one of your media player. There is also 'tv' button available in app header if you want to send some url manually",
positiveText: "Full release notes",
negativeText: "Ok",
onPositive: () {
SharedPreferences.getInstance().then((prefs) {
prefs.setBool(_whatsNewMessageKey, true);
Launcher.launchURL("https://github.com/estevez-dev/ha_client/releases");
});
},
onNegative: () {
SharedPreferences.getInstance().then((prefs) {
prefs.setBool(_whatsNewMessageKey, true);
});
}
));
}
2019-08-31 23:55:32 +03:00
}