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/pages/whats_new.page.dart
2020-05-06 18:19:41 +00:00

70 lines
1.5 KiB
Dart

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(whatsNewUrl);
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
);
}
}