Skip to content

Commit a837552

Browse files
apoichetalexandre_poichet
andauthored
rename eco range to device range (#19)
Co-authored-by: alexandre_poichet <[email protected]>
1 parent 32d7bac commit a837552

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ also to offer a less energy-consuming app.
3333
| Free Memory | Yes | Yes | X | |
3434
| Total Storage | Yes | Yes | X | |
3535
| Free Storage | Yes | Yes | X | |
36-
| <span style="color: #3CB371">**Eco Range**</span> | <span style="color: #3CB371">Yes</span> | <span style="color: #3CB371">Yes</span> | <span style="color: #3CB371">X</span> | <span style="color: #3CB371">X</span> |
36+
| <span style="color: #3CB371">**Device Range**</span> | <span style="color: #3CB371">Yes</span> | <span style="color: #3CB371">Yes</span> | <span style="color: #3CB371">X</span> | <span style="color: #3CB371">X</span> |
3737
| Battery Thermal State | Yes | Yes | X | |
3838
| Battery State | Yes | Yes | X | X |
3939
| Battery Level | Yes | Yes | X | X |
@@ -42,7 +42,7 @@ also to offer a less energy-consuming app.
4242

4343
## Eco Mode
4444

45-
### Eco Range
45+
### Device Range
4646
This feature gives the possibility to calculate a score for the device.
4747
The score does NOT represent an ecological performance.
4848
It's just a score to determine the device's capacities.

example/lib/extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension FlutterEcoModeExtension on FlutterEcoMode {
2121
.map((value) => value > 0 ? "${value.toInt()} %" : "not reachable");
2222
}
2323

24-
extension FutureEcoRangeExtension on Future<EcoRange?> {
24+
extension FutureEcoRangeExtension on Future<DeviceRange?> {
2525
Future<String?> getScore() => then((value) =>
2626
value?.score != null ? "${(value!.score * 100).toInt()}/100" : null);
2727

example/lib/low_end_device/low_end_device_page.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class LowEndDevicePage extends StatefulWidget {
1414
}
1515

1616
class _LowEndDevicePageState extends State<LowEndDevicePage> {
17-
late Future<EcoRange?> ecoRange;
17+
late Future<DeviceRange?> deviceRange;
1818

1919
@override
2020
void initState() {
2121
super.initState();
22-
ecoRange = widget.ecoMode.getEcoRange();
22+
deviceRange = widget.ecoMode.getDeviceRange();
2323
}
2424

2525
@override
@@ -51,22 +51,22 @@ class _LowEndDevicePageState extends State<LowEndDevicePage> {
5151
future: widget.ecoMode.getFreeStorage,
5252
),
5353
ResultLine(
54-
label: 'Eco range score',
54+
label: 'Device range score',
5555
labelColor: Colors.blue,
5656
valueColor: Colors.blue,
57-
future: ecoRange.getScore,
57+
future: deviceRange.getScore,
5858
),
5959
ResultLine(
60-
label: 'Device eco range',
60+
label: 'Device range',
6161
labelColor: Colors.blue,
6262
valueColor: Colors.blue,
63-
future: ecoRange.getRange,
63+
future: deviceRange.getRange,
6464
),
6565
ResultLine(
6666
label: 'Is low end device',
6767
labelColor: Colors.purple,
6868
valueColor: Colors.purple,
69-
future: ecoRange.isLowEndDevice,
69+
future: deviceRange.isLowEndDevice,
7070
),
7171
],
7272
);

lib/flutter_eco_mode.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ class FlutterEcoMode extends FlutterEcoModePlatform {
103103
}
104104

105105
@override
106-
Future<EcoRange?> getEcoRange() async {
107-
return _api.getEcoScore().then<EcoRange?>((value) {
106+
Future<DeviceRange?> getDeviceRange() async {
107+
return _api.getEcoScore().then<DeviceRange?>((value) {
108108
if (value == null) {
109109
throw Exception('Error while getting eco score');
110110
}
111111
final range = _buildRange(value);
112-
return EcoRange(
112+
return DeviceRange(
113113
score: value,
114114
range: range,
115115
isLowEndDevice: range == DeviceEcoRange.lowEnd);

lib/flutter_eco_mode_platform_interface.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ abstract class FlutterEcoModePlatform extends PlatformInterface {
7070
Stream<bool?> get isBatteryEcoModeStream;
7171

7272
/// Return the eco range.
73-
Future<EcoRange?> getEcoRange();
73+
Future<DeviceRange?> getDeviceRange();
7474
}
7575

76-
class EcoRange {
76+
class DeviceRange {
7777
double score;
7878
DeviceEcoRange range;
7979
bool isLowEndDevice;
8080

81-
EcoRange({
81+
DeviceRange({
8282
required this.score,
8383
required this.range,
8484
this.isLowEndDevice = false,

test/flutter_eco_mode_test.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,45 +174,45 @@ void main() {
174174
});
175175

176176
group(
177-
'getEcoRange',
177+
'getDeviceRange',
178178
() {
179179
test('should return null when get eco score error', () async {
180180
when(() => ecoModeApi.getEcoScore())
181181
.thenAnswer((_) => Future.error('error eco score'));
182-
expect(await buildEcoMode().getEcoRange(), null);
182+
expect(await buildEcoMode().getDeviceRange(), null);
183183
});
184184

185185
test('should return null when get eco score null', () async {
186186
when(() => ecoModeApi.getEcoScore())
187187
.thenAnswer((_) => Future.value(null));
188-
expect(await buildEcoMode().getEcoRange(), null);
188+
expect(await buildEcoMode().getDeviceRange(), null);
189189
});
190190

191191
test('should return low end device', () async {
192192
when(() => ecoModeApi.getEcoScore())
193193
.thenAnswer((_) => Future.value(minScoreLowEndDevice));
194-
final ecoRange = await buildEcoMode().getEcoRange();
195-
expect(ecoRange!.score, minScoreLowEndDevice);
196-
expect(ecoRange.range, DeviceEcoRange.lowEnd);
197-
expect(ecoRange.isLowEndDevice, true);
194+
final deviceRange = await buildEcoMode().getDeviceRange();
195+
expect(deviceRange!.score, minScoreLowEndDevice);
196+
expect(deviceRange.range, DeviceEcoRange.lowEnd);
197+
expect(deviceRange.isLowEndDevice, true);
198198
});
199199

200200
test('should return mid range device', () async {
201201
when(() => ecoModeApi.getEcoScore())
202202
.thenAnswer((_) => Future.value(minScoreMidRangeDevice));
203-
final ecoRange = await buildEcoMode().getEcoRange();
204-
expect(ecoRange!.score, minScoreMidRangeDevice);
205-
expect(ecoRange.range, DeviceEcoRange.midRange);
206-
expect(ecoRange.isLowEndDevice, false);
203+
final deviceRange = await buildEcoMode().getDeviceRange();
204+
expect(deviceRange!.score, minScoreMidRangeDevice);
205+
expect(deviceRange.range, DeviceEcoRange.midRange);
206+
expect(deviceRange.isLowEndDevice, false);
207207
});
208208

209209
test('should return high end device', () async {
210210
when(() => ecoModeApi.getEcoScore())
211211
.thenAnswer((_) => Future.value(minScoreMidRangeDevice + 0.1));
212-
final ecoRange = await buildEcoMode().getEcoRange();
213-
expect(ecoRange!.score, minScoreMidRangeDevice + 0.1);
214-
expect(ecoRange.range, DeviceEcoRange.highEnd);
215-
expect(ecoRange.isLowEndDevice, false);
212+
final deviceRange = await buildEcoMode().getDeviceRange();
213+
expect(deviceRange!.score, minScoreMidRangeDevice + 0.1);
214+
expect(deviceRange.range, DeviceEcoRange.highEnd);
215+
expect(deviceRange.isLowEndDevice, false);
216216
});
217217
},
218218
);

0 commit comments

Comments
 (0)