This commit is contained in:
Yegor Vialov 2018-11-03 22:50:21 +02:00
parent efab8b60b1
commit 3b99f4feeb
6 changed files with 215 additions and 239 deletions

View File

@ -17,7 +17,7 @@ class CombinedHistoryChartWidget extends StatefulWidget {
class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget> {
int _selectedId = -1;
List<charts.Series<CombinedEntityStateHistoryMoment, DateTime>> _parsedHistory;
List<charts.Series<EntityHistoryMoment, DateTime>> _parsedHistory;
@override
void initState() {
@ -46,7 +46,7 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CombinedHistoryControlWidget(
HistoryControlWidget(
selectedTimeStart: selectedTime,
selectedStates: selectedStates,
onPrevTap: () => _selectPrev(),
@ -93,13 +93,13 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
}
}
List<charts.Series<CombinedEntityStateHistoryMoment, DateTime>> _parseHistory() {
List<charts.Series<EntityHistoryMoment, DateTime>> _parseHistory() {
TheLogger.debug(" parsing history...");
Map<String, List<CombinedEntityStateHistoryMoment>> numericDataLists = {};
Map<String, List<EntityHistoryMoment>> numericDataLists = {};
int colorIdCounter = 0;
widget.config.numericAttributesToShow.forEach((String attrName) {
TheLogger.debug(" parsing attribute $attrName");
List<CombinedEntityStateHistoryMoment> data = [];
List<EntityHistoryMoment> data = [];
DateTime now = DateTime.now();
for (var i = 0; i < widget.rawHistory.length; i++) {
var stateData = widget.rawHistory[i];
@ -121,9 +121,28 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
hiddenLine = hiddenDot;
endTime = now;
}
data.add(CombinedEntityStateHistoryMoment(value, previousValue, hiddenDot, hiddenLine, stateData["state"], startTime, endTime, i, colorIdCounter));
data.add(EntityHistoryMoment(
value: value,
previousValue: previousValue,
hiddenDot: hiddenDot,
hiddenLine: hiddenLine,
state: stateData["state"],
startTime: startTime,
endTime: endTime,
id: i,
colorId: colorIdCounter
));
}
data.add(CombinedEntityStateHistoryMoment(data.last.value, data.last.previousValue, data.last.hiddenDot, data.last.hiddenLine, data.last.state, now, null, widget.rawHistory.length, colorIdCounter));
data.add(EntityHistoryMoment(
value: data.last.value,
previousValue: data.last.previousValue,
hiddenDot: data.last.hiddenDot,
hiddenLine: data.last.hiddenLine,
state: data.last.state,
startTime: now,
id: widget.rawHistory.length,
colorId: colorIdCounter
));
numericDataLists.addAll({attrName: data});
colorIdCounter += 1;
});
@ -131,14 +150,14 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
if ((_selectedId == -1) && (numericDataLists.isNotEmpty)) {
_selectedId = 0;
}
List<charts.Series<CombinedEntityStateHistoryMoment, DateTime>> result = [];
List<charts.Series<EntityHistoryMoment, DateTime>> result = [];
numericDataLists.forEach((attrName, dataList) {
TheLogger.debug(" adding ${dataList.length} data values");
result.add(
new charts.Series<CombinedEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: "value",
colorFn: (CombinedEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor("_", historyMoment.colorId),
radiusPxFn: (CombinedEntityStateHistoryMoment historyMoment, __) {
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor("_", historyMoment.colorId),
radiusPxFn: (EntityHistoryMoment historyMoment, __) {
if (historyMoment.hiddenDot) {
return 0.0;
} else if (historyMoment.id == _selectedId) {
@ -147,9 +166,9 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
return 1.0;
}
},
strokeWidthPxFn: (CombinedEntityStateHistoryMoment historyMoment, __) => historyMoment.hiddenLine ? 0.0 : 2.0,
domainFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.value ?? historyMoment.previousValue,
strokeWidthPxFn: (EntityHistoryMoment historyMoment, __) => historyMoment.hiddenLine ? 0.0 : 2.0,
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (EntityHistoryMoment historyMoment, _) => historyMoment.value ?? historyMoment.previousValue,
data: dataList,
/*domainLowerBoundFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.time.subtract(Duration(hours: 1)),
domainUpperBoundFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.time.add(Duration(hours: 1)),*/
@ -157,13 +176,13 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
);
});
result.add(
new charts.Series<CombinedEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: 'state',
radiusPxFn: (CombinedEntityStateHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 4.0,
colorFn: (CombinedEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.startTime,
domainLowerBoundFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.startTime,
domainUpperBoundFn: (CombinedEntityStateHistoryMoment historyMoment, _) => historyMoment.endTime ?? DateTime.now(),
radiusPxFn: (EntityHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 4.0,
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
domainLowerBoundFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
domainUpperBoundFn: (EntityHistoryMoment historyMoment, _) => historyMoment.endTime ?? DateTime.now(),
// No measure values are needed for symbol annotations.
measureFn: (_, __) => null,
data: numericDataLists[numericDataLists.keys.first],
@ -209,102 +228,3 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
}
}
}
class CombinedHistoryControlWidget extends StatelessWidget {
final Function onPrevTap;
final Function onNextTap;
final DateTime selectedTimeStart;
final DateTime selectedTimeEnd;
final List<String> selectedStates;
final List<int> colorIndexes;
const CombinedHistoryControlWidget({Key key, this.onPrevTap, this.onNextTap, this.selectedTimeStart, this.selectedTimeEnd, this.selectedStates, @ required this.colorIndexes}) : super(key: key);
@override
Widget build(BuildContext context) {
if (selectedTimeStart != null) {
return
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Icon(Icons.chevron_left),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onPrevTap,
),
Expanded(
child: Padding(
padding: EdgeInsets.only(right: 10.0),
child: _buildStates(),
),
),
_buildTime(),
IconButton(
icon: Icon(Icons.chevron_right),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onNextTap,
),
],
);
} else {
return Container(height: 48.0);
}
}
Widget _buildStates() {
List<Widget> children = [];
for (int i = 0; i < selectedStates.length; i++) {
children.add(
Text(
"${selectedStates[i] ?? '-'}",
textAlign: TextAlign.right,
style: TextStyle(
fontWeight: FontWeight.bold,
color: EntityColors.historyStateColor(selectedStates[i], colorIndexes[i]),
fontSize: 22.0
),
)
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: children,
);
}
Widget _buildTime() {
List<Widget> children = [];
children.add(
Text("${formatDate(selectedTimeStart, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
if (selectedTimeEnd != null) {
children.add(
Text("${formatDate(selectedTimeEnd, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children,
);
}
}
class CombinedEntityStateHistoryMoment {
final DateTime startTime;
final DateTime endTime;
final double value;
final double previousValue;
final int id;
final int colorId;
final String state;
final bool hiddenDot;
final bool hiddenLine;
CombinedEntityStateHistoryMoment(this.value, this.previousValue, this.hiddenDot, this.hiddenLine, this.state, this.startTime, this.endTime, this.id, this.colorId);
}

View File

@ -0,0 +1,25 @@
part of '../../main.dart';
class EntityHistoryMoment {
final DateTime startTime;
final DateTime endTime;
final double value;
final double previousValue;
final int id;
final int colorId;
final String state;
final bool hiddenDot;
final bool hiddenLine;
EntityHistoryMoment({
this.value,
this.previousValue,
this.hiddenDot,
this.hiddenLine,
this.state,
@required this.startTime,
this.endTime,
@required this.id,
this.colorId
});
}

View File

@ -0,0 +1,86 @@
part of '../../main.dart';
class HistoryControlWidget extends StatelessWidget {
final Function onPrevTap;
final Function onNextTap;
final DateTime selectedTimeStart;
final DateTime selectedTimeEnd;
final List<String> selectedStates;
final List<int> colorIndexes;
const HistoryControlWidget({Key key, this.onPrevTap, this.onNextTap, this.selectedTimeStart, this.selectedTimeEnd, this.selectedStates, @ required this.colorIndexes}) : super(key: key);
@override
Widget build(BuildContext context) {
if (selectedTimeStart != null) {
return
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Icon(Icons.chevron_left),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onPrevTap,
),
Expanded(
child: Padding(
padding: EdgeInsets.only(right: 10.0),
child: _buildStates(),
),
),
_buildTime(),
IconButton(
icon: Icon(Icons.chevron_right),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onNextTap,
),
],
);
} else {
return Container(height: 48.0);
}
}
Widget _buildStates() {
List<Widget> children = [];
for (int i = 0; i < selectedStates.length; i++) {
children.add(
Text(
"${selectedStates[i] ?? '-'}",
textAlign: TextAlign.right,
style: TextStyle(
fontWeight: FontWeight.bold,
color: EntityColors.historyStateColor(selectedStates[i], colorIndexes[i]),
fontSize: 22.0
),
)
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: children,
);
}
Widget _buildTime() {
List<Widget> children = [];
children.add(
Text("${formatDate(selectedTimeStart, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
if (selectedTimeEnd != null) {
children.add(
Text("${formatDate(selectedTimeEnd, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children,
);
}
}

View File

@ -17,7 +17,7 @@ class NumericStateHistoryChartWidget extends StatefulWidget {
class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChartWidget> {
int _selectedId = -1;
List<charts.Series<NumericEntityStateHistoryMoment, DateTime>> _parsedHistory;
List<charts.Series<EntityHistoryMoment, DateTime>> _parsedHistory;
@override
Widget build(BuildContext context) {
@ -25,7 +25,7 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
DateTime selectedTime;
double selectedState;
if ((_selectedId > -1) && (_parsedHistory != null) && (_parsedHistory.first.data.length >= (_selectedId + 1))) {
selectedTime = _parsedHistory.first.data[_selectedId].time;
selectedTime = _parsedHistory.first.data[_selectedId].startTime;
selectedState = _parsedHistory.first.data[_selectedId].value;
}
return Column(
@ -34,10 +34,10 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
children: <Widget>[
HistoryControlWidget(
selectedTimeStart: selectedTime,
selectedState: "${selectedState ?? '-'}",
selectedStates: ["${selectedState ?? '-'}"],
onPrevTap: () => _selectPrev(),
onNextTap: () => _selectNext(),
colorIndex: -1,
colorIndexes: [-1],
),
SizedBox(
height: 150.0,
@ -66,8 +66,8 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
);
}
List<charts.Series<NumericEntityStateHistoryMoment, DateTime>> _parseHistory() {
List<NumericEntityStateHistoryMoment> data = [];
List<charts.Series<EntityHistoryMoment, DateTime>> _parseHistory() {
List<EntityHistoryMoment> data = [];
DateTime now = DateTime.now();
for (var i = 0; i < widget.rawHistory.length; i++) {
var stateData = widget.rawHistory[i];
@ -85,21 +85,35 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
} else {
hiddenLine = hiddenDot;
}
data.add(NumericEntityStateHistoryMoment(value, previousValue, hiddenDot, hiddenLine, time, i));
data.add(EntityHistoryMoment(
value: value,
previousValue: previousValue,
hiddenDot: hiddenDot,
hiddenLine: hiddenLine,
startTime: time,
id: i
));
}
data.add(NumericEntityStateHistoryMoment(data.last.value, data.last.previousValue, data.last.hiddenDot, data.last.hiddenLine, now, widget.rawHistory.length));
data.add(EntityHistoryMoment(
value: data.last.value,
previousValue: data.last.previousValue,
hiddenDot: data.last.hiddenDot,
hiddenLine: data.last.hiddenLine,
startTime: now,
id: widget.rawHistory.length
));
if (_selectedId == -1) {
_selectedId = 0;
}
return [
new charts.Series<NumericEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: 'State',
colorFn: (NumericEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor("on", -1),
domainFn: (NumericEntityStateHistoryMoment historyMoment, _) => historyMoment.time,
measureFn: (NumericEntityStateHistoryMoment historyMoment, _) => historyMoment.value ?? historyMoment.previousValue,
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor("on", -1),
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (EntityHistoryMoment historyMoment, _) => historyMoment.value ?? historyMoment.previousValue,
data: data,
strokeWidthPxFn: (NumericEntityStateHistoryMoment historyMoment, __) => historyMoment.hiddenLine ? 0.0 : 2.0,
radiusPxFn: (NumericEntityStateHistoryMoment historyMoment, __) {
strokeWidthPxFn: (EntityHistoryMoment historyMoment, __) => historyMoment.hiddenLine ? 0.0 : 2.0,
radiusPxFn: (EntityHistoryMoment historyMoment, __) {
if (historyMoment.hiddenDot) {
return 0.0;
} else if (historyMoment.id == _selectedId) {
@ -144,14 +158,3 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
}
}
}
class NumericEntityStateHistoryMoment {
final DateTime time;
final double value;
final double previousValue;
final int id;
final bool hiddenDot;
final bool hiddenLine;
NumericEntityStateHistoryMoment(this.value, this.previousValue, this.hiddenDot, this.hiddenLine, this.time, this.id);
}

View File

@ -16,7 +16,7 @@ class SimpleStateHistoryChartWidget extends StatefulWidget {
class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartWidget> {
int _selectedId = -1;
List<charts.Series<SimpleEntityStateHistoryMoment, DateTime>> _parsedHistory;
List<charts.Series<EntityHistoryMoment, DateTime>> _parsedHistory;
@override
Widget build(BuildContext context) {
@ -36,10 +36,10 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
HistoryControlWidget(
selectedTimeStart: selectedTimeStart,
selectedTimeEnd: selectedTimeEnd,
selectedState: selectedState,
selectedStates: [selectedState],
onPrevTap: () => _selectPrev(),
onNextTap: () => _selectNext(),
colorIndex: _parsedHistory.first.data[_selectedId].colorId,
colorIndexes: [_parsedHistory.first.data[_selectedId].colorId],
),
SizedBox(
height: 70.0,
@ -70,8 +70,8 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
);
}
List<charts.Series<SimpleEntityStateHistoryMoment, DateTime>> _parseHistory() {
List<SimpleEntityStateHistoryMoment> data = [];
List<charts.Series<EntityHistoryMoment, DateTime>> _parseHistory() {
List<EntityHistoryMoment> data = [];
DateTime now = DateTime.now();
Map<String, int> cachedStates = {};
for (var i = 0; i < widget.rawHistory.length; i++) {
@ -86,35 +86,46 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
if (cachedStates[stateData["state"]] == null) {
cachedStates.addAll({"${stateData["state"]}": cachedStates.length});
}
data.add(SimpleEntityStateHistoryMoment(stateData["state"], startTime, endTime, i, cachedStates[stateData["state"]]));
data.add(EntityHistoryMoment(
state: stateData["state"],
startTime: startTime,
endTime: endTime,
id: i,
colorId: cachedStates[stateData["state"]]
));
}
data.add(SimpleEntityStateHistoryMoment(data.last.state, now, null, widget.rawHistory.length, data.last.colorId));
data.add(EntityHistoryMoment(
state: data.last.state,
startTime: now,
id: widget.rawHistory.length,
colorId: data.last.colorId
));
if (_selectedId == -1) {
_selectedId = 0;
}
return [
new charts.Series<SimpleEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: 'State',
strokeWidthPxFn: (SimpleEntityStateHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 6.0 : 3.0,
colorFn: (SimpleEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (SimpleEntityStateHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (SimpleEntityStateHistoryMoment historyMoment, _) => 10,
strokeWidthPxFn: (EntityHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 6.0 : 3.0,
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (EntityHistoryMoment historyMoment, _) => 10,
data: data,
),
new charts.Series<SimpleEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: 'State',
radiusPxFn: (SimpleEntityStateHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 3.0,
colorFn: (SimpleEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (SimpleEntityStateHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (SimpleEntityStateHistoryMoment historyMoment, _) => 10,
radiusPxFn: (EntityHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 3.0,
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.startTime,
measureFn: (EntityHistoryMoment historyMoment, _) => 10,
data: data,
)..setAttribute(charts.rendererIdKey, 'startValuePoints'),
new charts.Series<SimpleEntityStateHistoryMoment, DateTime>(
new charts.Series<EntityHistoryMoment, DateTime>(
id: 'State',
radiusPxFn: (SimpleEntityStateHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 3.0,
colorFn: (SimpleEntityStateHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (SimpleEntityStateHistoryMoment historyMoment, _) => historyMoment.endTime ?? DateTime.now(),
measureFn: (SimpleEntityStateHistoryMoment historyMoment, _) => 10,
radiusPxFn: (EntityHistoryMoment historyMoment, __) => (historyMoment.id == _selectedId) ? 5.0 : 3.0,
colorFn: (EntityHistoryMoment historyMoment, __) => EntityColors.chartHistoryStateColor(historyMoment.state, historyMoment.colorId),
domainFn: (EntityHistoryMoment historyMoment, _) => historyMoment.endTime ?? DateTime.now(),
measureFn: (EntityHistoryMoment historyMoment, _) => 10,
data: data,
)..setAttribute(charts.rendererIdKey, 'endValuePoints')
];
@ -153,78 +164,7 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
}
}
class HistoryControlWidget extends StatelessWidget {
final Function onPrevTap;
final Function onNextTap;
final DateTime selectedTimeStart;
final DateTime selectedTimeEnd;
final String selectedState;
final int colorIndex;
const HistoryControlWidget({Key key, this.onPrevTap, this.onNextTap, this.selectedTimeStart, this.selectedTimeEnd, this.selectedState, @ required this.colorIndex}) : super(key: key);
@override
Widget build(BuildContext context) {
if (selectedTimeStart != null) {
return
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Icon(Icons.chevron_left),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onPrevTap,
),
Expanded(
child: Padding(
padding: EdgeInsets.only(right: 10.0),
child: Text(
"${selectedState ?? '-'}",
textAlign: TextAlign.right,
style: TextStyle(
fontWeight: FontWeight.bold,
color: EntityColors.historyStateColor(selectedState, colorIndex),
fontSize: 22.0
),
),
),
),
_buildTime(),
IconButton(
icon: Icon(Icons.chevron_right),
padding: EdgeInsets.all(0.0),
iconSize: 40.0,
onPressed: onNextTap,
),
],
);
} else {
return Container(height: 48.0);
}
}
Widget _buildTime() {
List<Widget> children = [];
children.add(
Text("${formatDate(selectedTimeStart, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
if (selectedTimeEnd != null) {
children.add(
Text("${formatDate(selectedTimeEnd, [M, ' ', d, ', ', HH, ':', nn, ':', ss])}", textAlign: TextAlign.left,)
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children,
);
}
}
/*
class SimpleEntityStateHistoryMoment {
final DateTime startTime;
final DateTime endTime;
@ -233,4 +173,4 @@ class SimpleEntityStateHistoryMoment {
final int colorId;
SimpleEntityStateHistoryMoment(this.state, this.startTime, this.endTime, this.id, this.colorId);
}
}*/

View File

@ -42,6 +42,8 @@ part 'entity_widgets/history_chart/entity_history.dart';
part 'entity_widgets/history_chart/simple_state_history_chart.dart';
part 'entity_widgets/history_chart/numeric_state_history_chart.dart';
part 'entity_widgets/history_chart/combined_history_chart.dart';
part 'entity_widgets/history_chart/history_control_widget.dart';
part 'entity_widgets/history_chart/entity_history_moment.dart';
part 'entity_widgets/state/switch_state.dart';
part 'entity_widgets/state/slider_state.dart';
part 'entity_widgets/state/text_input_state.dart';