Showing
5 changed files
with
96 additions
and
36 deletions
... | @@ -9,7 +9,6 @@ import 'package:one_poem/tiktok/widgets/tiktok_top_info.dart'; | ... | @@ -9,7 +9,6 @@ import 'package:one_poem/tiktok/widgets/tiktok_top_info.dart'; |
9 | import 'package:one_poem/tiktok/widgets/tiktok_video.dart'; | 9 | import 'package:one_poem/tiktok/widgets/tiktok_video.dart'; |
10 | import 'package:one_poem/tiktok/widgets/tiktok_video_button_column.dart'; | 10 | import 'package:one_poem/tiktok/widgets/tiktok_video_button_column.dart'; |
11 | import 'package:one_poem/tiktok/widgets/tiktok_video_poem.dart'; | 11 | import 'package:one_poem/tiktok/widgets/tiktok_video_poem.dart'; |
12 | -import 'package:one_poem/util/toast_utils.dart'; | ||
13 | import 'package:one_poem/widgets/bars/home_action_bar.dart'; | 12 | import 'package:one_poem/widgets/bars/home_action_bar.dart'; |
14 | import 'package:one_poem/widgets/my_app_bar.dart'; | 13 | import 'package:one_poem/widgets/my_app_bar.dart'; |
15 | import 'package:video_player/video_player.dart'; | 14 | import 'package:video_player/video_player.dart'; | ... | ... |
... | @@ -66,6 +66,7 @@ class TikTokVidePoem extends StatelessWidget { | ... | @@ -66,6 +66,7 @@ class TikTokVidePoem extends StatelessWidget { |
66 | fontSize: 20.px), | 66 | fontSize: 20.px), |
67 | ), | 67 | ), |
68 | Container( | 68 | Container( |
69 | + padding: EdgeInsets.only(right: 5.px), | ||
69 | alignment: Alignment.centerRight, | 70 | alignment: Alignment.centerRight, |
70 | width: double.infinity, | 71 | width: double.infinity, |
71 | child: Text( | 72 | child: Text( | ... | ... |
... | @@ -5,7 +5,8 @@ import 'package:flutter/material.dart'; | ... | @@ -5,7 +5,8 @@ import 'package:flutter/material.dart'; |
5 | import 'package:flutter/services.dart'; | 5 | import 'package:flutter/services.dart'; |
6 | import 'package:one_poem/timeline/models/friend_entity.dart'; | 6 | import 'package:one_poem/timeline/models/friend_entity.dart'; |
7 | import 'package:one_poem/timeline/widgets/friend_cell.dart'; | 7 | import 'package:one_poem/timeline/widgets/friend_cell.dart'; |
8 | -import 'package:one_poem/timeline/widgets/header_view.dart'; | 8 | +import 'package:one_poem/widgets/bars/timeline_menu_bar.dart'; |
9 | +import 'package:one_poem/widgets/my_app_bar.dart'; | ||
9 | 10 | ||
10 | class TimelinesPage extends StatefulWidget { | 11 | class TimelinesPage extends StatefulWidget { |
11 | const TimelinesPage({Key? key}) : super(key: key); | 12 | const TimelinesPage({Key? key}) : super(key: key); |
... | @@ -14,11 +15,11 @@ class TimelinesPage extends StatefulWidget { | ... | @@ -14,11 +15,11 @@ class TimelinesPage extends StatefulWidget { |
14 | _TimelinesPageState createState() => _TimelinesPageState(); | 15 | _TimelinesPageState createState() => _TimelinesPageState(); |
15 | } | 16 | } |
16 | 17 | ||
17 | -class _TimelinesPageState extends State<TimelinesPage>{ | 18 | +class _TimelinesPageState extends State<TimelinesPage> { |
18 | final ScrollController _scrollController = ScrollController(); | 19 | final ScrollController _scrollController = ScrollController(); |
19 | double _opacity = 0; | 20 | double _opacity = 0; |
20 | 21 | ||
21 | - FriendEntity _friendmodelEntity = FriendEntity(); | 22 | + FriendEntity _friendModelEntity = FriendEntity(); |
22 | 23 | ||
23 | Future<String> loadAsset() async { | 24 | Future<String> loadAsset() async { |
24 | return await rootBundle.loadString('assets/data/Data.json'); | 25 | return await rootBundle.loadString('assets/data/Data.json'); |
... | @@ -28,59 +29,51 @@ class _TimelinesPageState extends State<TimelinesPage>{ | ... | @@ -28,59 +29,51 @@ class _TimelinesPageState extends State<TimelinesPage>{ |
28 | void initState() { | 29 | void initState() { |
29 | super.initState(); | 30 | super.initState(); |
30 | 31 | ||
31 | - loadAsset().then((value){ | 32 | + loadAsset().then((value) { |
32 | var json = jsonDecode(value); | 33 | var json = jsonDecode(value); |
33 | - _friendmodelEntity = FriendEntity.fromJson(json); | 34 | + _friendModelEntity = FriendEntity.fromJson(json); |
34 | setState(() {}); | 35 | setState(() {}); |
35 | }); | 36 | }); |
36 | 37 | ||
37 | - | ||
38 | _scrollController.addListener(() { | 38 | _scrollController.addListener(() { |
39 | - | 39 | + double alpha = _scrollController.offset / 200; |
40 | - double alph = _scrollController.offset/200; | 40 | + if (alpha < 0) { |
41 | - if (alph < 0) { | 41 | + alpha = 0; |
42 | - alph = 0; | 42 | + } else if (alpha > 1) { |
43 | - } else if (alph > 1) { | 43 | + alpha = 1; |
44 | - alph = 1; | ||
45 | } | 44 | } |
46 | setState(() { | 45 | setState(() { |
47 | - _opacity = alph; | 46 | + _opacity = alpha; |
48 | }); | 47 | }); |
49 | - | ||
50 | - | ||
51 | }); | 48 | }); |
52 | - | ||
53 | } | 49 | } |
54 | 50 | ||
55 | - Widget _mainListViewBuidler(BuildContext context , int index) { | 51 | + Widget _mainListViewBuilder(BuildContext context, int index) { |
56 | - return FriendCell(model: _friendmodelEntity.data[index],); | 52 | + return FriendCell( |
53 | + model: _friendModelEntity.data[index], | ||
54 | + ); | ||
57 | } | 55 | } |
58 | 56 | ||
59 | - | ||
60 | @override | 57 | @override |
61 | Widget build(BuildContext context) { | 58 | Widget build(BuildContext context) { |
62 | - | ||
63 | return Scaffold( | 59 | return Scaffold( |
64 | - body: Stack( | 60 | + appBar: const MyAppBar( |
65 | - children: <Widget>[ | 61 | + isBack: false, |
66 | - ListView( | 62 | + isTransparent: true, |
63 | + homeMenuHeader: TimelineMenuHeader(), | ||
64 | + ), | ||
65 | + body: ListView( | ||
67 | padding: const EdgeInsets.only(top: 0), | 66 | padding: const EdgeInsets.only(top: 0), |
68 | controller: _scrollController, | 67 | controller: _scrollController, |
69 | children: <Widget>[ | 68 | children: <Widget>[ |
70 | - const HeaderView(), | 69 | + ListView.builder( |
71 | - ListView.builder(padding: const EdgeInsets.only(top: 0), itemBuilder: _mainListViewBuidler , itemCount: _friendmodelEntity.data.length, shrinkWrap: true, physics:NeverScrollableScrollPhysics(),) | 70 | + padding: const EdgeInsets.only(top: 0), |
72 | - ], | 71 | + itemBuilder: _mainListViewBuilder, |
73 | - ), | 72 | + itemCount: _friendModelEntity.data.length, |
74 | - Opacity( | 73 | + shrinkWrap: true, |
75 | - opacity: _opacity, | 74 | + physics: const NeverScrollableScrollPhysics(), |
76 | - child: const CupertinoNavigationBar( | ||
77 | - middle: Text("临境|附近|新鲜"), | ||
78 | - | ||
79 | - ), | ||
80 | ) | 75 | ) |
81 | - | ||
82 | ], | 76 | ], |
83 | - | ||
84 | ), | 77 | ), |
85 | ); | 78 | ); |
86 | } | 79 | } | ... | ... |
This diff is collapsed. Click to expand it.
lib/widgets/bars/timeline_menu_bar.dart
0 → 100644
1 | +import 'package:flutter/material.dart'; | ||
2 | + | ||
3 | +class TimelineMenuHeader extends StatelessWidget { | ||
4 | + const TimelineMenuHeader({ | ||
5 | + Key? key, | ||
6 | + this.funcLeft, | ||
7 | + this.funcCenter, | ||
8 | + this.funcRight, | ||
9 | + }) : super(key: key); | ||
10 | + | ||
11 | + final Function? funcLeft; | ||
12 | + final Function? funcCenter; | ||
13 | + final Function? funcRight; | ||
14 | + | ||
15 | + @override | ||
16 | + Widget build(BuildContext context) { | ||
17 | + return Container( | ||
18 | + alignment: Alignment.center, | ||
19 | + margin: const EdgeInsets.symmetric(horizontal: 5.0), | ||
20 | + child: Row( | ||
21 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
22 | + mainAxisSize: MainAxisSize.min, | ||
23 | + //交叉轴的布局方式,对于column来说就是水平方向的布局方式 | ||
24 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
25 | + children: <Widget>[ | ||
26 | + SizedBox( | ||
27 | + width: 60.0, | ||
28 | + child: TextButton( | ||
29 | + onPressed: () => funcLeft!(), | ||
30 | + child: const Text( | ||
31 | + "临境", | ||
32 | + style: TextStyle(color: Colors.black54), | ||
33 | + ), | ||
34 | + ), | ||
35 | + ), | ||
36 | + const VerticalDivider( | ||
37 | + color: Colors.black54, | ||
38 | + width: 1.0, | ||
39 | + thickness: 1.0, | ||
40 | + indent: 16.0, | ||
41 | + endIndent: 16.0, | ||
42 | + ), | ||
43 | + TextButton( | ||
44 | + onPressed: () => funcCenter!(), | ||
45 | + child: const Text( | ||
46 | + "附近", | ||
47 | + style: TextStyle(color: Colors.black54), | ||
48 | + ), | ||
49 | + ), | ||
50 | + const VerticalDivider( | ||
51 | + color: Colors.black54, | ||
52 | + width: 1.0, | ||
53 | + thickness: 1.0, | ||
54 | + indent: 15.0, | ||
55 | + endIndent: 15.0, | ||
56 | + ), | ||
57 | + TextButton( | ||
58 | + onPressed: () => funcRight!(), | ||
59 | + child: const Text( | ||
60 | + "新鲜", | ||
61 | + style: TextStyle(color: Colors.black54), | ||
62 | + ), | ||
63 | + ), | ||
64 | + ], | ||
65 | + )); | ||
66 | + } | ||
67 | +} |
-
Please register or login to post a comment