Commit 68072d4
feat(bookmark): 空内容的书签点击后会直接浏览器打开 (#70)
* feat(bookmark): implement smart navigation for bookmark taps
This commit introduces a smarter navigation logic when a user taps on a bookmark card. The behavior is now determined by the availability of reading statistics, which serves as a proxy for whether the bookmark has content parsed and ready for reading within the app.
- If a bookmark has reading stats, tapping it will navigate to the in-app detail page.
- If a bookmark lacks reading stats (implying it might have empty content or hasn't been processed), it will open the URL directly in an external browser.
This change enhances the user experience by avoiding blank detail pages and providing immediate access to the content in the most appropriate way.
Comprehensive unit tests have been added for `BookmarksViewModel` and `DailyReadViewModel` to ensure the new decision logic and the navigation callback mechanism are working correctly.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: 移除未使用的导航异常类并简化代码
移除不再使用的 NavigationNeededException 类
简化 SnackBarHelper 的样式配置
将 getOrNull 替换为 getOrThrow 以提高代码健壮性
* refactor(bookmark_card): 使用 BookmarkDisplayModel 替换直接传递 Bookmark 对象
重构书签卡片组件,将直接传递的 Bookmark 对象改为使用 BookmarkDisplayModel 封装,统一数据传递方式
移除不再需要的 readingStats 参数,相关数据已包含在 BookmarkDisplayModel 中
更新相关测试用例以适应新的数据结构
* refactor(bookmark): 统一使用BookmarkDisplayModel替换Bookmark参数
修改所有相关组件、视图模型和测试,将Bookmark类型参数替换为BookmarkDisplayModel
更新相关命令和回调函数以保持一致
* refactor(书签操作): 将书签点击处理逻辑提取到用例中
将重复的书签点击处理逻辑从视图模型提取到 BookmarkOperationUseCases 中
统一处理书签点击后的导航和浏览器打开逻辑
* test(view_model): 完善DailyReadViewModel的测试覆盖
* test(bookmarks): 重构书签点击处理测试以使用新的用例方法
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8664175 commit 68072d4
File tree
15 files changed
+1577
-206
lines changed- lib
- data/repository/bookmark
- domain/use_cases
- ui
- bookmarks
- view_models
- widget
- core/ui
- daily_read
- view_models
- widgets
- test/ui
- bookmarks/view_models
- core/ui
- daily_read
- view_models
- widgets
15 files changed
+1577
-206
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
117 | 133 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
137 | 158 | | |
138 | 159 | | |
139 | 160 | | |
| |||
142 | 163 | | |
143 | 164 | | |
144 | 165 | | |
145 | | - | |
146 | | - | |
| 166 | + | |
| 167 | + | |
147 | 168 | | |
148 | 169 | | |
149 | 170 | | |
| |||
163 | 184 | | |
164 | 185 | | |
165 | 186 | | |
166 | | - | |
167 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
168 | 190 | | |
169 | 191 | | |
170 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
217 | 229 | | |
218 | 230 | | |
219 | 231 | | |
220 | | - | |
| 232 | + | |
221 | 233 | | |
| 234 | + | |
222 | 235 | | |
223 | | - | |
| 236 | + | |
224 | 237 | | |
225 | 238 | | |
226 | | - | |
| 239 | + | |
227 | 240 | | |
228 | 241 | | |
229 | 242 | | |
| |||
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | 250 | | |
247 | 251 | | |
248 | 252 | | |
249 | | - | |
| 253 | + | |
250 | 254 | | |
251 | 255 | | |
252 | 256 | | |
| |||
0 commit comments