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/cards/map_card.dart

88 lines
2.7 KiB
Dart
Raw Normal View History

2020-07-08 20:21:34 +03:00
part of '../main.dart';
2020-07-20 13:53:18 +03:00
class MapCard extends StatefulWidget {
2020-07-08 20:21:34 +03:00
final MapCardData card;
const MapCard({Key key, this.card}) : super(key: key);
2020-07-20 13:53:18 +03:00
@override
_MapCardState createState() => _MapCardState();
}
class _MapCardState extends State<MapCard> {
2020-07-22 13:32:34 +03:00
void _openMap(BuildContext context) {
Navigator.of(context).push(MaterialPageRoute(
builder: (bc) {
return Scaffold(
primary: false,
/*appBar: new AppBar(
backgroundColor: Colors.transparent,
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
Navigator.pop(context);
}),
actions: <Widget>[
IconButton(
icon: Icon(Icons.fullscreen),
onPressed: () {},
)
],
// 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("${widget.card.title ?? ""}"),
),*/
body: Container(
color: Theme.of(context).primaryColor,
child: SafeArea(
child: Stack(
children: <Widget>[
EntitiesMap(
entities: widget.card.entities,
interactive: true
),
Positioned(
top: 0,
left: 0,
child: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
Navigator.pop(context);
})
)
],
)
)
)
);
}
));
}
2020-07-08 20:21:34 +03:00
@override
Widget build(BuildContext context) {
return CardWrapper(
2020-07-20 13:53:18 +03:00
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
CardHeader(name: widget.card.title),
2020-07-22 13:32:34 +03:00
Stack(
children: <Widget>[
GestureDetector(
onTap: () => _openMap(context),
child: EntitiesMap(
aspectRatio: 1,
interactive: false,
entities: widget.card.entities,
)
),
Positioned(
bottom: 0,
left: 0,
child: Text('Tap to open interactive map', style: Theme.of(context).textTheme.caption)
)
],
),
2020-07-20 13:53:18 +03:00
],
2020-07-08 20:21:34 +03:00
)
);
}
}