2018-10-27 14:27:41 +03:00
|
|
|
part of '../main.dart';
|
2018-10-25 00:05:29 +03:00
|
|
|
|
2018-10-27 17:28:47 +03:00
|
|
|
class ViewWidget extends StatefulWidget {
|
2018-10-27 00:54:05 +03:00
|
|
|
final HAView view;
|
2018-10-25 00:05:29 +03:00
|
|
|
|
2018-10-27 17:28:47 +03:00
|
|
|
const ViewWidget({
|
2018-10-25 00:05:29 +03:00
|
|
|
Key key,
|
|
|
|
this.view
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
2018-10-27 17:28:47 +03:00
|
|
|
return ViewWidgetState();
|
2018-10-25 00:05:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-10-27 17:28:47 +03:00
|
|
|
class ViewWidgetState extends State<ViewWidget> {
|
2018-10-25 00:05:29 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-02-10 22:33:46 +02:00
|
|
|
return ListView(
|
|
|
|
padding: EdgeInsets.all(0.0),
|
|
|
|
//physics: const AlwaysScrollableScrollPhysics(),
|
|
|
|
children: _buildChildren(context),
|
2018-10-25 00:05:29 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> _buildChildren(BuildContext context) {
|
|
|
|
List<Widget> result = [];
|
|
|
|
|
|
|
|
if (widget.view.badges.isNotEmpty) {
|
|
|
|
result.insert(0,
|
|
|
|
Wrap(
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
spacing: 10.0,
|
|
|
|
runSpacing: 1.0,
|
|
|
|
children: _buildBadges(context),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-02-10 22:33:46 +02:00
|
|
|
List<Widget> cards = [];
|
2018-10-27 00:54:05 +03:00
|
|
|
widget.view.cards.forEach((HACard card){
|
2019-02-10 22:33:46 +02:00
|
|
|
cards.add(
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxWidth: 500),
|
|
|
|
child: card.build(context),
|
|
|
|
)
|
2018-10-27 14:27:41 +03:00
|
|
|
);
|
2018-10-25 00:05:29 +03:00
|
|
|
});
|
|
|
|
|
2019-02-10 22:33:46 +02:00
|
|
|
result.add(
|
|
|
|
Column (
|
|
|
|
children: cards,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2018-10-25 00:05:29 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> _buildBadges(BuildContext context) {
|
|
|
|
List<Widget> result = [];
|
|
|
|
widget.view.badges.forEach((Entity entity) {
|
2018-10-25 00:13:50 +03:00
|
|
|
if (!entity.isHidden) {
|
|
|
|
result.add(entity.buildBadgeWidget(context));
|
|
|
|
}
|
2018-10-25 00:05:29 +03:00
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|