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

69 lines
1.6 KiB
Dart
Raw Normal View History

2019-09-15 20:23:03 +03:00
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;
2020-02-12 15:22:26 +02:00
response = await http.get("http://ha-client.app/service/whats_new_0.7.0.md");
2019-09-15 20:23:03 +03:00
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
);
}
}