Whats new page

This commit is contained in:
estevez-dev 2019-09-15 20:23:03 +03:00
parent bf6a52e0b9
commit 14958d9165
3 changed files with 76 additions and 18 deletions

View File

@ -128,6 +128,7 @@ part 'pages/play_media.page.dart';
part 'entities/entity_page_layout.widget.dart'; part 'entities/entity_page_layout.widget.dart';
part 'entities/media_player/widgets/media_player_seek_bar.widget.dart'; part 'entities/media_player/widgets/media_player_seek_bar.widget.dart';
part 'entities/media_player/widgets/media_player_progress_bar.widget.dart'; part 'entities/media_player/widgets/media_player_progress_bar.widget.dart';
part 'pages/whats_new.page.dart';
EventBus eventBus = new EventBus(); EventBus eventBus = new EventBus();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
@ -178,6 +179,7 @@ class HAClientApp extends StatelessWidget {
mediaType: "${ModalRoute.of(context).settings.arguments != null ? (ModalRoute.of(context).settings.arguments as Map)['type'] ?? '' : ''}", mediaType: "${ModalRoute.of(context).settings.arguments != null ? (ModalRoute.of(context).settings.arguments as Map)['type'] ?? '' : ''}",
), ),
"/log-view": (context) => LogViewPage(title: "Log"), "/log-view": (context) => LogViewPage(title: "Log"),
"/whats-new": (context) => WhatsNewPage(),
"/login": (context) => WebviewScaffold( "/login": (context) => WebviewScaffold(
url: "${ConnectionManager().oauthUrl}", url: "${ConnectionManager().oauthUrl}",
appBar: new AppBar( appBar: new AppBar(

View File

@ -14,7 +14,7 @@ class StartupUserMessagesManager {
bool _supportAppDevelopmentMessageShown; bool _supportAppDevelopmentMessageShown;
bool _whatsNewMessageShown; bool _whatsNewMessageShown;
static final _supportAppDevelopmentMessageKey = "user-message-shown-support-development_3"; static final _supportAppDevelopmentMessageKey = "user-message-shown-support-development_3";
static final _whatsNewMessageKey = "user-message-shown-whats-new-660"; static final _whatsNewMessageKey = "user-message-shown-whats-new-672";
void checkMessagesToShow() async { void checkMessagesToShow() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
@ -49,23 +49,10 @@ class StartupUserMessagesManager {
} }
void _showWhatsNewMessage() { void _showWhatsNewMessage() {
eventBus.fire(ShowPopupDialogEvent( SharedPreferences.getInstance().then((prefs) {
title: "What's new", prefs.setBool(_whatsNewMessageKey, true);
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", eventBus.fire(ShowPageEvent(path: "/whats-new"));
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);
});
}
));
} }
} }

View File

@ -0,0 +1,69 @@
part of '../main.dart';
class WhatsNewPage extends StatefulWidget {
WhatsNewPage({Key key}) : super(key: key);
@override
_WhatsNewPageState createState() => new _WhatsNewPageState();
}
class _WhatsNewPageState extends State<WhatsNewPage> {
String data = "";
String error = "";
@override
void initState() {
super.initState();
_loadData();
}
_loadData() async {
setState(() {
data = "";
error = "";
});
http.Response response;
response = await http.get("http://ha-client.homemade.systems/service/whats_new.md");
if (response.statusCode == 200) {
setState(() {
data = response.body;
});
} else {
setState(() {
error = "Can't load changelog";
});
}
}
@override
Widget build(BuildContext context) {
Widget body;
if (error.isNotEmpty) {
body = PageLoadingError(errorText: error,);
} else if (data.isEmpty) {
body = PageLoadingIndicator();
} else {
body = Markdown(
data: data,
);
}
return new Scaffold(
appBar: new AppBar(
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
Navigator.pop(context);
}),
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () => _loadData(),
)
],
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: new Text("What's new"),
),
body: body
);
}
}