@@ -7,6 +7,7 @@ import 'package:gsy_github_app_flutter/common/style/gsy_style.dart';
77import 'package:gsy_github_app_flutter/common/utils/common_utils.dart' ;
88import 'package:gsy_github_app_flutter/common/utils/event_utils.dart' ;
99import 'package:gsy_github_app_flutter/common/utils/navigator_utils.dart' ;
10+ import 'package:gsy_github_app_flutter/model/event.dart' ;
1011import 'package:gsy_github_app_flutter/model/repo_commit.dart' ;
1112import 'package:gsy_github_app_flutter/model/repository_ql.dart' ;
1213import 'package:gsy_github_app_flutter/page/repos/provider/repos_detail_provider.dart' ;
@@ -71,18 +72,29 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
7172 onPressed: () {
7273 RepoCommit model = pullLoadWidgetControl.dataList[index];
7374 NavigatorUtils .goPushDetailPage (
74- context, provider.userName, provider.reposName, model.sha, false );
75+ context,
76+ provider.userName,
77+ provider.reposName,
78+ model.sha,
79+ false ,
80+ );
7581 },
7682 needImage: false ,
7783 );
84+ } else if (selectIndex == 0 && item is Event ) {
85+ return GSYEventItem (
86+ EventViewModel .fromEventMap (pullLoadWidgetControl.dataList[index]),
87+ onPressed: () {
88+ EventUtils .ActionUtils (
89+ context,
90+ pullLoadWidgetControl.dataList[index],
91+ "${provider .userName }/${provider .reposName }" ,
92+ );
93+ },
94+ );
95+ } else {
96+ return const SizedBox ();
7897 }
79- return GSYEventItem (
80- EventViewModel .fromEventMap (pullLoadWidgetControl.dataList[index]),
81- onPressed: () {
82- EventUtils .ActionUtils (context, pullLoadWidgetControl.dataList[index],
83- "${provider .userName }/${provider .reposName }" );
84- },
85- );
8698 }
8799
88100 ///获取列表
@@ -102,9 +114,9 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
102114
103115 ///获取详情
104116 _getReposDetail () {
105- context
106- . read < ReposDetailProvider >()
107- . getRepositoryDetailRequest (_getBottomWidget );
117+ context. read < ReposDetailProvider >(). getRepositoryDetailRequest (
118+ _getBottomWidget,
119+ );
108120 }
109121
110122 ///绘制底部状态
@@ -115,26 +127,31 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
115127 : < Widget > [
116128 /// star
117129 _renderBottomItem (
118- provider.bottomModel! .starText, provider.bottomModel! .starIcon,
119- () {
120- CommonUtils .showLoadingDialog (context);
121- return provider.doRepositoryStarRequest ().then ((result) {
122- showRefreshLoading ();
123- var context = this .context;
124- if (! context.mounted) return ;
125- Navigator .pop (context);
126- });
127- }),
130+ provider.bottomModel! .starText,
131+ provider.bottomModel! .starIcon,
132+ () {
133+ CommonUtils .showLoadingDialog (context);
134+ return provider.doRepositoryStarRequest ().then ((result) {
135+ showRefreshLoading ();
136+ var context = this .context;
137+ if (! context.mounted) return ;
138+ Navigator .pop (context);
139+ });
140+ },
141+ ),
128142
129143 /// watch
130- _renderBottomItem (provider.bottomModel! .watchText,
131- provider.bottomModel! .watchIcon, () {
132- CommonUtils .showLoadingDialog (context);
133- return provider.doRepositoryWatchRequest ().then ((result) {
134- showRefreshLoading ();
135- Navigator .pop (context);
136- });
137- }),
144+ _renderBottomItem (
145+ provider.bottomModel! .watchText,
146+ provider.bottomModel! .watchIcon,
147+ () {
148+ CommonUtils .showLoadingDialog (context);
149+ return provider.doRepositoryWatchRequest ().then ((result) {
150+ showRefreshLoading ();
151+ Navigator .pop (context);
152+ });
153+ },
154+ ),
138155
139156 ///fork
140157 _renderBottomItem ("fork" , GSYICons .REPOS_ITEM_FORK , () {
@@ -151,16 +168,17 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
151168 ///绘制底部状态 item
152169 _renderBottomItem (var text, var icon, var onPressed) {
153170 return TextButton (
154- onPressed: onPressed,
155- child: GSYIConText (
156- icon,
157- text,
158- GSYConstant .smallText,
159- GSYColors .primaryValue,
160- 15.0 ,
161- padding: 5.0 ,
162- mainAxisAlignment: MainAxisAlignment .center,
163- ));
171+ onPressed: onPressed,
172+ child: GSYIConText (
173+ icon,
174+ text,
175+ GSYConstant .smallText,
176+ GSYColors .primaryValue,
177+ 15.0 ,
178+ padding: 5.0 ,
179+ mainAxisAlignment: MainAxisAlignment .center,
180+ ),
181+ );
164182 }
165183
166184 @override
@@ -205,14 +223,20 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
205223 scrollController: scrollController,
206224 headerSliverBuilder: (context, innerBoxIsScrolled) {
207225 return _sliverBuilder (
208- context, innerBoxIsScrolled, context.read <ReposDetailProvider >());
226+ context,
227+ innerBoxIsScrolled,
228+ context.read <ReposDetailProvider >(),
229+ );
209230 },
210231 );
211232 }
212233
213234 ///绘制内置Header,支持部分停靠支持
214- List <Widget > _sliverBuilder (BuildContext context, bool innerBoxIsScrolled,
215- ReposDetailProvider provider) {
235+ List <Widget > _sliverBuilder (
236+ BuildContext context,
237+ bool innerBoxIsScrolled,
238+ ReposDetailProvider provider,
239+ ) {
216240 return < Widget > [
217241 ///头部信息
218242 SliverPersistentHeader (
@@ -228,7 +252,10 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
228252 maxHeight: 1000 ,
229253 child: ReposHeaderItem (
230254 ReposHeaderViewModel .fromHttpMap (
231- provider.userName, provider.reposName, provider.repository),
255+ provider.userName,
256+ provider.reposName,
257+ provider.repository,
258+ ),
232259 layoutListener: (size) {
233260 setState (() {
234261 headerSize = size.height;
@@ -245,47 +272,54 @@ class ReposDetailInfoPageState extends State<ReposDetailInfoPage>
245272
246273 /// SliverPersistentHeaderDelegate 的实现
247274 delegate: GSYSliverHeaderDelegate (
248- maxHeight: 60 ,
249- minHeight: 60 ,
250- changeSize: true ,
251- vSyncs: this ,
252- snapConfig: FloatingHeaderSnapConfiguration (
253- curve: Curves .bounceInOut,
254- duration: const Duration (milliseconds: 10 ),
255- ),
256- builder: (BuildContext context, double shrinkOffset,
257- bool overlapsContent) {
258- ///根据数值计算偏差
259- var lr = 10 - shrinkOffset / 60 * 10 ;
260- var radius = Radius .circular (4 - shrinkOffset / 60 * 4 );
261- return SizedBox .expand (
262- child: Padding (
263- padding: EdgeInsets .only (bottom: 10 , left: lr, right: lr),
264- child: GSYSelectItemWidget (
265- [
266- context.l10n.repos_tab_activity,
267- context.l10n.repos_tab_commits,
268- ],
269- (index) {
270- ///切换时先滑动
271- scrollController
272- .animateTo (0 ,
275+ maxHeight: 60 ,
276+ minHeight: 60 ,
277+ changeSize: true ,
278+ vSyncs: this ,
279+ snapConfig: FloatingHeaderSnapConfiguration (
280+ curve: Curves .bounceInOut,
281+ duration: const Duration (milliseconds: 10 ),
282+ ),
283+ builder:
284+ (
285+ BuildContext context,
286+ double shrinkOffset,
287+ bool overlapsContent,
288+ ) {
289+ ///根据数值计算偏差
290+ var lr = 10 - shrinkOffset / 60 * 10 ;
291+ var radius = Radius .circular (4 - shrinkOffset / 60 * 4 );
292+ return SizedBox .expand (
293+ child: Padding (
294+ padding: EdgeInsets .only (bottom: 10 , left: lr, right: lr),
295+ child: GSYSelectItemWidget (
296+ [
297+ context.l10n.repos_tab_activity,
298+ context.l10n.repos_tab_commits,
299+ ],
300+ (index) {
301+ ///切换时先滑动
302+ scrollController
303+ .animateTo (
304+ 0 ,
273305 duration: const Duration (milliseconds: 200 ),
274- curve: Curves .bounceInOut)
275- .then ((_) {
276- selectIndex = index;
277- clearData ();
278- showRefreshLoading ();
279- });
280- },
281- margin: EdgeInsets .zero,
282- shape: RoundedRectangleBorder (
283- borderRadius: BorderRadius .all (radius),
306+ curve: Curves .bounceInOut,
307+ )
308+ .then ((_) {
309+ selectIndex = index;
310+ clearData ();
311+ showRefreshLoading ();
312+ });
313+ },
314+ margin: EdgeInsets .zero,
315+ shape: RoundedRectangleBorder (
316+ borderRadius: BorderRadius .all (radius),
317+ ),
284318 ),
285319 ),
286- ),
287- );
288- } ),
320+ );
321+ },
322+ ),
289323 ),
290324 ];
291325 }
0 commit comments