diff --git a/lib/entity_class/const.dart b/lib/entity_class/const.dart index 6047dc3..4d62311 100644 --- a/lib/entity_class/const.dart +++ b/lib/entity_class/const.dart @@ -94,4 +94,5 @@ class CardType { static const entityButton = "entity-button"; static const conditional = "conditional"; static const alarmPanel = "alarm-panel"; + static const markdown = "markdown"; } \ No newline at end of file diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index f29894c..845cf08 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -439,7 +439,8 @@ class HomeAssistant { showName: isThereCardOptionsInside ? rawCard["card"]['show_name'] ?? true : rawCard['show_name'] ?? true, showState: isThereCardOptionsInside ? rawCard["card"]['show_state'] ?? true : rawCard['show_state'] ?? true, showEmpty: rawCard['show_empty'] ?? true, - stateFilter: rawCard['state_filter'] ?? [] + stateFilter: rawCard['state_filter'] ?? [], + content: rawCard['content'] ); if (rawCard["cards"] != null) { card.childCards = _createLovelaceCards(rawCard["cards"]); diff --git a/lib/main.dart b/lib/main.dart index 581d635..6e53c1c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,7 @@ import 'package:http/http.dart' as http; import 'package:flutter_colorpicker/material_picker.dart'; import 'package:charts_flutter/flutter.dart' as charts; import 'package:progress_indicators/progress_indicators.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; part 'entity_class/const.dart'; part 'entity_class/entity.class.dart'; @@ -85,7 +86,7 @@ part 'ui_widgets/card_header_widget.dart'; EventBus eventBus = new EventBus(); const String appName = "HA Client"; -const appVersion = "0.3.13-82"; +const appVersion = "0.3.13-83"; String homeAssistantWebHost; diff --git a/lib/ui_class/card.class.dart b/lib/ui_class/card.class.dart index dad72da..c28073a 100644 --- a/lib/ui_class/card.class.dart +++ b/lib/ui_class/card.class.dart @@ -12,6 +12,7 @@ class HACard { bool showEmpty; int columnsCount; List stateFilter; + String content; HACard({ this.name, @@ -22,6 +23,7 @@ class HACard { this.showState: true, this.stateFilter: const [], this.showEmpty: true, + this.content, @required this.type }); diff --git a/lib/ui_class/sizes_class.dart b/lib/ui_class/sizes_class.dart index 69349ad..531f1a3 100644 --- a/lib/ui_class/sizes_class.dart +++ b/lib/ui_class/sizes_class.dart @@ -11,6 +11,7 @@ class Sizes { static const nameFontSize = 15.0; static const smallFontSize = 14.0; static const largeFontSize = 24.0; + static const mediumFontSize = 21.0; static const inputWidth = 160.0; static const rowPadding = 10.0; } \ No newline at end of file diff --git a/lib/ui_widgets/card_header_widget.dart b/lib/ui_widgets/card_header_widget.dart index 3b7e0b3..3f51f23 100644 --- a/lib/ui_widgets/card_header_widget.dart +++ b/lib/ui_widgets/card_header_widget.dart @@ -14,7 +14,7 @@ class CardHeaderWidget extends StatelessWidget { title: Text("$name", textAlign: TextAlign.left, overflow: TextOverflow.ellipsis, - style: new TextStyle(fontWeight: FontWeight.bold, fontSize: Sizes.largeFontSize)), + style: new TextStyle(fontSize: Sizes.mediumFontSize)), ); } else { result = new Container(width: 0.0, height: 0.0); diff --git a/lib/ui_widgets/card_widget.dart b/lib/ui_widgets/card_widget.dart index b3754fd..d79094a 100644 --- a/lib/ui_widgets/card_widget.dart +++ b/lib/ui_widgets/card_widget.dart @@ -33,6 +33,10 @@ class CardWidget extends StatelessWidget { return _buildEntityButtonCard(context); } + case CardType.markdown: { + return _buildMarkdownCard(context); + } + case CardType.horizontalStack: { if (card.childCards.isNotEmpty) { List children = []; @@ -109,6 +113,21 @@ class CardWidget extends StatelessWidget { ); } + Widget _buildMarkdownCard(BuildContext context) { + if (card.content == null) { + return Container(height: 0.0, width: 0.0,); + } + List body = []; + body.add(CardHeaderWidget(name: card.name)); + body.add(MarkdownBody(data: card.content)); + return Card( + child: Padding( + padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, Sizes.rowPadding), + child: new Column(mainAxisSize: MainAxisSize.min, children: body), + ) + ); + } + Widget _buildGlanceCard(BuildContext context) { List entitiesToShow = card.getEntitiesToShow(); if (entitiesToShow.isEmpty && !card.showEmpty) { diff --git a/pubspec.lock b/pubspec.lock index 5edccb5..e452479 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.7" args: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.1" crypto: dependency: transitive description: @@ -83,7 +83,7 @@ packages: description: path: "." ref: HEAD - resolved-ref: e26916e095244a7e5ea61315b030d298d127ed26 + resolved-ref: a7ed88a4793e094a4d5d5c2d88a89e55510accde url: "https://github.com/MarkOSullivan94/dart_config.git" source: git version: "0.5.0" @@ -93,7 +93,7 @@ packages: name: date_format url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.0.6" event_bus: dependency: "direct main" description: @@ -119,7 +119,7 @@ packages: name: flutter_colorpicker url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.2.1" flutter_launcher_icons: dependency: "direct dev" description: @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.0" + flutter_markdown: + dependency: "direct main" + description: + name: flutter_markdown + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" flutter_test: dependency: "direct dev" description: flutter @@ -138,7 +145,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0" + version: "0.12.0+1" http_parser: dependency: transitive description: @@ -167,6 +174,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.11.3+2" + markdown: + dependency: transitive + description: + name: markdown + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" matcher: dependency: transitive description: @@ -201,7 +215,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.0" progress_indicators: dependency: "direct main" description: @@ -262,7 +276,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "1.5.3+2" term_glyph: dependency: transitive description: @@ -290,7 +304,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.1.0+1" uuid: dependency: transitive description: @@ -318,7 +332,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.2.3" + version: "3.2.5" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 808a4b1..c657ad9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: hass_client description: Home Assistant Android Client -version: 0.3.13+82 +version: 0.3.13+83 environment: sdk: ">=2.0.0-dev.68.0 <3.0.0" @@ -18,6 +18,7 @@ dependencies: date_format: any flutter_colorpicker: any charts_flutter: any + flutter_markdown: any # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.