reason

修改了视频发布流程

import 'dart:async';
import 'package:Parlando/account/account_router.dart';
import 'package:Parlando/events/trans_event.dart';
import 'package:Parlando/home/models/home_entity.dart';
import 'package:Parlando/home/provider/home_provider.dart';
import 'package:Parlando/net/dio_utils.dart';
import 'package:Parlando/net/http_api.dart';
import 'package:Parlando/util/toast_utils.dart';
import 'package:animated_radial_menu/animated_radial_menu.dart';
import 'package:flutter/material.dart';
import 'package:Parlando/category/category_router.dart';
import 'package:Parlando/poem/poem_router.dart';
......@@ -21,20 +24,22 @@ import 'package:Parlando/tiktok/widgets/tiktok_video_poem.dart';
import 'package:Parlando/widgets/bars/home_types_bar.dart';
import 'package:Parlando/widgets/my_app_bar.dart';
import 'package:getwidget/getwidget.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';
import 'poem_detail.dart';
import 'package:Parlando/extension/int_extension.dart';
import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
class PoemPage extends StatefulWidget {
const PoemPage({Key? key}) : super(key: key);
@override
_PoemPageState createState() => _PoemPageState();
PoemPageState createState() => PoemPageState();
}
class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
class PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
TikTokScaffoldController tkController = TikTokScaffoldController();
final PageController _pageController = PageController();
final TikTokVideoListController _videoListController =
......@@ -43,6 +48,9 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
late StreamSubscription bus;
bool isLoading = false;
String currentPoemId = '';
String currentPoemType = '';
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
if (state != AppLifecycleState.resumed) {
......@@ -76,9 +84,13 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
image: '',
url: data.url!,
desc: data.content,
poemId: '${data.poemId}',
poemType: '${data.type}',
),
);
}
currentPoemId = videoDataList.first.poemId;
currentPoemType = videoDataList.first.poemType;
_videoListController.init(
pageController: _pageController,
initialList: videoDataList
......@@ -89,6 +101,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
),
)
.toList(),
//TODO 增量加载
videoProvider: (int index, List<VPVideoController> list) async {
return videoDataList
.map(
......@@ -184,6 +197,12 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
page: Stack(
children: <Widget>[
PageView.builder(
onPageChanged: (p) {
currentPoemId =
_videoListController.currentPlayer.videoInfo!.poemId;
currentPoemType =
_videoListController.currentPlayer.videoInfo!.poemType;
},
key: const Key('home'),
physics: const QuickerScrollPhysics(),
controller: _pageController,
......@@ -205,7 +224,7 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
Widget poem = TikTokVidePoem(
title: "每日一言",
poem:
"清晨入古寺,初日照高林。\n曲径通幽处,禅房花木深。\n山光悦鸟性,潭影空人心。\n万籁此都寂,但余钟磬音。\n",
"清晨入古寺,初日照高林。\n曲径通幽处,禅房花木深。\n山光悦鸟性,潭影空人心。\n万籁此都寂,但余钟磬音。\n",
author: "----《题破山寺后禅院》常建",
onShowDetail: () {
tkController.animateToPage(TikTokPagePosition.right);
......@@ -247,6 +266,86 @@ class _PoemPageState extends State<PoemPage> with WidgetsBindingObserver {
currentPage ?? Container(),
],
),
floatingActionButton: SizedBox(
height: 60,
child: RadialMenu(
children: [
RadialButton(
icon: const Icon(Icons.video_call_outlined),
buttonColor: Colors.teal,
onPress: () {
String url =
'${PoemRouter.poemRecordVideoPage}?id=$currentPoemId&type=$currentPoemType';
print("===========================" + url);
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
url,
);
}),
RadialButton(
icon: const Icon(Icons.mic_none_outlined),
buttonColor: Colors.green,
onPress: () {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
'${PoemRouter.poemRecordAudioPage}?id=$currentPoemId&type=$currentPoemType',
);
}),
],
),
),
bottomNavigationBar: Consumer<HomeProvider>(
builder: (_, provider, __) {
return BottomAppBar(
color: Colors.grey,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
InkWell(
onTap: () {},
child: Container(
alignment: Alignment.center,
height: 36.0,
child: Text(
ParlandoLocalizations.of(context)
.onePoemBottomNavigationBarItemTitle,
style: const TextStyle(
color: Colors.white54,
fontSize: 15.0,
),
),
),
),
InkWell(
onTap: () {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
AccountRouter.accountPage,
);
},
child: Container(
alignment: Alignment.center,
height: 36.0,
child: Text(
ParlandoLocalizations.of(context)
.profileBottomNavigationBarItemTitle,
style: const TextStyle(
color: Colors.white54,
fontSize: 15.0,
),
),
),
),
]),
);
},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
);
}
}
......
......@@ -19,8 +19,15 @@ import 'package:path_provider/path_provider.dart';
import '../poem_router.dart';
class PoemPublish extends StatefulWidget {
const PoemPublish({Key? key, required this.data}) : super(key: key);
const PoemPublish({
Key? key,
required this.data,
required this.id,
required this.type,
}) : super(key: key);
final int id;
final int type;
final String data;
@override
......@@ -214,7 +221,7 @@ class _PoemPublishState extends State<PoemPublish> {
Future<dynamic> _getUploadVideo() async {
final directory = await getApplicationDocumentsDirectory();
dynamic video = await MultipartFile.fromFile(
directory.path + "/" + widget.data,
"${directory.path}/${widget.data}",
filename: "video.mp4");
return video;
}
......@@ -239,12 +246,13 @@ class _PoemPublishState extends State<PoemPublish> {
params: formData,
onSuccess: (data) {
String path = data!.data!.relativePath!;
String videoId = "1"; //TODO 临时用video id
String videoId = '${widget.id}'; //TODO 临时用video id
Map<String, String> params = <String, String>{
"video_id": videoId,
"video_url": path,
"item_id": videoId,
"item_url": path,
"content": msg,
"type": '${widget.type}',
};
DioUtils.instance.asyncRequestNetwork(
Method.post,
......
......@@ -16,13 +16,20 @@ import 'package:Parlando/extension/int_extension.dart';
import '../poem_router.dart';
class PoemRecordVideoPage extends StatefulWidget {
const PoemRecordVideoPage({Key? key}) : super(key: key);
final int id;
final int type;
const PoemRecordVideoPage({
Key? key,
required this.id,
required this.type,
}) : super(key: key);
@override
_PoemRecordVideoPageState createState() => _PoemRecordVideoPageState();
PoemRecordVideoPageState createState() => PoemRecordVideoPageState();
}
class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
class PoemRecordVideoPageState extends State<PoemRecordVideoPage>
with WidgetsBindingObserver {
CameraController? controller;
VideoPlayerController? videoController;
......@@ -255,7 +262,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
NavigatorUtils.push(
context,
'${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat',
'${PoemRouter.poemVideoPlayer}?url=$currentUnix.$fileFormat&id=${widget.id}&type=${widget.type}',
);
} catch (e) {
// print(e);
......
......@@ -11,11 +11,15 @@ import '../poem_router.dart';
class PoemVideoPlayer extends StatefulWidget {
final String url;
final String? title;
final int id;
final int type;
const PoemVideoPlayer({
Key? key,
required this.url,
this.title,
required this.id,
required this.type,
}) : super(key: key);
@override
......@@ -118,18 +122,18 @@ class _PoemVideoPlayerState extends State<PoemVideoPlayer> {
right: 20.px,
child: ElevatedButton(
onPressed: () {
NavigatorUtils.push(
context, '${PoemRouter.poemPublish}?data=' + widget.url,
NavigatorUtils.push(context,
'${PoemRouter.poemPublish}?data=${widget.url}&id=${widget.id}&type=${widget.type}',
clearStack: true);
},
child: Text(
"下一步",
style: TextStyle(fontSize: 15.px),
),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Colors.black54,
),
child: Text(
"下一步",
style: TextStyle(fontSize: 15.px),
),
),
),
],
......
......@@ -62,9 +62,11 @@ class PoemRouter implements IRouterProvider {
handler: Handler(
handlerFunc: (_, Map<String, List<String>> params) {
String? id = params['id']?.first;
return const PoemRecordVideoPage(
// poemId: int.parse(id!),
);
String? type = params['type']?.first;
return PoemRecordVideoPage(
id: int.parse(id!),
type: int.parse(type!),
);
},
),
);
......@@ -74,8 +76,12 @@ class PoemRouter implements IRouterProvider {
handler: Handler(
handlerFunc: (_, Map<String, List<String>> params) {
String? url = params['url']?.first;
String? id = params['id']?.first;
String? type = params['type']?.first;
return PoemVideoPlayer(
url: url!,
id: int.parse(id!),
type: int.parse(type!),
);
},
),
......@@ -85,8 +91,12 @@ class PoemRouter implements IRouterProvider {
handler: Handler(
handlerFunc: (_, Map<String, List<String>> params) {
String? data = params['data']?.first;
String? id = params['id']?.first;
String? type = params['type']?.first;
return PoemPublish(
data: data!,
id: int.parse(id!),
type: int.parse(type!),
);
},
),
......
......@@ -11,23 +11,17 @@ class UserVideo {
final String url;
final String image;
final String? desc;
final String poemId;
final String poemType;
UserVideo({
required this.url,
required this.image,
this.desc,
required this.poemId,
required this.poemType,
});
static List<UserVideo> fetchVideo() {
List<UserVideo> list = videoList
.map((e) => UserVideo(
image: '',
url: 'assets/data/$e',
desc: '清晨入古寺,初日照高林。\n竹径通幽处,禅房花木深。'))
.toList();
return list;
}
@override
String toString() {
return 'image:$image' '\nvideo:$url';
......
import 'dart:math';
import 'package:Parlando/account/account_router.dart';
import 'package:Parlando/events/trans_event.dart';
import 'package:Parlando/home/provider/home_provider.dart';
import 'package:Parlando/poem/poem_router.dart';
import 'package:Parlando/routers/fluro_navigator.dart';
import 'package:animated_radial_menu/animated_radial_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:Parlando/tiktok/style/style.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
const double scrollSpeed = 300;
......@@ -65,7 +57,9 @@ class TikTokScaffold extends StatefulWidget {
final bool? enableGesture;
final Widget? page;
final Widget? floatingActionButton;
final Widget? bottomNavigationBar;
final FloatingActionButtonLocation? floatingActionButtonLocation;
final Function()? onPullDownRefresh;
const TikTokScaffold({
......@@ -80,6 +74,9 @@ class TikTokScaffold extends StatefulWidget {
this.enableGesture,
this.onPullDownRefresh,
this.controller,
this.floatingActionButton,
this.bottomNavigationBar,
this.floatingActionButtonLocation,
}) : super(key: key);
@override
......@@ -193,82 +190,9 @@ class _TikTokScaffoldState extends State<TikTokScaffold>
body: body,
backgroundColor: Colors.black,
resizeToAvoidBottomInset: false,
floatingActionButton: SizedBox(
height: 60,
child: RadialMenu(
children: [
RadialButton(
icon: const Icon(Icons.video_call_outlined),
buttonColor: Colors.teal,
onPress: () {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
'${PoemRouter.poemRecordVideoPage}?data=100',
);
}),
RadialButton(
icon: const Icon(Icons.mic_none_outlined),
buttonColor: Colors.green,
onPress: () {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
'${PoemRouter.poemRecordAudioPage}?id=100',
);
}),
],
),
),
bottomNavigationBar: Consumer<HomeProvider>(
builder: (_, provider, __) {
return BottomAppBar(
color: Colors.grey,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
InkWell(
onTap: () {},
child: Container(
alignment: Alignment.center,
height: 36.0,
child: Text(
ParlandoLocalizations.of(context)
.onePoemBottomNavigationBarItemTitle,
style: const TextStyle(
color: Colors.white54,
fontSize: 15.0,
),
),
),
),
InkWell(
onTap: () {
eventBus.fire(TransEvent());
NavigatorUtils.push(
context,
AccountRouter.accountPage,
);
},
child: Container(
alignment: Alignment.center,
height: 36.0,
child: Text(
ParlandoLocalizations.of(context)
.profileBottomNavigationBarItemTitle,
style: const TextStyle(
color: Colors.white54,
fontSize: 15.0,
),
),
),
),
]),
);
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: widget.floatingActionButton,
bottomNavigationBar: widget.bottomNavigationBar,
floatingActionButtonLocation: widget.floatingActionButtonLocation,
),
);
return body;
......