Skip to content

Commit 2db35ea

Browse files
author
Kamil Klyta
committed
Rename start and end edge into leading and trailing
1 parent be61abd commit 2db35ea

File tree

9 files changed

+69
-69
lines changed

9 files changed

+69
-69
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ The default value equals `0.1(6)`.
147147

148148
### trigger (IndicatorTrigger)
149149
Defines the trigger for the pull to refresh gesture.
150-
| value | Description |
151-
| ------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152-
| **startEdge** | Pull to refresh can be triggered only from the **start** edge of the list. Mostly top side, but can be bottom for reversed ListView (with *reverse* argument set to true). |
153-
| **endEdge** | Pull to refresh can be triggered only from the **end** edge of the list. Mostly bottom, but can be top for reversed ListView (with *reverse* argument set to true). |
154-
| **bothEdges** | Pull to refresh can be triggered from **both edges** of the list. |
150+
| value | Description |
151+
| ---------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152+
| **leadingEdge** | Pull to refresh can be triggered only from the **leading** edge of the list. Mostly top side, but can be bottom for reversed ListView (with *reverse* argument set to true). |
153+
| **trailingEdge** | Pull to refresh can be triggered only from the **trailing** edge of the list. Mostly bottom, but can be top for reversed ListView (with *reverse* argument set to true). |
154+
| **bothEdges** | Pull to refresh can be triggered from **both edges** of the list. |
155155

156156
### triggerMode (IndicatorTriggerMode)
157157
Configures how *CustomRefreshIndicator* widget can be triggered. Works in the same way as the triggerMode of the built-in *RefreshIndicator* widget.
@@ -177,7 +177,7 @@ Open the sample application and try it yourself ([online example](https://custom
177177

178178
[![Controller data example](readme/controller_data.gif)](https://custom-refresh-indicator.klyta.it/#/presentation)
179179

180-
### state
180+
### state (IndicatorState)
181181
The following table describes each state of the indicator controller.
182182

183183
| value | Description |

example/lib/indicators/swipe_action.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FetchMoreIndicator extends StatelessWidget {
1717
const height = 150.0;
1818
return CustomRefreshIndicator(
1919
onRefresh: () async => onAction(),
20-
trigger: IndicatorTrigger.endEdge,
20+
trigger: IndicatorTrigger.trailingEdge,
2121
trailingScrollIndicatorVisible: false,
2222
leadingScrollIndicatorVisible: true,
2323
child: child,

lib/src/controller.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ class IndicatorController extends ChangeNotifier {
8787
if (edge == null) return IndicatorSide.none;
8888
switch (direction) {
8989
case AxisDirection.up:
90-
return edge.isStart ? IndicatorSide.bottom : IndicatorSide.top;
90+
return edge.isLeading ? IndicatorSide.bottom : IndicatorSide.top;
9191
case AxisDirection.right:
92-
return edge.isStart ? IndicatorSide.left : IndicatorSide.right;
92+
return edge.isLeading ? IndicatorSide.left : IndicatorSide.right;
9393
case AxisDirection.down:
94-
return edge.isStart ? IndicatorSide.top : IndicatorSide.bottom;
94+
return edge.isLeading ? IndicatorSide.top : IndicatorSide.bottom;
9595
case AxisDirection.left:
96-
return edge.isStart ? IndicatorSide.right : IndicatorSide.left;
96+
return edge.isLeading ? IndicatorSide.right : IndicatorSide.left;
9797
}
9898
}
9999

lib/src/custom_refresh_indicator.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ typedef OnStateChanged = void Function(IndicatorStateChange change);
1616
extension on IndicatorTrigger {
1717
IndicatorEdge? get derivedEdge {
1818
switch (this) {
19-
case IndicatorTrigger.startEdge:
20-
return IndicatorEdge.start;
21-
case IndicatorTrigger.endEdge:
22-
return IndicatorEdge.end;
19+
case IndicatorTrigger.leadingEdge:
20+
return IndicatorEdge.leading;
21+
case IndicatorTrigger.trailingEdge:
22+
return IndicatorEdge.trailing;
2323

2424
/// In this case, the side is determined by the direction of the user's
2525
/// first scrolling gesture, not the trigger itself.
@@ -148,7 +148,7 @@ class CustomRefreshIndicator extends StatefulWidget {
148148
required this.onRefresh,
149149
required this.builder,
150150
this.controller,
151-
this.trigger = IndicatorTrigger.startEdge,
151+
this.trigger = IndicatorTrigger.leadingEdge,
152152
this.triggerMode = IndicatorTriggerMode.onEdge,
153153
this.notificationPredicate = defaultScrollNotificationPredicate,
154154
this.autoRebuild = true,
@@ -253,9 +253,9 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
253253
IndicatorTrigger trigger,
254254
) {
255255
switch (trigger) {
256-
case IndicatorTrigger.startEdge:
256+
case IndicatorTrigger.leadingEdge:
257257
return notification.metrics.extentBefore == 0;
258-
case IndicatorTrigger.endEdge:
258+
case IndicatorTrigger.trailingEdge:
259259
return notification.metrics.extentAfter == 0;
260260
case IndicatorTrigger.bothEdges:
261261
return notification.metrics.extentBefore == 0 ||
@@ -295,12 +295,12 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
295295
if (notification.metrics.extentBefore == 0 &&
296296
notification.scrollDelta!.isNegative) {
297297
controller
298-
..setIndicatorEdge(IndicatorEdge.start)
298+
..setIndicatorEdge(IndicatorEdge.leading)
299299
..setIndicatorState(IndicatorState.dragging);
300300
} else if (notification.metrics.extentAfter == 0 &&
301301
!notification.scrollDelta!.isNegative) {
302302
controller
303-
..setIndicatorEdge(IndicatorEdge.end)
303+
..setIndicatorEdge(IndicatorEdge.trailing)
304304
..setIndicatorState(IndicatorState.dragging);
305305
}
306306
}
@@ -313,7 +313,7 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
313313
/// Handle the indicator state depending on scrolling direction
314314
} else if (controller.state.isDragging || controller.state.isArmed) {
315315
switch (controller.edge) {
316-
case IndicatorEdge.start:
316+
case IndicatorEdge.leading:
317317
if (notification.metrics.extentBefore > 0.0) {
318318
_hide();
319319
} else {
@@ -323,7 +323,7 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
323323
}
324324
break;
325325

326-
case IndicatorEdge.end:
326+
case IndicatorEdge.trailing:
327327
if (notification.metrics.extentAfter > 0.0) {
328328
_hide();
329329
} else {
@@ -347,12 +347,12 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
347347
if (!controller.hasEdge) {
348348
controller.setIndicatorEdge(
349349
notification.overscroll.isNegative
350-
? IndicatorEdge.start
351-
: IndicatorEdge.end,
350+
? IndicatorEdge.leading
351+
: IndicatorEdge.trailing,
352352
);
353353
}
354354

355-
if (controller.edge!.isStart) {
355+
if (controller.edge!.isLeading) {
356356
_dragOffset -= notification.overscroll;
357357
} else {
358358
_dragOffset += notification.overscroll;

lib/src/data/indicator_edge.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
enum IndicatorEdge {
2-
start,
3-
end,
2+
leading,
3+
trailing,
44
}
55

66
extension IndicatorEdgeGetters on IndicatorEdge {
7-
bool get isEnd => this == IndicatorEdge.end;
8-
bool get isStart => this == IndicatorEdge.start;
7+
bool get isTrailing => this == IndicatorEdge.trailing;
8+
bool get isLeading => this == IndicatorEdge.leading;
99
}

lib/src/data/indicator_trigger_edge.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
/// {@endtemplate}
44
///
55
/// **startEdge**:
6-
/// {@macro custom_refresh_indicator.indicator_trigger.start}
6+
/// {@macro custom_refresh_indicator.indicator_trigger.leading}
77
///
88
/// **endEdge**:
9-
/// {@macro custom_refresh_indicator.indicator_trigger.end}
9+
/// {@macro custom_refresh_indicator.indicator_trigger.trailing}
1010
///
1111
/// **bothEdges**:
1212
/// {@macro custom_refresh_indicator.indicator_trigger.both}
1313
enum IndicatorTrigger {
14-
/// {@template custom_refresh_indicator.indicator_trigger.start}
15-
/// Pull to refresh can be triggered only from the **start** edge of the list.
14+
/// {@template custom_refresh_indicator.indicator_trigger.leading}
15+
/// Pull to refresh can be triggered only from the **leading** edge of the list.
1616
/// Mostly top side, but can be bottom for reversed ListView
1717
/// (with *reverse* argument set to true).
1818
/// {@endtemplate}
19-
startEdge,
19+
leadingEdge,
2020

21-
/// {@template custom_refresh_indicator.indicator_trigger.end}
22-
/// Pull to refresh can be triggered only from the **end** edge of the list.
21+
/// {@template custom_refresh_indicator.indicator_trigger.trailing}
22+
/// Pull to refresh can be triggered only from the **trailing** edge of the list.
2323
/// Mostly bottom, but can be top for reversed ListView
2424
/// (with *reverse* argument set to true).
2525
/// {@endtemplate}
26-
endEdge,
26+
trailingEdge,
2727

2828
/// {@template custom_refresh_indicator.indicator_trigger.both}
2929
/// Pull to refresh can be triggered from **both edges** of the list.

test/src/controller_test.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,61 +189,61 @@ void main() {
189189
});
190190

191191
group('IndicatorSide -', () {
192-
test('AxisDirection.up - start edge', () {
192+
test('AxisDirection.up - leading edge', () {
193193
final controller = IndicatorController()
194194
..setAxisDirection(AxisDirection.up)
195-
..setIndicatorEdge(IndicatorEdge.start);
195+
..setIndicatorEdge(IndicatorEdge.leading);
196196

197197
expect(controller.side, IndicatorSide.bottom);
198198
});
199-
test('AxisDirection.up - end edge', () {
199+
test('AxisDirection.up - trailing edge', () {
200200
final controller = IndicatorController()
201201
..setAxisDirection(AxisDirection.up)
202-
..setIndicatorEdge(IndicatorEdge.end);
202+
..setIndicatorEdge(IndicatorEdge.trailing);
203203

204204
expect(controller.side, IndicatorSide.top);
205205
});
206206

207-
test('AxisDirection.down - start edge', () {
207+
test('AxisDirection.down - leading edge', () {
208208
final controller = IndicatorController()
209209
..setAxisDirection(AxisDirection.down)
210-
..setIndicatorEdge(IndicatorEdge.start);
210+
..setIndicatorEdge(IndicatorEdge.leading);
211211

212212
expect(controller.side, IndicatorSide.top);
213213
});
214-
test('AxisDirection.down - end edge', () {
214+
test('AxisDirection.down - trailing edge', () {
215215
final controller = IndicatorController()
216216
..setAxisDirection(AxisDirection.down)
217-
..setIndicatorEdge(IndicatorEdge.end);
217+
..setIndicatorEdge(IndicatorEdge.trailing);
218218

219219
expect(controller.side, IndicatorSide.bottom);
220220
});
221221

222-
test('AxisDirection.left - start edge', () {
222+
test('AxisDirection.left - leading edge', () {
223223
final controller = IndicatorController()
224224
..setAxisDirection(AxisDirection.left)
225-
..setIndicatorEdge(IndicatorEdge.start);
225+
..setIndicatorEdge(IndicatorEdge.leading);
226226

227227
expect(controller.side, IndicatorSide.right);
228228
});
229-
test('AxisDirection.left - end edge', () {
229+
test('AxisDirection.left - trailing edge', () {
230230
final controller = IndicatorController()
231231
..setAxisDirection(AxisDirection.left)
232-
..setIndicatorEdge(IndicatorEdge.end);
232+
..setIndicatorEdge(IndicatorEdge.trailing);
233233

234234
expect(controller.side, IndicatorSide.left);
235235
});
236-
test('AxisDirection.right - start edge', () {
236+
test('AxisDirection.right - leading edge', () {
237237
final controller = IndicatorController()
238238
..setAxisDirection(AxisDirection.right)
239-
..setIndicatorEdge(IndicatorEdge.start);
239+
..setIndicatorEdge(IndicatorEdge.leading);
240240

241241
expect(controller.side, IndicatorSide.left);
242242
});
243-
test('AxisDirection.right - end edge', () {
243+
test('AxisDirection.right - trailing edge', () {
244244
final controller = IndicatorController()
245245
..setAxisDirection(AxisDirection.right)
246-
..setIndicatorEdge(IndicatorEdge.end);
246+
..setIndicatorEdge(IndicatorEdge.trailing);
247247

248248
expect(controller.side, IndicatorSide.right);
249249
});

test/src/custom_refresh_indicator_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void main() {
205205
expect(controller.value, equals(1.0));
206206
expect(controller.state, equals(IndicatorState.loading));
207207
expect(controller.hasEdge, isTrue);
208-
expect(controller.edge, IndicatorEdge.start);
208+
expect(controller.edge, IndicatorEdge.leading);
209209
expect(controller.side, IndicatorSide.top);
210210
expect(controller.direction, AxisDirection.down);
211211
expect(controller.scrollingDirection, ScrollDirection.forward);
@@ -235,7 +235,7 @@ void main() {
235235
expect(controller.value, equals(1.0));
236236
expect(controller.state, equals(IndicatorState.loading));
237237
expect(controller.hasEdge, isTrue);
238-
expect(controller.edge, IndicatorEdge.start);
238+
expect(controller.edge, IndicatorEdge.leading);
239239
expect(controller.side, IndicatorSide.bottom);
240240
expect(controller.direction, AxisDirection.up);
241241
expect(controller.scrollingDirection, ScrollDirection.forward);
@@ -885,7 +885,7 @@ void main() {
885885

886886
expect(indicatorController.value, greaterThan(0.0));
887887
expect(indicatorController.value, lessThanOrEqualTo(1.0));
888-
expect(indicatorController.edge, IndicatorEdge.start);
888+
expect(indicatorController.edge, IndicatorEdge.leading);
889889
expect(fakeRefresh.called, isTrue);
890890
// finish the indicator
891891
await tester.pump(const Duration(seconds: 1));
@@ -906,7 +906,7 @@ void main() {
906906

907907
expect(indicatorController.value, greaterThan(0.0));
908908
expect(indicatorController.value, lessThanOrEqualTo(1.0));
909-
expect(indicatorController.edge, IndicatorEdge.end);
909+
expect(indicatorController.edge, IndicatorEdge.trailing);
910910
expect(fakeRefresh.called, isTrue);
911911

912912
// finish the indicator
@@ -924,7 +924,7 @@ void main() {
924924
home: CustomRefreshIndicator(
925925
controller: indicatorController,
926926
builder: buildWithoutIndicator,
927-
trigger: IndicatorTrigger.endEdge,
927+
trigger: IndicatorTrigger.trailingEdge,
928928
onRefresh: fakeRefresh.instantRefresh,
929929
child: const DefaultList(itemsCount: 1),
930930
),
@@ -945,7 +945,7 @@ void main() {
945945

946946
expect(indicatorController.value, greaterThan(0.0));
947947
expect(indicatorController.value, lessThanOrEqualTo(1.0));
948-
expect(indicatorController.edge, IndicatorEdge.end);
948+
expect(indicatorController.edge, IndicatorEdge.trailing);
949949
expect(fakeRefresh.called, isTrue);
950950

951951
// finish the indicator
@@ -963,7 +963,7 @@ void main() {
963963
home: CustomRefreshIndicator(
964964
controller: indicatorController,
965965
builder: buildWithoutIndicator,
966-
trigger: IndicatorTrigger.startEdge,
966+
trigger: IndicatorTrigger.leadingEdge,
967967
onRefresh: fakeRefresh.instantRefresh,
968968
child: const DefaultList(itemsCount: 1),
969969
),
@@ -984,7 +984,7 @@ void main() {
984984

985985
expect(indicatorController.value, greaterThan(0.0));
986986
expect(indicatorController.value, lessThanOrEqualTo(1.0));
987-
expect(indicatorController.edge, IndicatorEdge.start);
987+
expect(indicatorController.edge, IndicatorEdge.leading);
988988
expect(fakeRefresh.called, isTrue);
989989
// finish the indicator
990990
await tester.pump(const Duration(seconds: 1));

test/src/data/indicator_edge_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import 'package:custom_refresh_indicator/src/data/indicator_edge.dart';
22
import 'package:flutter_test/flutter_test.dart';
33

44
void main() {
5-
test('IndicatorEdgeGetters - end', () async {
6-
const end = IndicatorEdge.end;
7-
expect(end.isStart, isFalse);
8-
expect(end.isEnd, isTrue);
5+
test('IndicatorEdgeGetters - trailing', () async {
6+
const end = IndicatorEdge.trailing;
7+
expect(end.isLeading, isFalse);
8+
expect(end.isTrailing, isTrue);
99
});
1010

11-
test('IndicatorEdgeGetters - start', () async {
12-
const start = IndicatorEdge.start;
13-
expect(start.isStart, isTrue);
14-
expect(start.isEnd, isFalse);
11+
test('IndicatorEdgeGetters - leading', () async {
12+
const start = IndicatorEdge.leading;
13+
expect(start.isLeading, isTrue);
14+
expect(start.isTrailing, isFalse);
1515
});
1616
}

0 commit comments

Comments
 (0)