reason

修改了视频发布流程

1 import 'dart:async'; 1 import 'dart:async';
2 2
3 +import 'package:Parlando/account/account_router.dart';
3 import 'package:Parlando/events/trans_event.dart'; 4 import 'package:Parlando/events/trans_event.dart';
4 import 'package:Parlando/home/models/home_entity.dart'; 5 import 'package:Parlando/home/models/home_entity.dart';
6 +import 'package:Parlando/home/provider/home_provider.dart';
5 import 'package:Parlando/net/dio_utils.dart'; 7 import 'package:Parlando/net/dio_utils.dart';
6 import 'package:Parlando/net/http_api.dart'; 8 import 'package:Parlando/net/http_api.dart';
7 import 'package:Parlando/util/toast_utils.dart'; 9 import 'package:Parlando/util/toast_utils.dart';
10 +import 'package:animated_radial_menu/animated_radial_menu.dart';
8 import 'package:flutter/material.dart'; 11 import 'package:flutter/material.dart';
9 import 'package:Parlando/category/category_router.dart'; 12 import 'package:Parlando/category/category_router.dart';
10 import 'package:Parlando/poem/poem_router.dart'; 13 import 'package:Parlando/poem/poem_router.dart';
...@@ -21,20 +24,22 @@ import 'package:Parlando/tiktok/widgets/tiktok_video_poem.dart'; ...@@ -21,20 +24,22 @@ import 'package:Parlando/tiktok/widgets/tiktok_video_poem.dart';
21 import 'package:Parlando/widgets/bars/home_types_bar.dart'; 24 import 'package:Parlando/widgets/bars/home_types_bar.dart';
22 import 'package:Parlando/widgets/my_app_bar.dart'; 25 import 'package:Parlando/widgets/my_app_bar.dart';
23 import 'package:getwidget/getwidget.dart'; 26 import 'package:getwidget/getwidget.dart';
27 +import 'package:provider/provider.dart';
24 import 'package:video_player/video_player.dart'; 28 import 'package:video_player/video_player.dart';
25 29
26 import 'poem_detail.dart'; 30 import 'poem_detail.dart';
27 31
28 import 'package:Parlando/extension/int_extension.dart'; 32 import 'package:Parlando/extension/int_extension.dart';
33 +import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
29 34
30 class PoemPage extends StatefulWidget { 35 class PoemPage extends StatefulWidget {
31 const PoemPage({Key? key}) : super(key: key); 36 const PoemPage({Key? key}) : super(key: key);
32 37
33 @override 38 @override
34 - _PoemPageState createState() => _PoemPageState(); 39 + PoemPageState createState() => PoemPageState();
35 } 40 }
36 41
37 -class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { 42 +class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
38 TikTokScaffoldController tkController = TikTokScaffoldController(); 43 TikTokScaffoldController tkController = TikTokScaffoldController();
39 final PageController _pageController = PageController(); 44 final PageController _pageController = PageController();
40 final TikTokVideoListController _videoListController = 45 final TikTokVideoListController _videoListController =
...@@ -43,6 +48,9 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -43,6 +48,9 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
43 late StreamSubscription bus; 48 late StreamSubscription bus;
44 bool isLoading = false; 49 bool isLoading = false;
45 50
51 + String currentPoemId = '';
52 + String currentPoemType = '';
53 +
46 @override 54 @override
47 void didChangeAppLifecycleState(AppLifecycleState state) async { 55 void didChangeAppLifecycleState(AppLifecycleState state) async {
48 if (state != AppLifecycleState.resumed) { 56 if (state != AppLifecycleState.resumed) {
...@@ -76,9 +84,13 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -76,9 +84,13 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
76 image: '', 84 image: '',
77 url: data.url!, 85 url: data.url!,
78 desc: data.content, 86 desc: data.content,
87 + poemId: '${data.poemId}',
88 + poemType: '${data.type}',
79 ), 89 ),
80 ); 90 );
81 } 91 }
92 + currentPoemId = videoDataList.first.poemId;
93 + currentPoemType = videoDataList.first.poemType;
82 _videoListController.init( 94 _videoListController.init(
83 pageController: _pageController, 95 pageController: _pageController,
84 initialList: videoDataList 96 initialList: videoDataList
...@@ -89,6 +101,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -89,6 +101,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
89 ), 101 ),
90 ) 102 )
91 .toList(), 103 .toList(),
104 + //TODO 增量加载
92 videoProvider: (int index, List<VPVideoController> list) async { 105 videoProvider: (int index, List<VPVideoController> list) async {
93 return videoDataList 106 return videoDataList
94 .map( 107 .map(
...@@ -184,6 +197,12 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -184,6 +197,12 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
184 page: Stack( 197 page: Stack(
185 children: <Widget>[ 198 children: <Widget>[
186 PageView.builder( 199 PageView.builder(
200 + onPageChanged: (p) {
201 + currentPoemId =
202 + _videoListController.currentPlayer.videoInfo!.poemId;
203 + currentPoemType =
204 + _videoListController.currentPlayer.videoInfo!.poemType;
205 + },
187 key: const Key('home'), 206 key: const Key('home'),
188 physics: const QuickerScrollPhysics(), 207 physics: const QuickerScrollPhysics(),
189 controller: _pageController, 208 controller: _pageController,
...@@ -205,7 +224,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -205,7 +224,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
205 Widget poem = TikTokVidePoem( 224 Widget poem = TikTokVidePoem(
206 title: "每日一言", 225 title: "每日一言",
207 poem: 226 poem:
208 - "清晨入古寺,初日照高林。\n曲径通幽处,禅房花木深。\n山光悦鸟性,潭影空人心。\n万籁此都寂,但余钟磬音。\n", 227 + "清晨入古寺,初日照高林。\n曲径通幽处,禅房花木深。\n山光悦鸟性,潭影空人心。\n万籁此都寂,但余钟磬音。\n",
209 author: "----《题破山寺后禅院》常建", 228 author: "----《题破山寺后禅院》常建",
210 onShowDetail: () { 229 onShowDetail: () {
211 tkController.animateToPage(TikTokPagePosition.right); 230 tkController.animateToPage(TikTokPagePosition.right);
...@@ -247,6 +266,86 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver { ...@@ -247,6 +266,86 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
247 currentPage ?? Container(), 266 currentPage ?? Container(),
248 ], 267 ],
249 ), 268 ),
269 + floatingActionButton: SizedBox(
270 + height: 60,
271 + child: RadialMenu(
272 + children: [
273 + RadialButton(
274 + icon: const Icon(Icons.video_call_outlined),
275 + buttonColor: Colors.teal,
276 + onPress: () {
277 + String url =
278 + '${PoemRouter.poemRecordVideoPage}?id=$currentPoemId&type=$currentPoemType';
279 + print("===========================" + url);
280 + eventBus.fire(TransEvent());
281 + NavigatorUtils.push(
282 + context,
283 + url,
284 + );
285 + }),
286 + RadialButton(
287 + icon: const Icon(Icons.mic_none_outlined),
288 + buttonColor: Colors.green,
289 + onPress: () {
290 + eventBus.fire(TransEvent());
291 + NavigatorUtils.push(
292 + context,
293 + '${PoemRouter.poemRecordAudioPage}?id=$currentPoemId&type=$currentPoemType',
294 + );
295 + }),
296 + ],
297 + ),
298 + ),
299 + bottomNavigationBar: Consumer<HomeProvider>(
300 + builder: (_, provider, __) {
301 + return BottomAppBar(
302 + color: Colors.grey,
303 + child: Row(
304 + mainAxisSize: MainAxisSize.max,
305 + mainAxisAlignment: MainAxisAlignment.spaceAround,
306 + children: <Widget>[
307 + InkWell(
308 + onTap: () {},
309 + child: Container(
310 + alignment: Alignment.center,
311 + height: 36.0,
312 + child: Text(
313 + ParlandoLocalizations.of(context)
314 + .onePoemBottomNavigationBarItemTitle,
315 + style: const TextStyle(
316 + color: Colors.white54,
317 + fontSize: 15.0,
318 + ),
319 + ),
320 + ),
321 + ),
322 + InkWell(
323 + onTap: () {
324 + eventBus.fire(TransEvent());
325 + NavigatorUtils.push(
326 + context,
327 + AccountRouter.accountPage,
328 + );
329 + },
330 + child: Container(
331 + alignment: Alignment.center,
332 + height: 36.0,
333 + child: Text(
334 + ParlandoLocalizations.of(context)
335 + .profileBottomNavigationBarItemTitle,
336 + style: const TextStyle(
337 + color: Colors.white54,
338 + fontSize: 15.0,
339 + ),
340 + ),
341 + ),
342 + ),
343 + ]),
344 + );
345 + },
346 + ),
347 + floatingActionButtonLocation:
348 + FloatingActionButtonLocation.centerDocked,
250 ); 349 );
251 } 350 }
252 } 351 }
......
...@@ -19,8 +19,15 @@ import 'package:path_provider/path_provider.dart'; ...@@ -19,8 +19,15 @@ import 'package:path_provider/path_provider.dart';
19 import '../poem_router.dart'; 19 import '../poem_router.dart';
20 20
21 class PoemPublish extends StatefulWidget { 21 class PoemPublish extends StatefulWidget {
22 - const PoemPublish({Key? key, required this.data}) : super(key: key); 22 + const PoemPublish({
23 + Key? key,
24 + required this.data,
25 + required this.id,
26 + required this.type,
27 + }) : super(key: key);
23 28
29 + final int id;
30 + final int type;
24 final String data; 31 final String data;
25 32
26 @override 33 @override
...@@ -214,7 +221,7 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -214,7 +221,7 @@ class _PoemPublishState extends State<PoemPublish> {
214 Future<dynamic> _getUploadVideo() async { 221 Future<dynamic> _getUploadVideo() async {
215 final directory = await getApplicationDocumentsDirectory(); 222 final directory = await getApplicationDocumentsDirectory();
216 dynamic video = await MultipartFile.fromFile( 223 dynamic video = await MultipartFile.fromFile(
217 - directory.path + "/" + widget.data, 224 + "${directory.path}/${widget.data}",
218 filename: "video.mp4"); 225 filename: "video.mp4");
219 return video; 226 return video;
220 } 227 }
...@@ -239,12 +246,13 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -239,12 +246,13 @@ class _PoemPublishState extends State<PoemPublish> {
239 params: formData, 246 params: formData,
240 onSuccess: (data) { 247 onSuccess: (data) {
241 String path = data!.data!.relativePath!; 248 String path = data!.data!.relativePath!;
242 - String videoId = "1"; //TODO 临时用video id 249 + String videoId = '${widget.id}'; //TODO 临时用video id
243 250
244 Map<String, String> params = <String, String>{ 251 Map<String, String> params = <String, String>{
245 - "video_id": videoId, 252 + "item_id": videoId,
246 - "video_url": path, 253 + "item_url": path,
247 "content": msg, 254 "content": msg,
255 + "type": '${widget.type}',
248 }; 256 };
249 DioUtils.instance.asyncRequestNetwork( 257 DioUtils.instance.asyncRequestNetwork(
250 Method.post, 258 Method.post,
......
...@@ -16,13 +16,20 @@ import 'package:Parlando/extension/int_extension.dart'; ...@@ -16,13 +16,20 @@ import 'package:Parlando/extension/int_extension.dart';
16 import '../poem_router.dart'; 16 import '../poem_router.dart';
17 17
18 class PoemRecordVideoPage extends StatefulWidget { 18 class PoemRecordVideoPage extends StatefulWidget {
19 - const PoemRecordVideoPage({Key? key}) : super(key: key); 19 + final int id;
20 + final int type;
21 +
22 + const PoemRecordVideoPage({
23 + Key? key,
24 + required this.id,
25 + required this.type,
26 + }) : super(key: key);
20 27
21 @override 28 @override
22 - _PoemRecordVideoPageState createState() => _PoemRecordVideoPageState(); 29 + PoemRecordVideoPageState createState() => PoemRecordVideoPageState();
23 } 30 }
24 31
25 -class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> 32 +class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
26 with WidgetsBindingObserver { 33 with WidgetsBindingObserver {
27 CameraController? controller; 34 CameraController? controller;
28 VideoPlayerController? videoController; 35 VideoPlayerController? videoController;
...@@ -255,7 +262,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -255,7 +262,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
255 262
256 NavigatorUtils.push( 263 NavigatorUtils.push(
257 context, 264 context,
258 - '${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat', 265 + '${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat&id=${widget.id}&type=${widget.type}',
259 ); 266 );
260 } catch (e) { 267 } catch (e) {
261 // print(e); 268 // print(e);
......
...@@ -11,11 +11,15 @@ import '../poem_router.dart'; ...@@ -11,11 +11,15 @@ import '../poem_router.dart';
11 class PoemVideoPlayer extends StatefulWidget { 11 class PoemVideoPlayer extends StatefulWidget {
12 final String url; 12 final String url;
13 final String? title; 13 final String? title;
14 + final int id;
15 + final int type;
14 16
15 const PoemVideoPlayer({ 17 const PoemVideoPlayer({
16 Key? key, 18 Key? key,
17 required this.url, 19 required this.url,
18 this.title, 20 this.title,
21 + required this.id,
22 + required this.type,
19 }) : super(key: key); 23 }) : super(key: key);
20 24
21 @override 25 @override
...@@ -118,18 +122,18 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -118,18 +122,18 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
118 right: 20.px, 122 right: 20.px,
119 child: ElevatedButton( 123 child: ElevatedButton(
120 onPressed: () { 124 onPressed: () {
121 - NavigatorUtils.push( 125 + NavigatorUtils.push(context,
122 - context, '${PoemRouter.poemPublish}?data=' + widget.url, 126 + '${PoemRouter.poemPublish}?data=${widget.url}&id=${widget.id}&type=${widget.type}',
123 clearStack: true); 127 clearStack: true);
124 }, 128 },
125 - child: Text(
126 - "下一步",
127 - style: TextStyle(fontSize: 15.px),
128 - ),
129 style: TextButton.styleFrom( 129 style: TextButton.styleFrom(
130 primary: Colors.white, 130 primary: Colors.white,
131 backgroundColor: Colors.black54, 131 backgroundColor: Colors.black54,
132 ), 132 ),
133 + child: Text(
134 + "下一步",
135 + style: TextStyle(fontSize: 15.px),
136 + ),
133 ), 137 ),
134 ), 138 ),
135 ], 139 ],
......
...@@ -62,9 +62,11 @@ class PoemRouter implements IRouterProvider { ...@@ -62,9 +62,11 @@ class PoemRouter implements IRouterProvider {
62 handler: Handler( 62 handler: Handler(
63 handlerFunc: (_, Map<String, List<String>> params) { 63 handlerFunc: (_, Map<String, List<String>> params) {
64 String? id = params['id']?.first; 64 String? id = params['id']?.first;
65 - return const PoemRecordVideoPage( 65 + String? type = params['type']?.first;
66 - // poemId: int.parse(id!), 66 + return PoemRecordVideoPage(
67 - ); 67 + id: int.parse(id!),
68 + type: int.parse(type!),
69 + );
68 }, 70 },
69 ), 71 ),
70 ); 72 );
...@@ -74,8 +76,12 @@ class PoemRouter implements IRouterProvider { ...@@ -74,8 +76,12 @@ class PoemRouter implements IRouterProvider {
74 handler: Handler( 76 handler: Handler(
75 handlerFunc: (_, Map<String, List<String>> params) { 77 handlerFunc: (_, Map<String, List<String>> params) {
76 String? url = params['url']?.first; 78 String? url = params['url']?.first;
79 + String? id = params['id']?.first;
80 + String? type = params['type']?.first;
77 return PoemVideoPlayer( 81 return PoemVideoPlayer(
78 url: url!, 82 url: url!,
83 + id: int.parse(id!),
84 + type: int.parse(type!),
79 ); 85 );
80 }, 86 },
81 ), 87 ),
...@@ -85,8 +91,12 @@ class PoemRouter implements IRouterProvider { ...@@ -85,8 +91,12 @@ class PoemRouter implements IRouterProvider {
85 handler: Handler( 91 handler: Handler(
86 handlerFunc: (_, Map<String, List<String>> params) { 92 handlerFunc: (_, Map<String, List<String>> params) {
87 String? data = params['data']?.first; 93 String? data = params['data']?.first;
94 + String? id = params['id']?.first;
95 + String? type = params['type']?.first;
88 return PoemPublish( 96 return PoemPublish(
89 data: data!, 97 data: data!,
98 + id: int.parse(id!),
99 + type: int.parse(type!),
90 ); 100 );
91 }, 101 },
92 ), 102 ),
......
...@@ -11,23 +11,17 @@ class UserVideo { ...@@ -11,23 +11,17 @@ class UserVideo {
11 final String url; 11 final String url;
12 final String image; 12 final String image;
13 final String? desc; 13 final String? desc;
14 + final String poemId;
15 + final String poemType;
14 16
15 UserVideo({ 17 UserVideo({
16 required this.url, 18 required this.url,
17 required this.image, 19 required this.image,
18 this.desc, 20 this.desc,
21 + required this.poemId,
22 + required this.poemType,
19 }); 23 });
20 24
21 - static List<UserVideo> fetchVideo() {
22 - List<UserVideo> list = videoList
23 - .map((e) => UserVideo(
24 - image: '',
25 - url: 'assets/data/$e',
26 - desc: '清晨入古寺,初日照高林。\n竹径通幽处,禅房花木深。'))
27 - .toList();
28 - return list;
29 - }
30 -
31 @override 25 @override
32 String toString() { 26 String toString() {
33 return 'image:$image' '\nvideo:$url'; 27 return 'image:$image' '\nvideo:$url';
......
1 import 'dart:math'; 1 import 'dart:math';
2 -import 'package:Parlando/account/account_router.dart';
3 -import 'package:Parlando/events/trans_event.dart';
4 -import 'package:Parlando/home/provider/home_provider.dart';
5 -import 'package:Parlando/poem/poem_router.dart';
6 -import 'package:Parlando/routers/fluro_navigator.dart';
7 -import 'package:animated_radial_menu/animated_radial_menu.dart';
8 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
9 import 'package:flutter/rendering.dart'; 3 import 'package:flutter/rendering.dart';
10 import 'package:Parlando/tiktok/style/style.dart'; 4 import 'package:Parlando/tiktok/style/style.dart';
11 -import 'package:provider/provider.dart';
12 -import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
13 5
14 const double scrollSpeed = 300; 6 const double scrollSpeed = 300;
15 7
...@@ -65,7 +57,9 @@ class TikTokScaffold extends StatefulWidget { ...@@ -65,7 +57,9 @@ class TikTokScaffold extends StatefulWidget {
65 final bool? enableGesture; 57 final bool? enableGesture;
66 58
67 final Widget? page; 59 final Widget? page;
68 - 60 + final Widget? floatingActionButton;
61 + final Widget? bottomNavigationBar;
62 + final FloatingActionButtonLocation? floatingActionButtonLocation;
69 final Function()? onPullDownRefresh; 63 final Function()? onPullDownRefresh;
70 64
71 const TikTokScaffold({ 65 const TikTokScaffold({
...@@ -80,6 +74,9 @@ class TikTokScaffold extends StatefulWidget { ...@@ -80,6 +74,9 @@ class TikTokScaffold extends StatefulWidget {
80 this.enableGesture, 74 this.enableGesture,
81 this.onPullDownRefresh, 75 this.onPullDownRefresh,
82 this.controller, 76 this.controller,
77 + this.floatingActionButton,
78 + this.bottomNavigationBar,
79 + this.floatingActionButtonLocation,
83 }) : super(key: key); 80 }) : super(key: key);
84 81
85 @override 82 @override
...@@ -193,82 +190,9 @@ class _TikTokScaffoldState extends State<TikTokScaffold> ...@@ -193,82 +190,9 @@ class _TikTokScaffoldState extends State<TikTokScaffold>
193 body: body, 190 body: body,
194 backgroundColor: Colors.black, 191 backgroundColor: Colors.black,
195 resizeToAvoidBottomInset: false, 192 resizeToAvoidBottomInset: false,
196 - floatingActionButton: SizedBox( 193 + floatingActionButton: widget.floatingActionButton,
197 - height: 60, 194 + bottomNavigationBar: widget.bottomNavigationBar,
198 - child: RadialMenu( 195 + floatingActionButtonLocation: widget.floatingActionButtonLocation,
199 - children: [
200 - RadialButton(
201 - icon: const Icon(Icons.video_call_outlined),
202 - buttonColor: Colors.teal,
203 - onPress: () {
204 - eventBus.fire(TransEvent());
205 - NavigatorUtils.push(
206 - context,
207 - '${PoemRouter.poemRecordVideoPage}?data=100',
208 - );
209 - }),
210 - RadialButton(
211 - icon: const Icon(Icons.mic_none_outlined),
212 - buttonColor: Colors.green,
213 - onPress: () {
214 - eventBus.fire(TransEvent());
215 - NavigatorUtils.push(
216 - context,
217 - '${PoemRouter.poemRecordAudioPage}?id=100',
218 - );
219 - }),
220 - ],
221 - ),
222 - ),
223 - bottomNavigationBar: Consumer<HomeProvider>(
224 - builder: (_, provider, __) {
225 - return BottomAppBar(
226 - color: Colors.grey,
227 - child: Row(
228 - mainAxisSize: MainAxisSize.max,
229 - mainAxisAlignment: MainAxisAlignment.spaceAround,
230 - children: <Widget>[
231 - InkWell(
232 - onTap: () {},
233 - child: Container(
234 - alignment: Alignment.center,
235 - height: 36.0,
236 - child: Text(
237 - ParlandoLocalizations.of(context)
238 - .onePoemBottomNavigationBarItemTitle,
239 - style: const TextStyle(
240 - color: Colors.white54,
241 - fontSize: 15.0,
242 - ),
243 - ),
244 - ),
245 - ),
246 - InkWell(
247 - onTap: () {
248 - eventBus.fire(TransEvent());
249 - NavigatorUtils.push(
250 - context,
251 - AccountRouter.accountPage,
252 - );
253 - },
254 - child: Container(
255 - alignment: Alignment.center,
256 - height: 36.0,
257 - child: Text(
258 - ParlandoLocalizations.of(context)
259 - .profileBottomNavigationBarItemTitle,
260 - style: const TextStyle(
261 - color: Colors.white54,
262 - fontSize: 15.0,
263 - ),
264 - ),
265 - ),
266 - ),
267 - ]),
268 - );
269 - },
270 - ),
271 - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
272 ), 196 ),
273 ); 197 );
274 return body; 198 return body;
......