Showing
4 changed files
with
20 additions
and
11 deletions
... | @@ -72,4 +72,7 @@ | ... | @@ -72,4 +72,7 @@ |
72 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | 72 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
73 | <uses-permission android:name="android.permission.CAMERA" /> | 73 | <uses-permission android:name="android.permission.CAMERA" /> |
74 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | 74 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> |
75 | + <uses-permission | ||
76 | + android:name="android.permission.QUERY_ALL_PACKAGES" | ||
77 | + tools:node="remove" /> | ||
75 | </manifest> | 78 | </manifest> | ... | ... |
... | @@ -23,7 +23,6 @@ class Home extends StatefulWidget { | ... | @@ -23,7 +23,6 @@ class Home extends StatefulWidget { |
23 | 23 | ||
24 | class HomeState extends State<Home> with WidgetsBindingObserver { | 24 | class HomeState extends State<Home> with WidgetsBindingObserver { |
25 | final PageController _controller = PageController(); | 25 | final PageController _controller = PageController(); |
26 | - | ||
27 | bool isLoading = false; | 26 | bool isLoading = false; |
28 | int currentId = 0; | 27 | int currentId = 0; |
29 | int currentPage = 0; | 28 | int currentPage = 0; |
... | @@ -32,6 +31,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -32,6 +31,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
32 | bool isFav = false; | 31 | bool isFav = false; |
33 | bool isPraise = false; | 32 | bool isPraise = false; |
34 | bool isSharing = false; | 33 | bool isSharing = false; |
34 | + int cate = 0; | ||
35 | 35 | ||
36 | late StreamSubscription bus; | 36 | late StreamSubscription bus; |
37 | List<Widget> videos = []; | 37 | List<Widget> videos = []; |
... | @@ -95,6 +95,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -95,6 +95,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
95 | : debugPrint("未获得授权:$permissions")); | 95 | : debugPrint("未获得授权:$permissions")); |
96 | }); | 96 | }); |
97 | _onRefresh(); | 97 | _onRefresh(); |
98 | + bus = eventBus.on<TransEvent>().listen((event) {}); | ||
98 | } | 99 | } |
99 | 100 | ||
100 | /// 下拉刷新方法,为list重新赋值 | 101 | /// 下拉刷新方法,为list重新赋值 |
... | @@ -103,7 +104,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -103,7 +104,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
103 | currentPage = 0; | 104 | currentPage = 0; |
104 | DioUtils.instance.asyncRequestNetwork<HomeEntity>( | 105 | DioUtils.instance.asyncRequestNetwork<HomeEntity>( |
105 | Method.get, | 106 | Method.get, |
106 | - HttpApi.home, | 107 | + cate == 0 ? HttpApi.home : HttpApi.fresh, |
107 | params: {'page_size': 80}, | 108 | params: {'page_size': 80}, |
108 | onSuccess: (data) { | 109 | onSuccess: (data) { |
109 | isLoading = false; | 110 | isLoading = false; |
... | @@ -119,8 +120,6 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -119,8 +120,6 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
119 | )); | 120 | )); |
120 | } | 121 | } |
121 | setState(() {}); | 122 | setState(() {}); |
122 | - | ||
123 | - bus = eventBus.on<TransEvent>().listen((event) {}); | ||
124 | }, | 123 | }, |
125 | onError: (code, msg) { | 124 | onError: (code, msg) { |
126 | Toast.show("获取数据失败,请稍候再试..."); | 125 | Toast.show("获取数据失败,请稍候再试..."); |
... | @@ -135,11 +134,10 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -135,11 +134,10 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
135 | isLoading = true; | 134 | isLoading = true; |
136 | DioUtils.instance.asyncRequestNetwork<HomeEntity>( | 135 | DioUtils.instance.asyncRequestNetwork<HomeEntity>( |
137 | Method.get, | 136 | Method.get, |
138 | - HttpApi.home, | 137 | + cate == 0 ? HttpApi.home : HttpApi.fresh, |
139 | params: {'page_size': 80, 'page': currentPage}, | 138 | params: {'page_size': 80, 'page': currentPage}, |
140 | onSuccess: (data) { | 139 | onSuccess: (data) { |
141 | isLoading = false; | 140 | isLoading = false; |
142 | - | ||
143 | for (HomeData data in data!.data!) { | 141 | for (HomeData data in data!.data!) { |
144 | videos.add(VideoSlides( | 142 | videos.add(VideoSlides( |
145 | videoId: data.id!, | 143 | videoId: data.id!, |
... | @@ -151,8 +149,6 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -151,8 +149,6 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
151 | )); | 149 | )); |
152 | } | 150 | } |
153 | setState(() {}); | 151 | setState(() {}); |
154 | - | ||
155 | - bus = eventBus.on<TransEvent>().listen((event) {}); | ||
156 | }, | 152 | }, |
157 | onError: (code, msg) { | 153 | onError: (code, msg) { |
158 | Toast.show("获取数据失败,请稍候再试..."); | 154 | Toast.show("获取数据失败,请稍候再试..."); |
... | @@ -188,7 +184,11 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -188,7 +184,11 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
188 | mainAxisAlignment: MainAxisAlignment.center, | 184 | mainAxisAlignment: MainAxisAlignment.center, |
189 | children: [ | 185 | children: [ |
190 | TextButton( | 186 | TextButton( |
191 | - onPressed: () {}, | 187 | + onPressed: () { |
188 | + cate = 0; | ||
189 | + setState(() {}); | ||
190 | + _onRefresh(); | ||
191 | + }, | ||
192 | child: const Text( | 192 | child: const Text( |
193 | "临境", | 193 | "临境", |
194 | style: TextStyle( | 194 | style: TextStyle( |
... | @@ -203,6 +203,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -203,6 +203,7 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
203 | ), | 203 | ), |
204 | TextButton( | 204 | TextButton( |
205 | onPressed: () { | 205 | onPressed: () { |
206 | + eventBus.fire(TransEvent()); | ||
206 | NavigatorUtils.push( | 207 | NavigatorUtils.push( |
207 | context, | 208 | context, |
208 | CategoryRouter.categoryPage, | 209 | CategoryRouter.categoryPage, |
... | @@ -221,7 +222,11 @@ class HomeState extends State<Home> with WidgetsBindingObserver { | ... | @@ -221,7 +222,11 @@ class HomeState extends State<Home> with WidgetsBindingObserver { |
221 | style: TextStyle(color: Colors.white), | 222 | style: TextStyle(color: Colors.white), |
222 | ), | 223 | ), |
223 | TextButton( | 224 | TextButton( |
224 | - onPressed: () => {}, | 225 | + onPressed: () { |
226 | + cate = 1; | ||
227 | + setState(() {}); | ||
228 | + _onRefresh(); | ||
229 | + }, | ||
225 | child: const Text( | 230 | child: const Text( |
226 | "新鲜", | 231 | "新鲜", |
227 | style: TextStyle( | 232 | style: TextStyle( | ... | ... |
... | @@ -11,6 +11,7 @@ class HttpApi { | ... | @@ -11,6 +11,7 @@ class HttpApi { |
11 | static const String user = 'user'; | 11 | static const String user = 'user'; |
12 | static const String membership = 'membership'; | 12 | static const String membership = 'membership'; |
13 | static const String home = 'home'; | 13 | static const String home = 'home'; |
14 | + static const String fresh = 'fresh'; | ||
14 | static const String myVideos = '/my/videos'; | 15 | static const String myVideos = '/my/videos'; |
15 | static const String praise = '/praise'; | 16 | static const String praise = '/praise'; |
16 | static const String addView = '/addview'; | 17 | static const String addView = '/addview'; | ... | ... |
... | @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ... | @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev |
15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. | 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. |
16 | # Read more about iOS versioning at | 16 | # Read more about iOS versioning at |
17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html |
18 | -version: 1.0.0+6 | 18 | +version: 1.0.0+8 |
19 | 19 | ||
20 | environment: | 20 | environment: |
21 | sdk: ">=2.16.2 <3.0.0" | 21 | sdk: ">=2.16.2 <3.0.0" | ... | ... |
-
Please register or login to post a comment