Skip to content

Commit 3d97d8e

Browse files
committed
update: example
1 parent 077a013 commit 3d97d8e

File tree

4 files changed

+88
-5
lines changed

4 files changed

+88
-5
lines changed

example/lib/features/scene/detail/header/detail_header.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ enum DetailModuleType {
3232
module7,
3333
module8,
3434
}
35+
36+
enum DetailRefreshIndicatorType {
37+
none,
38+
footer,
39+
}

example/lib/features/scene/detail/state/detail_state_config.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,29 @@ mixin DetailStateForConfig {
1414

1515
List<DropdownMenuEntry<DetailModuleType>> get configDefaultAnchorEntries {
1616
List<DropdownMenuEntry<DetailModuleType>> entries = [];
17-
for (final DetailModuleType moduleType in DetailModuleType.values) {
17+
for (final moduleType in DetailModuleType.values) {
1818
entries.add(
19-
DropdownMenuEntry(value: moduleType, label: moduleType.name),
19+
DropdownMenuEntry(
20+
value: moduleType,
21+
label: moduleType.name,
22+
),
23+
);
24+
}
25+
return entries;
26+
}
27+
28+
DetailRefreshIndicatorType configRefreshIndicator =
29+
DetailRefreshIndicatorType.none;
30+
31+
List<DropdownMenuEntry<DetailRefreshIndicatorType>>
32+
get configRefreshIndicatorEntries {
33+
List<DropdownMenuEntry<DetailRefreshIndicatorType>> entries = [];
34+
for (final moduleType in DetailRefreshIndicatorType.values) {
35+
entries.add(
36+
DropdownMenuEntry(
37+
value: moduleType,
38+
label: moduleType.name,
39+
),
2040
);
2141
}
2242
return entries;

example/lib/features/scene/detail/widget/detail_config_view.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class _DetailConfigViewState extends State<DetailConfigView>
4949
return ListView(
5050
children: [
5151
_buildDefaultAnchor(),
52+
_buildRefreshPosition(),
5253
],
5354
);
5455
}
@@ -63,6 +64,22 @@ class _DetailConfigViewState extends State<DetailConfigView>
6364
if (module == null) return;
6465
state.configSelectedAnchor = module;
6566
},
67+
inputDecorationTheme: inputDecorationTheme(),
68+
),
69+
);
70+
}
71+
72+
Widget _buildRefreshPosition() {
73+
return ListTile(
74+
title: const Text('Refresh Indicator'),
75+
trailing: DropdownMenu<DetailRefreshIndicatorType>(
76+
initialSelection: state.configRefreshIndicator,
77+
dropdownMenuEntries: state.configRefreshIndicatorEntries,
78+
onSelected: (DetailRefreshIndicatorType? position) {
79+
if (position == null) return;
80+
state.configRefreshIndicator = position;
81+
},
82+
inputDecorationTheme: inputDecorationTheme(),
6683
),
6784
);
6885
}
@@ -78,6 +95,16 @@ class _DetailConfigViewState extends State<DetailConfigView>
7895
child: const Text('Confirm'),
7996
),
8097
);
98+
resultWidget = Container(
99+
margin: const EdgeInsets.only(bottom: 15),
100+
child: resultWidget,
101+
);
81102
return resultWidget;
82103
}
104+
105+
InputDecorationTheme inputDecorationTheme() {
106+
return const InputDecorationTheme(
107+
isCollapsed: true,
108+
);
109+
}
83110
}

example/lib/features/scene/detail/widget/detail_list_view.dart

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @Date: 2025-08-02 20:03:56
55
*/
66

7+
import 'package:easy_refresh/easy_refresh.dart';
78
import 'package:flutter/material.dart';
89
import 'package:scrollview_observer/scrollview_observer.dart';
910
import 'package:scrollview_observer_example/features/scene/detail/header/detail_header.dart';
@@ -33,11 +34,41 @@ class _DetailListViewState extends State<DetailListView>
3334

3435
@override
3536
Widget build(BuildContext context) {
37+
Widget resultWidget;
38+
39+
switch (state.configRefreshIndicator) {
40+
case DetailRefreshIndicatorType.none:
41+
resultWidget = _buildListView();
42+
break;
43+
case DetailRefreshIndicatorType.footer:
44+
resultWidget = EasyRefresh.builder(
45+
footer: const MaterialFooter(),
46+
onLoad: () async {
47+
await Future.delayed(const Duration(seconds: 2));
48+
},
49+
childBuilder: (context, physics) {
50+
return _buildListView(physics: physics);
51+
},
52+
);
53+
break;
54+
}
55+
56+
return resultWidget;
57+
}
58+
59+
Widget _buildListView({
60+
ScrollPhysics? physics,
61+
}) {
62+
ScrollPhysics _physics = ChatObserverClampingScrollPhysics(
63+
observer: state.keepPositionObserver,
64+
);
65+
if (physics != null) {
66+
_physics = physics.applyTo(_physics);
67+
}
68+
3669
Widget resultWidget = ListView.separated(
3770
controller: state.scrollController,
38-
physics: ChatObserverClampingScrollPhysics(
39-
observer: state.keepPositionObserver,
40-
),
71+
physics: _physics,
4172
itemBuilder: (context, index) {
4273
switch (moduleTypes[index]) {
4374
case DetailModuleType.module1:

0 commit comments

Comments
 (0)