Skip to content

Commit dc80e43

Browse files
committed
add signals demo
1 parent 28321ad commit dc80e43

File tree

4 files changed

+177
-155
lines changed

4 files changed

+177
-155
lines changed

README.md

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
>
6060
> 6、 Redux:目前展示了全局登陆和用户信息等上面使用。
6161
>
62+
> 7、 Signals:目前用于 NotifyPage、RepositoryDetailFileListPage 页面内状态管理
63+
>
6264
> **列表显示有多个,其中:**
6365
>
6466
> 1、**gsy_pull_load_widget.dart.dart**
@@ -168,6 +170,10 @@
168170
│ │Common UI││ │Riverpod │ │ │ │
169171
│ └─────────┘│ └─────────┘ │ │ │
170172
│ │ │ │ │
173+
│ │ ┌─────────┐ │ │ │
174+
│ │ │ Signals │ │ │ │
175+
│ │ └─────────┘ │ │ │
176+
│ │ │ │ │
171177
└─────────────┴───────────────┴────────────────┴─────────────────┘
172178
```
173179

@@ -224,7 +230,7 @@ riverpod 页面内状态管理:
224230

225231
```
226232
┌───────────────────────────────────────────────────────────────────────────┐
227-
TrendPage Architecture
233+
Page Architecture Overview
228234
└───────────────────────────────────────────────────────────────────────────┘
229235
230236
@@ -236,71 +242,54 @@ riverpod 页面内状态管理:
236242
│ └───────────────────┘ └────────────────────┘ └────────────────────┘ │
237243
└───────────────────────────────────────────────────────────────────────────┘
238244
239-
240-
┌───────────────────────────────────────────────────────────────────────────┐
241-
│ TrendPage Specific State │
242-
├───────────────────────────────────────────────────────────────────────────┤
243-
│ │
244-
│ ┌─────────────────────────────────────────────────────────────────────┐ │
245-
│ │ Riverpod Providers │ │
246-
│ │ ┌───────────────────────────────┐ ┌─────────────────────────────┐ │ │
247-
│ │ │ trendFirstProvider │ │ trendSecondProvider │ │ │
248-
│ │ │ (Primary Data Source) │ │ (Secondary Data Source) │ │ │
249-
│ │ │ - Takes time & language params│ │ - Depends on firstProvider │ │ │
250-
│ │ │ - Fetches trending repos │ │ - Processes additional data │ │ │
251-
│ │ └───────────────────────────────┘ └─────────────────────────────┘ │ │
252-
│ └─────────────────────────────────────────────────────────────────────┘ │
253-
│ │ │
254-
│ ▼ │
255-
│ ┌─────────────────────────────────────────────────────────────────────┐ │
256-
│ │ Local State (StatefulWidget) │ │
257-
│ │ ┌───────────────────────────┐ ┌───────────────────────────────┐ │ │
258-
│ │ │ User Interface Controls │ │ Filter Parameters │ │ │
259-
│ │ │ - scrollController │ │ - selectTime (daily/weekly) │ │ │
260-
│ │ │ - _isOpen │ │ - selectType (language) │ │ │
261-
│ │ │ - refreshIndicatorKey │ │ - selectTimeIndex │ │ │
262-
│ │ └───────────────────────────┘ │ - selectTypeIndex │ │ │
263-
│ │ └───────────────────────────────┘ │ │
264-
│ └─────────────────────────────────────────────────────────────────────┘ │
265-
│ │ │
266-
│ ▼ │
267-
│ ┌─────────────────────────────────────────────────────────────────────┐ │
268-
│ │ Global State Flags │ │
269-
│ │ ┌───────────────────────────────┐ ┌─────────────────────────────┐ │ │
270-
│ │ │ trendLoadingState (boolean) │ │ trendRequestedState (bool) │ │ │
271-
│ │ │ - Tracks loading status │ │ - Tracks if data requested │ │ │
272-
│ │ └───────────────────────────────┘ └─────────────────────────────┘ │ │
273-
│ └─────────────────────────────────────────────────────────────────────┘ │
274-
│ │
275-
└───────────────────────────────────────────────────────────────────────────┘
276-
245+
┌────────────────┴────────────────┐
246+
▼ ▼
247+
┌─────────────────────────────────┐ ┌─────────────────────────────────────┐
248+
│ TrendPage (Riverpod) │ │ NotifyPage (Signals) │
249+
├─────────────────────────────────┤ ├─────────────────────────────────────┤
250+
│ │ │ │
251+
│┌─────────────────────────────┐ │ │┌───────────────────────────────────┐│
252+
││ Riverpod Providers │ │ ││ Signals State ││
253+
││┌───────────────────────────┐│ │ ││┌─────────────────────────────────┐││
254+
│││ trendFirstProvider ││ │ │││ notifySignal (List) │││
255+
│││ trendSecondProvider ││ │ │││ notifyIndexSignal (int) │││
256+
││└───────────────────────────┘│ │ │││ signalPage (int) │││
257+
│└─────────────────────────────┘ │ ││└─────────────────────────────────┘││
258+
│ │ │└───────────────────────────────────┘│
259+
│┌─────────────────────────────┐ │ │┌───────────────────────────────────┐│
260+
││ Local State (StatefulWidget)│ │ ││ SignalsMixin Processing ││
261+
││ - UI Controls │ │ ││ - createEffect() for reactions ││
262+
││ - Filter Parameters │ │ ││ - Manages data loading ││
263+
│└─────────────────────────────┘ │ ││ - Updates UI based on signals ││
264+
│ │ │└───────────────────────────────────┘│
265+
└─────────────────────────────────┘ └─────────────────────────────────────┘
266+
│ │
267+
└────────────────┬────────────────┘
277268
278269
┌───────────────────────────────────────────────────────────────────────────┐
279270
│ Data Layer │
280271
│ ┌───────────────────────────────────────────────────────────────────────┐ │
281-
│ │ ReposRepository │ │
272+
│ │ ReposRepository / UserRepository │ │
282273
│ │ ┌────────────────────────┐ ┌─────────────────────────────────┐ │ │
283-
│ │ │ Network Request │───┬──▶│ TrendRepositoryDbProvider │ │ │
284-
│ │ │ - API calls │ │ │ - Database caching │ │ │
285-
│ │ └────────────────────────┘ │ │ - Offline data retrieval │ │ │
286-
│ │ │ └─────────────────────────────────┘ │ │
274+
│ │ │ Network Request │───┬──▶│ Database Providers │ │ │
275+
│ │ │ - API calls │ │ │ - Data caching │ │ │
276+
│ │ └────────────────────────┘ │ └─────────────────────────────────┘ │ │
287277
│ │ │ │ │
288278
│ │ │ ┌─────────────────────────────────┐ │ │
289-
│ │ └──▶│ TrendingRepoModel │ │ │
290-
│ │ │ - Data model for trending repos │ │ │
279+
│ │ └──▶│ Data Models │ │ │
280+
│ │ │ - Structure definitions │ │ │
291281
│ │ └─────────────────────────────────┘ │ │
292282
│ └───────────────────────────────────────────────────────────────────────┘ │
293283
└───────────────────────────────────────────────────────────────────────────┘
294284
295285
296286
┌───────────────────────────────────────────────────────────────────────────┐
297287
│ UI Components │
298-
│ ┌────────────────────────────┐ ┌─────────────────────────┐ ┌───────────┐
299-
│ │ TrendTypeModel │ │ ReposViewModel │ │ ReposItem │
300-
│ │ - Filter options │ │ - UI data wrapper │ │ - UI │ │
301-
│ └────────────────────────────┘ └─────────────────────────┘ └───────────┘
288+
│ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────────
289+
│ │ View Models │ │ List Items │ │ Interactive UI │
290+
│ │ - Data Formatting │ │ - Item Rendering │ │ - User Actions
291+
│ └────────────────────┘ └────────────────────┘ └────────────────────
302292
└───────────────────────────────────────────────────────────────────────────┘
303-
304293
```
305294

306295
provider 页面内状态管理:

0 commit comments

Comments
 (0)