reason

修改上传视频逻辑

...@@ -280,7 +280,7 @@ class AccountPageState extends State<AccountPage> { ...@@ -280,7 +280,7 @@ class AccountPageState extends State<AccountPage> {
280 bottomNavigationBar: Consumer( 280 bottomNavigationBar: Consumer(
281 builder: (_, provider, __) { 281 builder: (_, provider, __) {
282 return BottomAppBar( 282 return BottomAppBar(
283 - color: Colors.grey, 283 + color: Colors.black54,
284 child: Row( 284 child: Row(
285 mainAxisSize: MainAxisSize.max, 285 mainAxisSize: MainAxisSize.max,
286 mainAxisAlignment: MainAxisAlignment.spaceAround, 286 mainAxisAlignment: MainAxisAlignment.spaceAround,
......
...@@ -18,6 +18,7 @@ import 'package:Parlando/membership/models/order_entity.dart'; ...@@ -18,6 +18,7 @@ import 'package:Parlando/membership/models/order_entity.dart';
18 import 'package:Parlando/membership/models/pay_entity.dart'; 18 import 'package:Parlando/membership/models/pay_entity.dart';
19 import 'package:Parlando/models/upload_entity.dart'; 19 import 'package:Parlando/models/upload_entity.dart';
20 import 'package:Parlando/poem/models/lang_sort_entity.dart'; 20 import 'package:Parlando/poem/models/lang_sort_entity.dart';
21 +import 'package:Parlando/poem/models/poem_entity.dart';
21 import 'package:Parlando/poem/models/search_entity.dart'; 22 import 'package:Parlando/poem/models/search_entity.dart';
22 import 'package:Parlando/timeline/models/friend_entity.dart'; 23 import 'package:Parlando/timeline/models/friend_entity.dart';
23 24
...@@ -76,6 +77,9 @@ class JsonConvert { ...@@ -76,6 +77,9 @@ class JsonConvert {
76 (UploadData).toString(): UploadData.fromJson, 77 (UploadData).toString(): UploadData.fromJson,
77 (UploadError).toString(): UploadError.fromJson, 78 (UploadError).toString(): UploadError.fromJson,
78 (LangSortEntity).toString(): LangSortEntity.fromJson, 79 (LangSortEntity).toString(): LangSortEntity.fromJson,
80 + (PoemEntity).toString(): PoemEntity.fromJson,
81 + (PoemData).toString(): PoemData.fromJson,
82 + (PoemError).toString(): PoemError.fromJson,
79 (SearchEntity).toString(): SearchEntity.fromJson, 83 (SearchEntity).toString(): SearchEntity.fromJson,
80 (SearchItems).toString(): SearchItems.fromJson, 84 (SearchItems).toString(): SearchItems.fromJson,
81 (SearchItemsOwner).toString(): SearchItemsOwner.fromJson, 85 (SearchItemsOwner).toString(): SearchItemsOwner.fromJson,
...@@ -424,6 +428,21 @@ class JsonConvert { ...@@ -424,6 +428,21 @@ class JsonConvert {
424 (Map<String, dynamic> e) => LangSortEntity.fromJson(e)) 428 (Map<String, dynamic> e) => LangSortEntity.fromJson(e))
425 .toList() as M; 429 .toList() as M;
426 } 430 }
431 + if (<PoemEntity>[] is M) {
432 + return data
433 + .map<PoemEntity>((Map<String, dynamic> e) => PoemEntity.fromJson(e))
434 + .toList() as M;
435 + }
436 + if (<PoemData>[] is M) {
437 + return data
438 + .map<PoemData>((Map<String, dynamic> e) => PoemData.fromJson(e))
439 + .toList() as M;
440 + }
441 + if (<PoemError>[] is M) {
442 + return data
443 + .map<PoemError>((Map<String, dynamic> e) => PoemError.fromJson(e))
444 + .toList() as M;
445 + }
427 if (<SearchEntity>[] is M) { 446 if (<SearchEntity>[] is M) {
428 return data 447 return data
429 .map<SearchEntity>( 448 .map<SearchEntity>(
......
1 +import 'package:Parlando/generated/json/base/json_convert_content.dart';
2 +import 'package:Parlando/poem/models/poem_entity.dart';
3 +
4 +PoemEntity $PoemEntityFromJson(Map<String, dynamic> json) {
5 + final PoemEntity poemEntity = PoemEntity();
6 + final String? status = jsonConvert.convert<String>(json['status']);
7 + if (status != null) {
8 + poemEntity.status = status;
9 + }
10 + final int? code = jsonConvert.convert<int>(json['code']);
11 + if (code != null) {
12 + poemEntity.code = code;
13 + }
14 + final String? message = jsonConvert.convert<String>(json['message']);
15 + if (message != null) {
16 + poemEntity.message = message;
17 + }
18 + final PoemData? data = jsonConvert.convert<PoemData>(json['data']);
19 + if (data != null) {
20 + poemEntity.data = data;
21 + }
22 + final PoemError? error = jsonConvert.convert<PoemError>(json['error']);
23 + if (error != null) {
24 + poemEntity.error = error;
25 + }
26 + return poemEntity;
27 +}
28 +
29 +Map<String, dynamic> $PoemEntityToJson(PoemEntity entity) {
30 + final Map<String, dynamic> data = <String, dynamic>{};
31 + data['status'] = entity.status;
32 + data['code'] = entity.code;
33 + data['message'] = entity.message;
34 + data['data'] = entity.data?.toJson();
35 + data['error'] = entity.error?.toJson();
36 + return data;
37 +}
38 +
39 +PoemData $PoemDataFromJson(Map<String, dynamic> json) {
40 + final PoemData poemData = PoemData();
41 + final int? id = jsonConvert.convert<int>(json['id']);
42 + if (id != null) {
43 + poemData.id = id;
44 + }
45 + final String? title = jsonConvert.convert<String>(json['title']);
46 + if (title != null) {
47 + poemData.title = title;
48 + }
49 + final String? author = jsonConvert.convert<String>(json['author']);
50 + if (author != null) {
51 + poemData.author = author;
52 + }
53 + final String? content = jsonConvert.convert<String>(json['content']);
54 + if (content != null) {
55 + poemData.content = content;
56 + }
57 + final String? annotate = jsonConvert.convert<String>(json['annotate']);
58 + if (annotate != null) {
59 + poemData.annotate = annotate;
60 + }
61 + final dynamic? spelling = jsonConvert.convert<dynamic>(json['spelling']);
62 + if (spelling != null) {
63 + poemData.spelling = spelling;
64 + }
65 + final dynamic? en = jsonConvert.convert<dynamic>(json['en']);
66 + if (en != null) {
67 + poemData.en = en;
68 + }
69 + final int? state = jsonConvert.convert<int>(json['state']);
70 + if (state != null) {
71 + poemData.state = state;
72 + }
73 + final String? createdAt = jsonConvert.convert<String>(json['created_at']);
74 + if (createdAt != null) {
75 + poemData.createdAt = createdAt;
76 + }
77 + final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
78 + if (updatedAt != null) {
79 + poemData.updatedAt = updatedAt;
80 + }
81 + return poemData;
82 +}
83 +
84 +Map<String, dynamic> $PoemDataToJson(PoemData entity) {
85 + final Map<String, dynamic> data = <String, dynamic>{};
86 + data['id'] = entity.id;
87 + data['title'] = entity.title;
88 + data['author'] = entity.author;
89 + data['content'] = entity.content;
90 + data['annotate'] = entity.annotate;
91 + data['spelling'] = entity.spelling;
92 + data['en'] = entity.en;
93 + data['state'] = entity.state;
94 + data['created_at'] = entity.createdAt;
95 + data['updated_at'] = entity.updatedAt;
96 + return data;
97 +}
98 +
99 +PoemError $PoemErrorFromJson(Map<String, dynamic> json) {
100 + final PoemError poemError = PoemError();
101 + return poemError;
102 +}
103 +
104 +Map<String, dynamic> $PoemErrorToJson(PoemError entity) {
105 + final Map<String, dynamic> data = <String, dynamic>{};
106 + return data;
107 +}
...@@ -10,7 +10,7 @@ import 'error_handle.dart'; ...@@ -10,7 +10,7 @@ import 'error_handle.dart';
10 /// 默认dio配置 10 /// 默认dio配置
11 int _connectTimeout = 15000; 11 int _connectTimeout = 15000;
12 int _receiveTimeout = 15000; 12 int _receiveTimeout = 15000;
13 -int _sendTimeout = 10000; 13 +int _sendTimeout = 100000;
14 String _baseUrl = ''; 14 String _baseUrl = '';
15 List<Interceptor> _interceptors = []; 15 List<Interceptor> _interceptors = [];
16 16
......
...@@ -17,6 +17,7 @@ class HttpApi { ...@@ -17,6 +17,7 @@ class HttpApi {
17 static const String collect = '/collect'; 17 static const String collect = '/collect';
18 static const String order = '/order'; 18 static const String order = '/order';
19 static const String pay = '/pay'; 19 static const String pay = '/pay';
20 + static const String poem = '/poem';
20 static const String search = 'search/repositories'; 21 static const String search = 'search/repositories';
21 static const String subscriptions = 'users/simplezhli/subscriptions'; 22 static const String subscriptions = 'users/simplezhli/subscriptions';
22 static const String upload = 'uuc/upload-inco'; 23 static const String upload = 'uuc/upload-inco';
......
...@@ -281,7 +281,7 @@ class VideoSlidesState extends State<VideoSlides> { ...@@ -281,7 +281,7 @@ class VideoSlidesState extends State<VideoSlides> {
281 onPress: () { 281 onPress: () {
282 eventBus.fire(TransEvent()); 282 eventBus.fire(TransEvent());
283 String url = 283 String url =
284 - '${PoemRouter.poemRecordVideoPage}?id=${widget.videoId}&type=${widget.poemType}'; 284 + '${PoemRouter.poemRecordVideoPage}?id=${widget.videoId}&poem=${widget.poemId}&type=${widget.poemType}';
285 NavigatorUtils.push( 285 NavigatorUtils.push(
286 context, 286 context,
287 url, 287 url,
...@@ -294,7 +294,7 @@ class VideoSlidesState extends State<VideoSlides> { ...@@ -294,7 +294,7 @@ class VideoSlidesState extends State<VideoSlides> {
294 eventBus.fire(TransEvent()); 294 eventBus.fire(TransEvent());
295 NavigatorUtils.push( 295 NavigatorUtils.push(
296 context, 296 context,
297 - '${PoemRouter.poemRecordAudioPage}?id=${widget.videoId}&type=${widget.poemType}', 297 + '${PoemRouter.poemRecordAudioPage}?id=${widget.videoId}&poem=${widget.poemId}&type=${widget.poemType}',
298 ); 298 );
299 }), 299 }),
300 ], 300 ],
......
1 +import 'package:Parlando/generated/json/base/json_field.dart';
2 +import 'package:Parlando/generated/json/poem_entity.g.dart';
3 +import 'dart:convert';
4 +
5 +@JsonSerializable()
6 +class PoemEntity {
7 + String? status;
8 + int? code;
9 + String? message;
10 + PoemData? data;
11 + PoemError? error;
12 +
13 + PoemEntity();
14 +
15 + factory PoemEntity.fromJson(Map<String, dynamic> json) =>
16 + $PoemEntityFromJson(json);
17 +
18 + Map<String, dynamic> toJson() => $PoemEntityToJson(this);
19 +
20 + @override
21 + String toString() {
22 + return jsonEncode(this);
23 + }
24 +}
25 +
26 +@JsonSerializable()
27 +class PoemData {
28 + int? id;
29 + String? title;
30 + String? author;
31 + String? content;
32 + String? annotate;
33 + dynamic spelling;
34 + dynamic en;
35 + int? state;
36 + @JSONField(name: "created_at")
37 + String? createdAt;
38 + @JSONField(name: "updated_at")
39 + String? updatedAt;
40 +
41 + PoemData();
42 +
43 + factory PoemData.fromJson(Map<String, dynamic> json) =>
44 + $PoemDataFromJson(json);
45 +
46 + Map<String, dynamic> toJson() => $PoemDataToJson(this);
47 +
48 + @override
49 + String toString() {
50 + return jsonEncode(this);
51 + }
52 +}
53 +
54 +@JsonSerializable()
55 +class PoemError {
56 + PoemError();
57 +
58 + factory PoemError.fromJson(Map<String, dynamic> json) =>
59 + $PoemErrorFromJson(json);
60 +
61 + Map<String, dynamic> toJson() => $PoemErrorToJson(this);
62 +
63 + @override
64 + String toString() {
65 + return jsonEncode(this);
66 + }
67 +}
...@@ -94,7 +94,7 @@ class _PoemCompletePageState extends State<PoemCompletePage> { ...@@ -94,7 +94,7 @@ class _PoemCompletePageState extends State<PoemCompletePage> {
94 } 94 }
95 95
96 Future<bool> _isExit() async { 96 Future<bool> _isExit() async {
97 - NavigatorUtils.push(context, Routes.home, clearStack: true); 97 + NavigatorUtils.push(context, Routes.navBarPage, clearStack: true);
98 return Future.value(false); 98 return Future.value(false);
99 } 99 }
100 } 100 }
......
...@@ -31,14 +31,16 @@ class PoemPublish extends StatefulWidget { ...@@ -31,14 +31,16 @@ class PoemPublish extends StatefulWidget {
31 final String data; 31 final String data;
32 32
33 @override 33 @override
34 - _PoemPublishState createState() => _PoemPublishState(); 34 + PoemPublishState createState() => PoemPublishState();
35 } 35 }
36 36
37 -class _PoemPublishState extends State<PoemPublish> { 37 +class PoemPublishState extends State<PoemPublish> {
38 bool isPublishing = false; 38 bool isPublishing = false;
39 String _langSortName = "普通话"; 39 String _langSortName = "普通话";
40 int _langSortId = 1; //TODO 传入服务器的口音ID 40 int _langSortId = 1; //TODO 传入服务器的口音ID
41 String _address = '我在此地'; 41 String _address = '我在此地';
42 + String _longitude = "";
43 + String _latitude = "";
42 final LangSortProvider _provider = LangSortProvider(); 44 final LangSortProvider _provider = LangSortProvider();
43 45
44 final TextEditingController _msgController = TextEditingController(); 46 final TextEditingController _msgController = TextEditingController();
...@@ -106,6 +108,8 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -106,6 +108,8 @@ class _PoemPublishState extends State<PoemPublish> {
106 context, PoemRouter.addressSelectPage, (result) { 108 context, PoemRouter.addressSelectPage, (result) {
107 setState(() { 109 setState(() {
108 final PoiSearch model = result as PoiSearch; 110 final PoiSearch model = result as PoiSearch;
111 + _longitude = model.longitude!;
112 + _latitude = model.latitude!;
109 _address = 113 _address =
110 '${model.provinceName!} ${model.cityName!} ${model.adName!} ${model.title!}'; 114 '${model.provinceName!} ${model.cityName!} ${model.adName!} ${model.title!}';
111 }); 115 });
...@@ -246,13 +250,16 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -246,13 +250,16 @@ class _PoemPublishState extends State<PoemPublish> {
246 params: formData, 250 params: formData,
247 onSuccess: (data) { 251 onSuccess: (data) {
248 String path = data!.data!.relativePath!; 252 String path = data!.data!.relativePath!;
249 - String videoId = '${widget.id}'; //TODO 临时用video id 253 + String videoId = '${widget.id}';
250 254
251 Map<String, String> params = <String, String>{ 255 Map<String, String> params = <String, String>{
252 "item_id": videoId, 256 "item_id": videoId,
253 "item_url": path, 257 "item_url": path,
254 "content": msg, 258 "content": msg,
255 "type": '${widget.type}', 259 "type": '${widget.type}',
260 + "longitude": _longitude,
261 + "latitude": _latitude,
262 + "location": _address,
256 }; 263 };
257 DioUtils.instance.asyncRequestNetwork( 264 DioUtils.instance.asyncRequestNetwork(
258 Method.post, 265 Method.post,
...@@ -273,6 +280,7 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -273,6 +280,7 @@ class _PoemPublishState extends State<PoemPublish> {
273 ); 280 );
274 }, 281 },
275 onError: (code, msg) { 282 onError: (code, msg) {
283 + Toast.show(msg.toString());
276 isPublishing = false; 284 isPublishing = false;
277 setState(() {}); 285 setState(() {});
278 }, 286 },
...@@ -301,7 +309,8 @@ class _PoemPublishState extends State<PoemPublish> { ...@@ -301,7 +309,8 @@ class _PoemPublishState extends State<PoemPublish> {
301 TextButton( 309 TextButton(
302 child: const Text("残忍放弃"), 310 child: const Text("残忍放弃"),
303 onPressed: () { 311 onPressed: () {
304 - NavigatorUtils.push(context, Routes.home, clearStack: true); 312 + NavigatorUtils.push(context, Routes.navBarPage,
313 + clearStack: true);
305 }, 314 },
306 ), 315 ),
307 ], 316 ],
......
1 import 'dart:async'; 1 import 'dart:async';
2 import 'dart:io'; 2 import 'dart:io';
3 3
4 +import 'package:Parlando/net/dio_utils.dart';
5 +import 'package:Parlando/net/http_api.dart';
6 +import 'package:Parlando/poem/models/poem_entity.dart';
4 import 'package:camera/camera.dart'; 7 import 'package:camera/camera.dart';
5 import 'package:flutter/material.dart'; 8 import 'package:flutter/material.dart';
6 import 'package:flutter/services.dart'; 9 import 'package:flutter/services.dart';
...@@ -18,12 +21,14 @@ import '../poem_router.dart'; ...@@ -18,12 +21,14 @@ import '../poem_router.dart';
18 21
19 class PoemRecordVideoPage extends StatefulWidget { 22 class PoemRecordVideoPage extends StatefulWidget {
20 final int id; 23 final int id;
24 + final int poemId;
21 final int type; 25 final int type;
22 26
23 const PoemRecordVideoPage({ 27 const PoemRecordVideoPage({
24 Key? key, 28 Key? key,
25 required this.id, 29 required this.id,
26 required this.type, 30 required this.type,
31 + required this.poemId,
27 }) : super(key: key); 32 }) : super(key: key);
28 33
29 @override 34 @override
...@@ -36,7 +41,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -36,7 +41,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
36 VideoPlayerController? videoController; 41 VideoPlayerController? videoController;
37 42
38 File? _videoFile; // 保存的视频文件位置,用于上传视频的时候用! 43 File? _videoFile; // 保存的视频文件位置,用于上传视频的时候用!
39 - 44 + PoemData? _poem;
40 final bool _isVideoCameraSelected = true; 45 final bool _isVideoCameraSelected = true;
41 bool _isCameraInitialized = false; 46 bool _isCameraInitialized = false;
42 bool _isRearCameraSelected = true; 47 bool _isRearCameraSelected = true;
...@@ -69,9 +74,11 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -69,9 +74,11 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
69 } 74 }
70 }); 75 });
71 76
77 + fetchPoemDetail();
78 +
72 _timer = PausableTimer( 79 _timer = PausableTimer(
73 const Duration(milliseconds: 100), 80 const Duration(milliseconds: 100),
74 - () { 81 + () {
75 currentTimer += 100; 82 currentTimer += 100;
76 _timer 83 _timer
77 ..reset() 84 ..reset()
...@@ -85,6 +92,19 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -85,6 +92,19 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
85 super.initState(); 92 super.initState();
86 } 93 }
87 94
95 + Future<void> fetchPoemDetail() async {
96 + DioUtils.instance.asyncRequestNetwork<PoemEntity>(
97 + Method.get,
98 + "${HttpApi.poem}/${widget.poemId}",
99 + params: [],
100 + onSuccess: (data) {
101 + _poem = data!.data!;
102 + setState(() {});
103 + },
104 + onError: (code, msg) {},
105 + );
106 + }
107 +
88 Future<List<CameraDescription>?> initCameras() async { 108 Future<List<CameraDescription>?> initCameras() async {
89 try { 109 try {
90 WidgetsFlutterBinding.ensureInitialized(); 110 WidgetsFlutterBinding.ensureInitialized();
...@@ -262,16 +282,19 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -262,16 +282,19 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
262 ); 282 );
263 // TODO why pause!直接使用cancel()会出现问题,暂时这么解决 283 // TODO why pause!直接使用cancel()会出现问题,暂时这么解决
264 _timer.pause(); 284 _timer.pause();
265 - 285 + _gotoNext(currentUnix, fileFormat);
266 - NavigatorUtils.push(
267 - context,
268 - '${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat&id=${widget.id}&type=${widget.type}',
269 - );
270 } catch (e) { 286 } catch (e) {
271 // print(e); 287 // print(e);
272 } 288 }
273 } 289 }
274 290
291 + void _gotoNext(int currentUnix, String fileFormat) {
292 + NavigatorUtils.push(
293 + context,
294 + '${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat&id=${widget.id}&poemId=${widget.poemId}&type=${widget.type}',
295 + );
296 + }
297 +
275 @override 298 @override
276 Widget build(BuildContext context) { 299 Widget build(BuildContext context) {
277 return SafeArea( 300 return SafeArea(
...@@ -290,7 +313,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -290,7 +313,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
290 crossAxisAlignment: CrossAxisAlignment.start, 313 crossAxisAlignment: CrossAxisAlignment.start,
291 children: [ 314 children: [
292 Text( 315 Text(
293 - "题破山寺后禅院", 316 + _poem != null ? _poem!.title.toString() : "",
294 style: TextStyle( 317 style: TextStyle(
295 color: Colors.white, 318 color: Colors.white,
296 fontSize: 28.px, 319 fontSize: 28.px,
...@@ -298,7 +321,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -298,7 +321,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
298 ), 321 ),
299 Gaps.vGap10, 322 Gaps.vGap10,
300 Text( 323 Text(
301 - "常建", 324 + _poem != null ? _poem!.author.toString() : "",
302 style: TextStyle( 325 style: TextStyle(
303 color: Colors.white, 326 color: Colors.white,
304 fontSize: 15.px, 327 fontSize: 15.px,
...@@ -306,7 +329,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> ...@@ -306,7 +329,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
306 ), 329 ),
307 Gaps.vGap5, 330 Gaps.vGap5,
308 Text( 331 Text(
309 - "清晨入古寺,\n初日照高林。\n曲径通幽处,\n禅房花木深。\n山光悦鸟性,\n潭影空人心。\n万籁此都寂,\n但余钟磬音。\n", 332 + _poem != null ? _poem!.content.toString() : "",
310 style: TextStyle( 333 style: TextStyle(
311 color: Colors.white, 334 color: Colors.white,
312 fontFamily: "ZCOOLXiaoWei", 335 fontFamily: "ZCOOLXiaoWei",
......
...@@ -6,6 +6,9 @@ import 'package:Parlando/widgets/my_app_bar.dart'; ...@@ -6,6 +6,9 @@ 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 import 'package:path_provider/path_provider.dart';
8 8
9 +import '../../net/dio_utils.dart';
10 +import '../../net/http_api.dart';
11 +import '../models/poem_entity.dart';
9 import '../poem_router.dart'; 12 import '../poem_router.dart';
10 13
11 class PoemVideoPlayer extends StatefulWidget { 14 class PoemVideoPlayer extends StatefulWidget {
...@@ -13,6 +16,7 @@ class PoemVideoPlayer extends StatefulWidget { ...@@ -13,6 +16,7 @@ class PoemVideoPlayer extends StatefulWidget {
13 final String? title; 16 final String? title;
14 final int id; 17 final int id;
15 final int type; 18 final int type;
19 + final int poemId;
16 20
17 const PoemVideoPlayer({ 21 const PoemVideoPlayer({
18 Key? key, 22 Key? key,
...@@ -20,16 +24,18 @@ class PoemVideoPlayer extends StatefulWidget { ...@@ -20,16 +24,18 @@ class PoemVideoPlayer extends StatefulWidget {
20 this.title, 24 this.title,
21 required this.id, 25 required this.id,
22 required this.type, 26 required this.type,
27 + required this.poemId,
23 }) : super(key: key); 28 }) : super(key: key);
24 29
25 @override 30 @override
26 - _PoemVideoPlayerState createState() => _PoemVideoPlayerState(); 31 + PoemVideoPlayerState createState() => PoemVideoPlayerState();
27 } 32 }
28 33
29 -class _PoemVideoPlayerState extends State<PoemVideoPlayer> { 34 +class PoemVideoPlayerState extends State<PoemVideoPlayer> {
30 final FijkPlayer player = FijkPlayer(); 35 final FijkPlayer player = FijkPlayer();
36 + PoemData? _poem;
31 37
32 - _PoemVideoPlayerState(); 38 + PoemVideoPlayerState();
33 39
34 Future<String> _getDir() async { 40 Future<String> _getDir() async {
35 final directory = await getApplicationDocumentsDirectory(); 41 final directory = await getApplicationDocumentsDirectory();
...@@ -40,13 +46,28 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -40,13 +46,28 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
40 void initState() { 46 void initState() {
41 super.initState(); 47 super.initState();
42 _getDir().then((value) { 48 _getDir().then((value) {
43 - String path = "$value/" + widget.url; 49 + String path = "$value/${widget.url}";
44 player.setDataSource( 50 player.setDataSource(
45 path, 51 path,
46 autoPlay: true, 52 autoPlay: true,
47 ); 53 );
48 player.setLoop(0); 54 player.setLoop(0);
49 }); 55 });
56 +
57 + fetchPoemDetail();
58 + }
59 +
60 + Future<void> fetchPoemDetail() async {
61 + DioUtils.instance.asyncRequestNetwork<PoemEntity>(
62 + Method.get,
63 + "${HttpApi.poem}/${widget.poemId}",
64 + params: [],
65 + onSuccess: (data) {
66 + _poem = data!.data!;
67 + setState(() {});
68 + },
69 + onError: (code, msg) {},
70 + );
50 } 71 }
51 72
52 @override 73 @override
...@@ -76,7 +97,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -76,7 +97,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
76 crossAxisAlignment: CrossAxisAlignment.start, 97 crossAxisAlignment: CrossAxisAlignment.start,
77 children: [ 98 children: [
78 Text( 99 Text(
79 - "题破山寺后禅院", 100 + _poem != null ? _poem!.title.toString() : "",
80 style: TextStyle( 101 style: TextStyle(
81 color: Colors.white, 102 color: Colors.white,
82 fontSize: 28.px, 103 fontSize: 28.px,
...@@ -84,7 +105,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -84,7 +105,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
84 ), 105 ),
85 Gaps.vGap10, 106 Gaps.vGap10,
86 Text( 107 Text(
87 - "常建", 108 + _poem != null ? _poem!.author.toString() : "",
88 style: TextStyle( 109 style: TextStyle(
89 color: Colors.white, 110 color: Colors.white,
90 fontSize: 15.px, 111 fontSize: 15.px,
...@@ -92,7 +113,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> { ...@@ -92,7 +113,7 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
92 ), 113 ),
93 Gaps.vGap5, 114 Gaps.vGap5,
94 Text( 115 Text(
95 - "清晨入古寺,\n初日照高林。\n曲径通幽处,\n禅房花木深。\n山光悦鸟性,\n潭影空人心。\n万籁此都寂,\n但余钟磬音。\n", 116 + _poem != null ? _poem!.content.toString() : "",
96 style: TextStyle( 117 style: TextStyle(
97 color: Colors.white, 118 color: Colors.white,
98 fontFamily: "ZCOOLXiaoWei", 119 fontFamily: "ZCOOLXiaoWei",
......
...@@ -62,10 +62,12 @@ class PoemRouter implements IRouterProvider { ...@@ -62,10 +62,12 @@ 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 + int? poem = int.parse(params['poem']!.first);
65 String? type = params['type']?.first; 66 String? type = params['type']?.first;
66 return PoemRecordVideoPage( 67 return PoemRecordVideoPage(
67 id: int.parse(id!), 68 id: int.parse(id!),
68 type: int.parse(type!), 69 type: int.parse(type!),
70 + poemId: poem,
69 ); 71 );
70 }, 72 },
71 ), 73 ),
...@@ -78,10 +80,12 @@ class PoemRouter implements IRouterProvider { ...@@ -78,10 +80,12 @@ class PoemRouter implements IRouterProvider {
78 String? url = params['url']?.first; 80 String? url = params['url']?.first;
79 String? id = params['id']?.first; 81 String? id = params['id']?.first;
80 String? type = params['type']?.first; 82 String? type = params['type']?.first;
83 + int? poem = int.parse(params['poemId']!.first);
81 return PoemVideoPlayer( 84 return PoemVideoPlayer(
82 url: url!, 85 url: url!,
83 id: int.parse(id!), 86 id: int.parse(id!),
84 type: int.parse(type!), 87 type: int.parse(type!),
88 + poemId: poem,
85 ); 89 );
86 }, 90 },
87 ), 91 ),
......