diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 86535e6..228db4c 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -15,15 +15,11 @@ dependencies: hmi_core: git: url: https://github.com/a-givertzman/hmi_core.git - ref: master + ref: 1.0.0 hmi_networking: git: url: https://github.com/a-givertzman/hmi_networking.git - ref: master - fl_chart: - git: - url: https://github.com/a-givertzman/fl_chart.git - ref: master + ref: 1.0.0 another_flushbar: ^1.12.29 dev_dependencies: diff --git a/lib/src/charts/crane_load_chart/crane_load_chart_legend_json.dart b/lib/src/charts/crane_load_chart/crane_load_chart_legend_json.dart index 8f1eef9..6031218 100644 --- a/lib/src/charts/crane_load_chart/crane_load_chart_legend_json.dart +++ b/lib/src/charts/crane_load_chart/crane_load_chart_legend_json.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/src/core/result_new/result.dart'; /// class CraneLoadChartLegendJson { final JsonList> _jsonList; @@ -11,6 +12,12 @@ class CraneLoadChartLegendJson { /// Future>>> get decoded { return _jsonList.decoded + .then((result) { + return switch(result) { + Ok(:final value) => value, + Err(:final error) => throw error, + }; + }) .then( (list) => list.fold>>>( { diff --git a/lib/src/charts/crane_load_chart/swl_data.dart b/lib/src/charts/crane_load_chart/swl_data.dart index 6eae9d8..c33213a 100644 --- a/lib/src/charts/crane_load_chart/swl_data.dart +++ b/lib/src/charts/crane_load_chart/swl_data.dart @@ -1,4 +1,5 @@ import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; /// class SwlData { static final _log = const Log('SwlData')..level = LogLevel.debug; @@ -34,6 +35,12 @@ class SwlData { /// Future> _loadAsset(TextFile textFile) { return textFile.content + .then((result) { + return switch(result) { + Ok(:final value) => value, + Err(:final error) => throw error, + }; + }) .then((value) { final doubleList = _parseStringList( value.replaceAll('\n', ';').replaceAll(',', '.').trim().split(';'), diff --git a/lib/src/edit_field/network_dropdown_field/oil_data.dart b/lib/src/edit_field/network_dropdown_field/oil_data.dart index 927b327..085b2f9 100644 --- a/lib/src/edit_field/network_dropdown_field/oil_data.dart +++ b/lib/src/edit_field/network_dropdown_field/oil_data.dart @@ -1,4 +1,5 @@ import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; /// /// Reads oil names and spec data for [SettingsPage] - HPU /// from assets json file @@ -16,6 +17,12 @@ class OilData { Future> names() async { if (_data.isEmpty) { await _jsonMap.decoded + .then((result) { + return switch(result) { + Ok(:final value) => value, + Err(:final error) => throw error, + }; + }) .then((value) => _data.addAll(value)) .onError((error, stackTrace) { throw Failure.unexpected( diff --git a/pubspec.yaml b/pubspec.yaml index 2e1d661..72079dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: hmi_widgets description: A Flutter package helps to visualize states, values, changes and other artefacts from technological processes. -version: 0.0.1 +version: 1.0.0 homepage: https://github.com/a-givertzman/hmi_widgets publish_to: none @@ -14,15 +14,15 @@ dependencies: fl_chart: git: url: https://github.com/a-givertzman/fl_chart.git - ref: master + ref: 0.63.0+2 hmi_core: git: url: https://github.com/a-givertzman/hmi_core.git - ref: master + ref: 1.0.0 hmi_networking: git: url: https://github.com/a-givertzman/hmi_networking.git - ref: master + ref: 1.0.0 another_flushbar: ^1.12.29 dev_dependencies: diff --git a/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/crane_load_chart_legend_json_decoded_test.dart b/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/crane_load_chart_legend_json_decoded_test.dart index 58ffd48..3f0e515 100644 --- a/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/crane_load_chart_legend_json_decoded_test.dart +++ b/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/crane_load_chart_legend_json_decoded_test.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; import 'package:hmi_widgets/src/charts/crane_load_chart/crane_load_chart_legend_json.dart'; import 'fake_json_list.dart'; void main() { @@ -61,7 +62,7 @@ void main() { for (final config in validLegendConfigs) { final list = config['list'] as List>; final legendJson = CraneLoadChartLegendJson( - jsonList: FakeJsonList(list), + jsonList: FakeJsonList(Ok(list)), ); final decodedLegend = await legendJson.decoded; expect( @@ -106,7 +107,7 @@ void main() { ]; for (final invalidConfig in invalidJsonConfigs) { final legendData = CraneLoadChartLegendJson( - jsonList: FakeJsonList(invalidConfig), + jsonList: FakeJsonList(Ok(invalidConfig)), ); expect( legendData.decoded, diff --git a/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/fake_json_list.dart b/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/fake_json_list.dart index 978811a..b2443de 100644 --- a/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/fake_json_list.dart +++ b/test/unit/charts/crane_load_chart/crane_load_chart_legend_json/fake_json_list.dart @@ -1,8 +1,9 @@ import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; /// class FakeJsonList implements JsonList { - final List _list; - const FakeJsonList(this._list); + final ResultF> _decodedResult; + const FakeJsonList(this._decodedResult); @override - Future> get decoded => Future.value(_list); + Future>> get decoded => Future.value(_decodedResult); } \ No newline at end of file diff --git a/test/unit/charts/crane_load_chart/swl_data/fake_text_file.dart b/test/unit/charts/crane_load_chart/swl_data/fake_text_file.dart index eb243ac..dd01b9d 100644 --- a/test/unit/charts/crane_load_chart/swl_data/fake_text_file.dart +++ b/test/unit/charts/crane_load_chart/swl_data/fake_text_file.dart @@ -1,9 +1,15 @@ import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; /// class FakeTextFile implements TextFile { - final String _content; - const FakeTextFile(this._content); + String contentText; + FakeTextFile(this.contentText); @override - Future get content => Future.value(_content); + Future> get content => Future.value(Ok(contentText)); + + @override + Future write(String text) async { + contentText = text; + } } \ No newline at end of file diff --git a/test/unit/edit_field/network_dropdown_field/oil_data/fake_json_map.dart b/test/unit/edit_field/network_dropdown_field/oil_data/fake_json_map.dart index dba1741..7b09da4 100644 --- a/test/unit/edit_field/network_dropdown_field/oil_data/fake_json_map.dart +++ b/test/unit/edit_field/network_dropdown_field/oil_data/fake_json_map.dart @@ -1,10 +1,11 @@ import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; /// class FakeJsonMap implements JsonMap { - final Map _decoded; + final ResultF> _decodedResult; /// - const FakeJsonMap(this._decoded); + const FakeJsonMap(this._decodedResult); // @override - Future> get decoded => Future.value(_decoded); + Future>> get decoded => Future.value(_decodedResult); } \ No newline at end of file diff --git a/test/unit/edit_field/network_dropdown_field/oil_data/oil_data_names_test.dart b/test/unit/edit_field/network_dropdown_field/oil_data/oil_data_names_test.dart index bda1cb3..2308ce9 100644 --- a/test/unit/edit_field/network_dropdown_field/oil_data/oil_data_names_test.dart +++ b/test/unit/edit_field/network_dropdown_field/oil_data/oil_data_names_test.dart @@ -1,5 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:hmi_core/hmi_core.dart'; +import 'package:hmi_core/hmi_core_result_new.dart'; import 'package:hmi_widgets/src/edit_field/network_dropdown_field/oil_data.dart'; import 'fake_json_map.dart'; void main() { @@ -57,7 +58,7 @@ void main() { final oilJsonMap = entry['json_map'] as Map>; final names = entry['names'] as List; final oilData = OilData( - jsonMap: FakeJsonMap(oilJsonMap), + jsonMap: FakeJsonMap(Ok(oilJsonMap)), ); expect(await oilData.names(), names); }