1
1
import 'dart:convert' ;
2
-
3
2
import 'package:clicli_grey/api/post.dart' ;
4
3
import 'package:clicli_grey/pages/player_page.dart' ;
5
4
import 'package:clicli_grey/utils/reg_utils.dart' ;
@@ -16,102 +15,96 @@ class RankPage extends StatefulWidget {
16
15
class _RankPageState extends State <RankPage > {
17
16
List rankList = [];
18
17
19
- Future < Object > getRankInfo () async {
18
+ getRankInfo () async {
20
19
rankList = jsonDecode ((await getRank ()).data)['posts' ];
21
- return rankList ;
20
+ setState (() {}) ;
22
21
}
23
22
24
23
toPlay (dynamic data) => Navigator .push (
25
24
context, MaterialPageRoute (builder: (_) => PlayerPage (data: data)));
26
25
27
26
@override
28
- Widget build (BuildContext context) => Scaffold (
29
- body: NestedScrollView (
30
- headerSliverBuilder: (_, __) => [
31
- SliverAppBar (
32
- pinned: true ,
33
- floating: true ,
34
- expandedHeight: 120 ,
35
- flexibleSpace: FlexibleSpaceBar (
36
- background: Image .network (
37
- getSuo (rankList.isNotEmpty ? rankList[0 ]['content' ] : '' ),
38
- fit: BoxFit .cover,
39
- ),
40
- ),
41
- title: Text (
42
- 'THE HOT TOP 10' ,
43
- style: Theme .of (context)
44
- .textTheme
45
- .headline6
46
- ? .copyWith (color: Colors .white),
47
- ),
48
- ),
49
- ],
50
- body: ListView .builder (
51
- padding: const EdgeInsets .all (10 ),
52
- itemCount: rankList.length,
53
- itemBuilder: (ctx, i) {
54
- return GestureDetector (
55
- onTap: () => toPlay (rankList[i]),
56
- child: Card (
57
- clipBehavior: Clip .antiAliasWithSaveLayer,
58
- margin: const EdgeInsets .symmetric (vertical: 4 ),
59
- child: IntrinsicHeight (
60
- child: Row (
61
- children: < Widget > [
62
- Padding (
63
- padding: const EdgeInsets .only (right: 15 ),
64
- child: ConstrainedBox (
65
- constraints: const BoxConstraints (minHeight: 120 ),
66
- child: Image (
67
- image:
68
- NetworkImage (getSuo (rankList[i]['content' ])),
69
- width: MediaQuery .of (context).size.width / 4 ,
70
- fit: BoxFit .cover,
71
- ),
72
- ),
27
+ void initState () {
28
+ super .initState ();
29
+ getRankInfo ();
30
+ }
31
+
32
+ @override
33
+ Widget build (BuildContext context) {
34
+ return Scaffold (
35
+ backgroundColor: const Color .fromRGBO (240 , 240 , 245 , 1 ),
36
+ appBar: AppBar (
37
+ backgroundColor: const Color .fromRGBO (240 , 240 , 245 , 1 ),
38
+ automaticallyImplyLeading: false ,
39
+ title: const Text ('排行榜' ,
40
+ style: TextStyle (
41
+ fontSize: 24 , color: Color .fromRGBO (148 , 107 , 230 , 1 ))),
42
+ centerTitle: false ,
43
+ ),
44
+ body: ListView .builder (
45
+ padding: const EdgeInsets .all (10 ),
46
+ itemCount: rankList.length,
47
+ itemBuilder: (ctx, i) {
48
+ return GestureDetector (
49
+ onTap: () => toPlay (rankList[i]),
50
+ child: Card (
51
+ clipBehavior: Clip .antiAliasWithSaveLayer,
52
+ margin: const EdgeInsets .symmetric (vertical: 4 ),
53
+ child: IntrinsicHeight (
54
+ child: Row (
55
+ children: < Widget > [
56
+ Padding (
57
+ padding: const EdgeInsets .only (right: 15 ),
58
+ child: ConstrainedBox (
59
+ constraints: const BoxConstraints (minHeight: 120 ),
60
+ child: Image (
61
+ image: NetworkImage (getSuo (rankList[i]['content' ])),
62
+ width: MediaQuery .of (context).size.width / 4 ,
63
+ fit: BoxFit .cover,
73
64
),
74
- Expanded (
75
- child: Column (
76
- crossAxisAlignment: CrossAxisAlignment .start,
77
- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
78
- children: < Widget > [
79
- Text (
80
- rankList[i]['title' ].trimLeft (),
81
- style: Theme .of (context).textTheme.subtitle1! ,
82
- maxLines: 1 ,
83
- overflow: TextOverflow .ellipsis,
84
- ),
85
- Text (
86
- rankList[i]['sort' ],
87
- style: TextStyle (
88
- color: Theme .of (context).primaryColor),
89
- ),
90
- Text (
91
- rankList[i]['tag' ].trim (),
92
- maxLines: 1 ,
93
- overflow: TextOverflow .ellipsis,
94
- style: Theme .of (context).textTheme.caption,
95
- ),
96
- ],
65
+ ),
66
+ ),
67
+ Expanded (
68
+ child: Column (
69
+ crossAxisAlignment: CrossAxisAlignment .start,
70
+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
71
+ children: < Widget > [
72
+ Text (
73
+ rankList[i]['title' ].trimLeft (),
74
+ style: Theme .of (context).textTheme.subtitle1! ,
75
+ maxLines: 1 ,
76
+ overflow: TextOverflow .ellipsis,
97
77
),
98
- ),
99
- MaterialButton (
100
- onPressed: () => toPlay (rankList[i]),
101
- minWidth: 30 ,
102
- child: SvgPicture .asset (
103
- 'assets/play_outline.svg' ,
104
- color: Theme .of (context).primaryColor,
105
- width: 25 ,
78
+ Text (
79
+ rankList[i]['sort' ],
80
+ style: TextStyle (
81
+ color: Theme .of (context).primaryColor),
82
+ ),
83
+ Text (
84
+ rankList[i]['tag' ].trim (),
85
+ maxLines: 1 ,
86
+ overflow: TextOverflow .ellipsis,
87
+ style: Theme .of (context).textTheme.caption,
106
88
),
107
- )
108
- ] ,
89
+ ],
90
+ ) ,
109
91
),
110
- ),
92
+ MaterialButton (
93
+ onPressed: () => toPlay (rankList[i]),
94
+ minWidth: 30 ,
95
+ child: SvgPicture .asset (
96
+ 'assets/play_outline.svg' ,
97
+ color: Theme .of (context).primaryColor,
98
+ width: 25 ,
99
+ ),
100
+ )
101
+ ],
111
102
),
112
- );
113
- },
114
- ),
115
- ),
116
- );
103
+ ),
104
+ ),
105
+ );
106
+ },
107
+ ),
108
+ );
109
+ }
117
110
}
0 commit comments