- [x] 点击去直播

- [x] 图片背景色
- [x] 视频录制后后台仍在播放
- [x] 商品搜索多选
master
laiiihz 5 years ago
parent 03ec3902dc
commit a04a69b672

@ -1,4 +1,5 @@
import 'package:chewie/chewie.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:many_like/many_like.dart';
import 'package:recook/constants/api.dart';
@ -26,15 +27,20 @@ class _LivePlaybackViewPageState extends State<LivePlaybackViewPage> {
LiveStreamInfoModel _streamInfoModel;
VideoPlayerController _videoPlayerController;
ChewieController _chewieController;
bool upload = false;
@override
void initState() {
super.initState();
getPlaybackInfoModel().then((model) {
if (model == null)
Navigator.pop(context);
else {
if (model == null) Navigator.pop(context);
if (TextUtil.isEmpty(model.playUrl)) {
setState(() {
upload = true;
});
} else {
setState(() {
upload = false;
_streamInfoModel = model;
});
_videoPlayerController = VideoPlayerController.network(model.playUrl);
@ -75,176 +81,187 @@ class _LivePlaybackViewPageState extends State<LivePlaybackViewPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black87,
body: _streamInfoModel == null
? Center(child: CircularProgressIndicator())
: Stack(
children: [
Positioned(
bottom: 0,
left: 0,
right: 0,
top: 0,
child: _chewieController == null
? Center(
child: CircularProgressIndicator(),
)
: Chewie(
controller: _chewieController,
),
body: upload
? Center(
child: Text(
'录播上传中',
style: TextStyle(
color: Colors.white,
fontSize: rSP(20),
),
//
AnimatedPositioned(
top: _showTools
? MediaQuery.of(context).padding.top
: -rSize(52),
left: 0,
right: 0,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
child: Padding(
padding: EdgeInsets.only(
left: rSize(15),
top: rSize(15),
),
)
: _streamInfoModel == null
? Center(child: CircularProgressIndicator())
: Stack(
children: [
Positioned(
bottom: 0,
left: 0,
right: 0,
top: 0,
child: _chewieController == null
? Center(
child: CircularProgressIndicator(),
)
: Chewie(
controller: _chewieController,
),
),
child: Row(
children: [
LiveUserBar(
initAttention: _streamInfoModel.userId ==
UserManager.instance.user.info.id
? true
: _streamInfoModel.isFollow == 1,
onAttention: () {
HttpManager.post(
LiveAPI.addFollow,
{'followUserId': _streamInfoModel.userId},
);
},
title: _streamInfoModel.nickname,
subTitle: '点赞数 ${_streamInfoModel.praise}',
avatar: _streamInfoModel.headImgUrl,
//
AnimatedPositioned(
top: _showTools
? MediaQuery.of(context).padding.top
: -rSize(52),
left: 0,
right: 0,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
child: Padding(
padding: EdgeInsets.only(
left: rSize(15),
top: rSize(15),
),
Spacer(),
],
),
),
),
//
Positioned(
top: MediaQuery.of(context).padding.top + rSize(24),
right: 0,
child: CustomImageButton(
padding: EdgeInsets.symmetric(horizontal: rSize(15)),
icon: Icon(
Icons.clear,
color: Colors.white,
),
onPressed: () => Navigator.pop(context),
),
),
//
AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
bottom: _showTools ? 0 : -rSize(15 + 44.0),
left: 0,
right: 0,
child: Padding(
padding: EdgeInsets.only(
left: rSize(15),
right: rSize(15),
bottom: rSize(15),
),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
child: Row(
children: [
CustomImageButton(
onPressed: () {
ActionSheet.show(
context,
items: ['举报'],
listener: (index) {
Navigator.pop(context);
//fake
Future.delayed(Duration(milliseconds: 1000),
() {
GSDialog.of(context)
.showSuccess(context, '举报成功');
});
},
);
},
child: Image.asset(
R.ASSETS_LIVE_LIVE_MORE_PNG,
width: rSize(32),
height: rSize(32),
),
),
// SizedBox(width: rSize(10)),
// Image.asset(
// R.ASSETS_LIVE_LIVE_SHARE_PNG,
// width: rSize(32),
// height: rSize(32),
// ),
SizedBox(width: rSize(10)),
ManyLikeButton(
child: Image.asset(
R.ASSETS_LIVE_LIVE_LIKE_PNG,
width: rSize(32),
height: rSize(32),
),
popChild: Image.asset(
R.ASSETS_LIVE_LIVE_LIKE_PNG,
width: rSize(32),
height: rSize(32),
),
onTap: () {
LiveUserBar(
initAttention: _streamInfoModel.userId ==
UserManager.instance.user.info.id
? true
: _streamInfoModel.isFollow == 1,
onAttention: () {
HttpManager.post(
LiveAPI.liveLike,
{'liveItemId': widget.id},
LiveAPI.addFollow,
{'followUserId': _streamInfoModel.userId},
);
},
title: _streamInfoModel.nickname,
subTitle: '点赞数 ${_streamInfoModel.praise}',
avatar: _streamInfoModel.headImgUrl,
),
SizedBox(width: rSize(10)),
Spacer(),
CustomImageButton(
child: Container(
alignment: Alignment.bottomCenter,
width: rSize(44),
height: rSize(44),
child: Text(
_streamInfoModel.goodsLists.length.toString(),
style: TextStyle(
color: Colors.white,
fontSize: rSP(13),
height: 28 / 13,
],
),
),
),
//
Positioned(
top: MediaQuery.of(context).padding.top + rSize(24),
right: 0,
child: CustomImageButton(
padding: EdgeInsets.symmetric(horizontal: rSize(15)),
icon: Icon(
Icons.clear,
color: Colors.white,
),
onPressed: () => Navigator.pop(context),
),
),
//
AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
bottom: _showTools ? 0 : -rSize(15 + 44.0),
left: 0,
right: 0,
child: Padding(
padding: EdgeInsets.only(
left: rSize(15),
right: rSize(15),
bottom: rSize(15),
),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
CustomImageButton(
onPressed: () {
ActionSheet.show(
context,
items: ['举报'],
listener: (index) {
Navigator.pop(context);
//fake
Future.delayed(
Duration(milliseconds: 1000), () {
GSDialog.of(context)
.showSuccess(context, '举报成功');
});
},
);
},
child: Image.asset(
R.ASSETS_LIVE_LIVE_MORE_PNG,
width: rSize(32),
height: rSize(32),
),
),
decoration: BoxDecoration(
image: DecorationImage(
image:
AssetImage(R.ASSETS_LIVE_LIVE_GOOD_PNG),
// SizedBox(width: rSize(10)),
// Image.asset(
// R.ASSETS_LIVE_LIVE_SHARE_PNG,
// width: rSize(32),
// height: rSize(32),
// ),
SizedBox(width: rSize(10)),
ManyLikeButton(
child: Image.asset(
R.ASSETS_LIVE_LIVE_LIKE_PNG,
width: rSize(32),
height: rSize(32),
),
popChild: Image.asset(
R.ASSETS_LIVE_LIVE_LIKE_PNG,
width: rSize(32),
height: rSize(32),
),
onTap: () {
HttpManager.post(
LiveAPI.liveLike,
{'liveItemId': widget.id},
);
},
),
),
onPressed: () {
showGoodsListDialog(
context,
models: _streamInfoModel.goodsLists,
onLive: false,
);
},
SizedBox(width: rSize(10)),
Spacer(),
CustomImageButton(
child: Container(
alignment: Alignment.bottomCenter,
width: rSize(44),
height: rSize(44),
child: Text(
_streamInfoModel.goodsLists.length
.toString(),
style: TextStyle(
color: Colors.white,
fontSize: rSP(13),
height: 28 / 13,
),
),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
R.ASSETS_LIVE_LIVE_GOOD_PNG),
),
),
),
onPressed: () {
showGoodsListDialog(
context,
models: _streamInfoModel.goodsLists,
onLive: false,
);
},
),
],
),
],
),
],
),
),
),
],
),
],
),
);
}
}

@ -91,7 +91,8 @@ class _PickSearchGoodsPageState extends State<PickSearchGoodsPage> {
itemBuilder: (context, index) {
return LiveGoodsCard(
onPick: () {
Navigator.pop(context);
setState(() {});
// Navigator.pop(context);
},
model: _goodsModels[index]);
},

@ -43,11 +43,17 @@ class _LiveGoodsCardState extends State<LiveGoodsCard> {
children: [
RecookCheckBox(state: picked),
rWBox(10),
FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
image: Api.getImgUrl(widget.model.mainPhotoUrl),
height: rSize(86),
width: rSize(86),
ClipRRect(
borderRadius: BorderRadius.circular(rSize(4)),
child: Container(
color: AppColor.frenchColor,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
image: Api.getImgUrl(widget.model.mainPhotoUrl),
height: rSize(86),
width: rSize(86),
),
),
),
rWBox(10),
Expanded(

@ -3,11 +3,13 @@ import 'package:recook/constants/api.dart';
import 'package:recook/constants/header.dart';
import 'package:recook/manager/http_manager.dart';
import 'package:recook/manager/user_manager.dart';
import 'package:recook/pages/live/live_stream/live_page.dart';
import 'package:recook/pages/live/models/live_base_info_model.dart';
import 'package:recook/pages/live/models/live_time_data_model.dart';
import 'package:recook/pages/live/pages/goods_window_page.dart';
import 'package:recook/pages/live/sub_page/data_manager_page.dart';
import 'package:recook/utils/custom_route.dart';
import 'package:recook/utils/permission_tool.dart';
import 'package:recook/widgets/recook_back_button.dart';
import 'package:recook/widgets/recook_indicator.dart';
@ -56,7 +58,13 @@ class _LiveHostCenterPageState extends State<LiveHostCenterPage>
actions: [
FlatButton(
splashColor: Color(0xFFDB2D2D).withOpacity(0.3),
onPressed: () {},
onPressed: () {
PermissionTool.haveCameraPermission().then((value) {
PermissionTool.haveAudioPermission().then((value) {
CRoute.pushReplace(context, LivePage());
});
});
},
child: Text(
'去开播',
style: TextStyle(

@ -39,6 +39,7 @@ class _LocalFileVideoState extends State<LocalFileVideo> {
@override
void dispose() {
_videoPlayerController?.dispose();
_chewieController?.dispose();
super.dispose();
}

@ -144,8 +144,12 @@ class _TabBarWidgetState extends State<TabBarWidget>
R.ASSETS_LIVE_ADD_STREAM_PNG,
onTap: () {
PermissionTool.haveCameraPermission()
.then((value) {});
CRoute.push(context, LivePage());
.then((value) {
PermissionTool.haveAudioPermission()
.then((value) {
CRoute.push(context, LivePage());
});
});
},
),
verticalButton(

@ -1,66 +1,64 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
class PermissionTool{
class PermissionTool {
static Future<bool> haveCameraPermission() async {
Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.camera]);
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler().requestPermissions([PermissionGroup.camera]);
if (permissions[PermissionGroup.camera] == PermissionStatus.granted) {
return true;
}else{
} else {
return false;
}
}
static Future<bool> havePhotoPermission() async {
Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.photos]);
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler().requestPermissions([PermissionGroup.photos]);
if (permissions[PermissionGroup.photos] == PermissionStatus.granted) {
return true;
}else{
} else {
return false;
}
}
static Future<bool> haveAudioPermission() async {
Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.microphone]);
if (permissions[PermissionGroup.photos] == PermissionStatus.granted) {
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler()
.requestPermissions([PermissionGroup.microphone]);
if (permissions[PermissionGroup.microphone] == PermissionStatus.granted) {
return true;
}else{
} else {
return false;
}
}
static showOpenPermissionDialog(BuildContext context, String message,{Function open}){
static showOpenPermissionDialog(BuildContext context, String message,
{Function open}) {
showCupertinoDialog<int>(
context: context,
builder: (context){
return CupertinoAlertDialog(
title: Text("权限"),
content: Text(message),
actions: <Widget>[
CupertinoDialogAction(
child: Text("去开启"),
onPressed: () async {
if (open != null) {
open();
}else{
bool isOpened = await PermissionHandler().openAppSettings();
}
},
),
CupertinoDialogAction(
child: Text("取消"),
onPressed: (){
},
),
],
);
});
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: Text("权限"),
content: Text(message),
actions: <Widget>[
CupertinoDialogAction(
child: Text("去开启"),
onPressed: () async {
if (open != null) {
open();
} else {
bool isOpened = await PermissionHandler().openAppSettings();
}
},
),
CupertinoDialogAction(
child: Text("取消"),
onPressed: () {},
),
],
);
});
}
}
}

Loading…
Cancel
Save