Reason Pun

todo 上传临境

1 buildscript { 1 buildscript {
2 - ext.kotlin_version = '1.6.10' 2 + ext.kotlin_version = '1.6.21'
3 repositories { 3 repositories {
4 google() 4 google()
5 mavenCentral() 5 mavenCentral()
......
...@@ -33,7 +33,7 @@ import 'util/theme_utils.dart'; ...@@ -33,7 +33,7 @@ import 'util/theme_utils.dart';
33 /// json to model 33 /// json to model
34 /// 安装 34 /// 安装
35 /// dependencies: 35 /// dependencies:
36 -/// json_annotation: ^4.4.0 36 +/// json_annotation: ^4.4.0x
37 /// dev_dependencies: 37 /// dev_dependencies:
38 /// json_serializable: ^6.1.3 38 /// json_serializable: ^6.1.3
39 /// build_runner: ^2.1.7 39 /// build_runner: ^2.1.7
......
...@@ -3,6 +3,7 @@ class HttpApi { ...@@ -3,6 +3,7 @@ class HttpApi {
3 static const String register = 'register'; 3 static const String register = 'register';
4 static const String verify = 'verify'; 4 static const String verify = 'verify';
5 static const String login = 'login'; 5 static const String login = 'login';
6 + static const String uploadVideo = 'upload/video';
6 static const String user = 'user'; 7 static const String user = 'user';
7 static const String search = 'search/repositories'; 8 static const String search = 'search/repositories';
8 static const String subscriptions = 'users/simplezhli/subscriptions'; 9 static const String subscriptions = 'users/simplezhli/subscriptions';
......
1 +import 'package:Parlando/net/dio_utils.dart';
2 +import 'package:Parlando/net/http_api.dart';
3 +import 'package:dio/dio.dart';
1 import 'package:flutter/cupertino.dart'; 4 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/material.dart'; 5 import 'package:flutter/material.dart';
3 import 'package:flutter_2d_amap/flutter_2d_amap.dart'; 6 import 'package:flutter_2d_amap/flutter_2d_amap.dart';
...@@ -6,10 +9,10 @@ import 'package:Parlando/poem/widgets/lang_sort_bottom_sheet.dart'; ...@@ -6,10 +9,10 @@ import 'package:Parlando/poem/widgets/lang_sort_bottom_sheet.dart';
6 import 'package:Parlando/res/resources.dart'; 9 import 'package:Parlando/res/resources.dart';
7 import 'package:Parlando/routers/fluro_navigator.dart'; 10 import 'package:Parlando/routers/fluro_navigator.dart';
8 import 'package:Parlando/routers/routers.dart'; 11 import 'package:Parlando/routers/routers.dart';
9 -import 'package:Parlando/widgets/click_item.dart';
10 import 'package:Parlando/widgets/my_app_bar.dart'; 12 import 'package:Parlando/widgets/my_app_bar.dart';
11 13
12 import 'package:Parlando/extension/int_extension.dart'; 14 import 'package:Parlando/extension/int_extension.dart';
15 +import 'package:path_provider/path_provider.dart';
13 16
14 import '../poem_router.dart'; 17 import '../poem_router.dart';
15 18
...@@ -29,6 +32,8 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -29,6 +32,8 @@ class _PoemPublishState extends State<PoemPublish> {
29 String _address = '我在此地'; 32 String _address = '我在此地';
30 final LangSortProvider _provider = LangSortProvider(); 33 final LangSortProvider _provider = LangSortProvider();
31 34
35 + final TextEditingController _msgController = TextEditingController();
36 +
32 @override 37 @override
33 void initState() { 38 void initState() {
34 super.initState(); 39 super.initState();
...@@ -72,6 +77,7 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -72,6 +77,7 @@ class _PoemPublishState extends State<PoemPublish> {
72 maxWidth: double.infinity, 77 maxWidth: double.infinity,
73 ), 78 ),
74 child: TextField( 79 child: TextField(
80 + controller: _msgController,
75 maxLines: 10, 81 maxLines: 10,
76 decoration: InputDecoration( 82 decoration: InputDecoration(
77 contentPadding: const EdgeInsets.all(10.0), 83 contentPadding: const EdgeInsets.all(10.0),
...@@ -203,16 +209,51 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -203,16 +209,51 @@ class _PoemPublishState extends State<PoemPublish> {
203 ); 209 );
204 } 210 }
205 211
212 + Future<dynamic> _getUploadVideo() async {
213 + final directory = await getApplicationDocumentsDirectory();
214 + dynamic video = await MultipartFile.fromFile(
215 + directory.path + "/" + widget.data,
216 + filename: "xxx23.png");
217 + return video;
218 + }
219 +
206 Future<void> publishPoem(BuildContext context) async { 220 Future<void> publishPoem(BuildContext context) async {
221 + String msg = _msgController.text;
222 + if (msg.isEmpty) {
223 + msg = "读此一言,仿佛身临其境";
224 + }
225 +
207 isPublishing = true; 226 isPublishing = true;
208 setState(() {}); 227 setState(() {});
209 - // TODO 等待套入正式接口发布临境 228 +
210 - await Future.delayed(const Duration(seconds: 2), () { 229 + _getUploadVideo().then((value) {
211 - NavigatorUtils.push( 230 + Map<String, dynamic> map = <String, dynamic>{
212 - context, 231 + "video": value,
213 - '${PoemRouter.poemCompletePage}?id=100', 232 + };
233 + FormData formData = FormData.fromMap(map);
234 + DioUtils.instance.asyncRequestNetwork(
235 + Method.post,
236 + HttpApi.uploadVideo,
237 + params: formData,
238 + onSuccess: (data) {
239 + print(data);
240 + //TODO 上传视频成功之后创建临境
241 + isPublishing = false;
242 + },
243 + onError: (code, msg) {
244 + isPublishing = false;
245 + setState(() {});
246 + },
214 ); 247 );
215 }); 248 });
249 +
250 + // TODO 等待套入正式接口发布临境
251 + // await Future.delayed(const Duration(seconds: 2), () {
252 + // NavigatorUtils.push(
253 + // context,
254 + // '${PoemRouter.poemCompletePage}?id=100',
255 + // );
256 + // });
216 } 257 }
217 258
218 Future<bool> _isExit() async { 259 Future<bool> _isExit() async {
......
...@@ -255,7 +255,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -255,7 +255,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
255 255
256 NavigatorUtils.push( 256 NavigatorUtils.push(
257 context, 257 context,
258 - '${PoemRouter.poemVideoPlayer}?url=100', 258 + '${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat',
259 ); 259 );
260 } catch (e) { 260 } catch (e) {
261 // print(e); 261 // print(e);
......
...@@ -4,6 +4,7 @@ import 'package:Parlando/res/resources.dart'; ...@@ -4,6 +4,7 @@ import 'package:Parlando/res/resources.dart';
4 import 'package:Parlando/routers/fluro_navigator.dart'; 4 import 'package:Parlando/routers/fluro_navigator.dart';
5 import 'package:Parlando/widgets/my_app_bar.dart'; 5 import 'package:Parlando/widgets/my_app_bar.dart';
6 import 'package:Parlando/extension/int_extension.dart'; 6 import 'package:Parlando/extension/int_extension.dart';
7 +import 'package:path_provider/path_provider.dart';
7 8
8 import '../poem_router.dart'; 9 import '../poem_router.dart';
9 10
...@@ -26,16 +27,22 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -26,16 +27,22 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
26 27
27 _PoemVideoPlayerState(); 28 _PoemVideoPlayerState();
28 29
30 + Future<String> _getDir() async {
31 + final directory = await getApplicationDocumentsDirectory();
32 + return directory.path;
33 + }
34 +
29 @override 35 @override
30 void initState() { 36 void initState() {
31 super.initState(); 37 super.initState();
32 - // player.setDataSource(widget.url, autoPlay: true); 38 + _getDir().then((value) {
33 - //TODO 替换真实URL 39 + String path = "$value/" + widget.url;
34 - player.setDataSource( 40 + player.setDataSource(
35 - "asset:///assets/data/video_01.mp4", 41 + path,
36 - autoPlay: true, 42 + autoPlay: true,
37 - ); 43 + );
38 - player.setLoop(0); 44 + player.setLoop(0);
45 + });
39 } 46 }
40 47
41 @override 48 @override
...@@ -112,10 +119,8 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -112,10 +119,8 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
112 child: ElevatedButton( 119 child: ElevatedButton(
113 onPressed: () { 120 onPressed: () {
114 NavigatorUtils.push( 121 NavigatorUtils.push(
115 - context, 122 + context, '${PoemRouter.poemPublish}?data=' + widget.url,
116 - '${PoemRouter.poemPublish}?data=100', 123 + clearStack: true);
117 - clearStack: true
118 - );
119 }, 124 },
120 child: Text( 125 child: Text(
121 "下一步", 126 "下一步",
......
This diff is collapsed. Click to expand it.