|
|
@@ -12,6 +12,7 @@ import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
|
|
import 'bloc/wechat_teacher_event.dart'; |
|
|
|
import 'bloc/wechat_teacher_state.dart'; |
|
|
|
import 'package:url_launcher/url_launcher.dart'; |
|
|
|
|
|
|
|
/// |
|
|
|
/// 微信导师 |
|
|
@@ -24,8 +25,7 @@ class WechatTeacherPage extends StatelessWidget { |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return BlocProvider<WechatTeacherBloc>( |
|
|
|
create: (_) => WechatTeacherBloc(WechatTeacherRepository(data)) |
|
|
|
..add(WechatTeacherInitEvent()), |
|
|
|
create: (_) => WechatTeacherBloc(WechatTeacherRepository(data))..add(WechatTeacherInitEvent()), |
|
|
|
child: _WechatTeacherPageContainer(), |
|
|
|
); |
|
|
|
} |
|
|
@@ -33,12 +33,10 @@ class WechatTeacherPage extends StatelessWidget { |
|
|
|
|
|
|
|
class _WechatTeacherPageContainer extends StatefulWidget { |
|
|
|
@override |
|
|
|
_WechatTeacherPageContainerState createState() => |
|
|
|
_WechatTeacherPageContainerState(); |
|
|
|
_WechatTeacherPageContainerState createState() => _WechatTeacherPageContainerState(); |
|
|
|
} |
|
|
|
|
|
|
|
class _WechatTeacherPageContainerState |
|
|
|
extends State<_WechatTeacherPageContainer> { |
|
|
|
class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer> { |
|
|
|
TextEditingController _editingController; |
|
|
|
|
|
|
|
/// 是否绑定中 |
|
|
@@ -55,24 +53,33 @@ class _WechatTeacherPageContainerState |
|
|
|
setState(() { |
|
|
|
_isBinding = true; |
|
|
|
}); |
|
|
|
BlocProvider.of<WechatTeacherBloc>(context) |
|
|
|
.add(WechatTeacherBindEvent(teacherWxChat: wxAccount)); |
|
|
|
BlocProvider.of<WechatTeacherBloc>(context).add(WechatTeacherBindEvent(teacherWxChat: wxAccount)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// 拷贝 |
|
|
|
void _copyText(String text) { |
|
|
|
void _copyText(String text) async { |
|
|
|
if (!EmptyUtil.isEmpty(text)) { |
|
|
|
Clipboard.setData(ClipboardData(text: text)); |
|
|
|
await Clipboard.setData(ClipboardData(text: text)); |
|
|
|
Fluttertoast.showToast(msg: '复制成功~'); |
|
|
|
String url = "weixin://"; |
|
|
|
if (await canLaunch(url)) { |
|
|
|
await launch(url); |
|
|
|
} else { |
|
|
|
throw 'Could not launch $url'; |
|
|
|
} |
|
|
|
} else { |
|
|
|
Fluttertoast.showToast(msg: '内容不能为空~'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// 长按保存图片 |
|
|
|
void _longClickSaveImage() { |
|
|
|
void _longClickSaveImage(String url) async { |
|
|
|
Logger.log('长按保存图片'); |
|
|
|
if (!EmptyUtil.isEmpty(url)) { |
|
|
|
var msg = await Download().fileToGallery(url); |
|
|
|
Fluttertoast.showToast(msg: msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
@@ -115,8 +122,7 @@ class _WechatTeacherPageContainerState |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createMainWidget( |
|
|
|
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
Widget _createMainWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
return Scaffold( |
|
|
|
appBar: _createNav(styleModel), |
|
|
|
backgroundColor: HexColor.fromHex(styleModel?.bgColor ?? '#FFF5F5F5'), |
|
|
@@ -184,8 +190,7 @@ class _WechatTeacherPageContainerState |
|
|
|
child: CupertinoTextField( |
|
|
|
onSubmitted: (val) => _bindTeacher(), |
|
|
|
controller: _editingController, |
|
|
|
placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? |
|
|
|
'请填写邀请人邀请码/手机号码', |
|
|
|
placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? '请填写邀请人邀请码/手机号码', |
|
|
|
placeholderStyle: TextStyle(fontSize: 14), |
|
|
|
decoration: BoxDecoration(), |
|
|
|
), |
|
|
@@ -202,19 +207,14 @@ class _WechatTeacherPageContainerState |
|
|
|
width: 130, |
|
|
|
height: 30, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'), |
|
|
|
color: HexColor.fromHex(styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'), |
|
|
|
borderRadius: BorderRadius.circular(15), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
_isBinding |
|
|
|
? '绑定中...' |
|
|
|
: styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人', |
|
|
|
_isBinding ? '绑定中...' : styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人', |
|
|
|
style: TextStyle( |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), |
|
|
|
fontSize: 14), |
|
|
|
color: HexColor.fromHex(styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), fontSize: 14), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
@@ -225,8 +225,7 @@ class _WechatTeacherPageContainerState |
|
|
|
} |
|
|
|
|
|
|
|
/// 绑定的UI |
|
|
|
Widget _createBindWidget( |
|
|
|
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
Widget _createBindWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
height: double.infinity, |
|
|
@@ -249,35 +248,25 @@ class _WechatTeacherPageContainerState |
|
|
|
children: <Widget>[ |
|
|
|
Text(dataModel?.teacherUsername ?? '', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))), |
|
|
|
fontSize: 15, color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))), |
|
|
|
Text('微信号: ${dataModel?.teacherWechatAccount ?? ''}', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 15, |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.commStyle?.wechatAccountColor ?? |
|
|
|
'#FF5050'))), |
|
|
|
fontSize: 15, color: HexColor.fromHex(styleModel?.commStyle?.wechatAccountColor ?? '#FF5050'))), |
|
|
|
GestureDetector( |
|
|
|
onTap: () => _copyText(dataModel?.teacherWechatAccount), |
|
|
|
child: UnconstrainedBox( |
|
|
|
child: Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
// color: Color(0xffffdada), |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.bindTeacherDialog?.btnBgColor ?? |
|
|
|
'#FFDADA'), |
|
|
|
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnBgColor ?? '#FFDADA'), |
|
|
|
borderRadius: BorderRadius.circular(20), |
|
|
|
), |
|
|
|
padding: |
|
|
|
EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), |
|
|
|
padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), |
|
|
|
child: Text( |
|
|
|
styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13, |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.bindTeacherDialog?.btnTextColor ?? |
|
|
|
'#FF0000')), |
|
|
|
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
@@ -288,7 +277,8 @@ class _WechatTeacherPageContainerState |
|
|
|
child: Align( |
|
|
|
alignment: Alignment.centerRight, |
|
|
|
child: GestureDetector( |
|
|
|
onLongPress: () => _longClickSaveImage(), |
|
|
|
onLongPress: () => _longClickSaveImage( |
|
|
|
dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? ''), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
Container( |
|
|
@@ -296,9 +286,7 @@ class _WechatTeacherPageContainerState |
|
|
|
height: 56, |
|
|
|
// color: Colors.red, |
|
|
|
child: CachedNetworkImage( |
|
|
|
imageUrl: dataModel?.teacherWxQrCode ?? |
|
|
|
styleModel?.myTeacher?.defalutTeacher?.qrcode ?? |
|
|
|
'', |
|
|
|
imageUrl: dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? '', |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 9), |
|
|
@@ -306,9 +294,7 @@ class _WechatTeacherPageContainerState |
|
|
|
styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13, |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.officalWxchat?.qrcodeTextColor ?? |
|
|
|
'#999999')), |
|
|
|
color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
@@ -320,8 +306,7 @@ class _WechatTeacherPageContainerState |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _createHeader( |
|
|
|
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
Widget _createHeader(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { |
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 283, |
|
|
@@ -347,8 +332,7 @@ class _WechatTeacherPageContainerState |
|
|
|
margin: EdgeInsets.only(left: 10, right: 10), |
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.teacherDialogBgColor ?? '#FFFFFF'), |
|
|
|
color: HexColor.fromHex(styleModel?.teacherDialogBgColor ?? '#FFFFFF'), |
|
|
|
borderRadius: BorderRadius.circular(10), |
|
|
|
), |
|
|
|
child: Column( |
|
|
@@ -360,8 +344,7 @@ class _WechatTeacherPageContainerState |
|
|
|
style: TextStyle( |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
fontSize: 15, |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.teacherDialogTitleColor ?? '#3C3C3C'), |
|
|
|
color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'), |
|
|
|
), |
|
|
|
), |
|
|
|
Expanded( |
|
|
@@ -386,8 +369,7 @@ class _WechatTeacherPageContainerState |
|
|
|
margin: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 22), |
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: |
|
|
|
HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'), |
|
|
|
color: HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'), |
|
|
|
borderRadius: BorderRadius.circular(10), |
|
|
|
), |
|
|
|
child: Column( |
|
|
@@ -397,8 +379,7 @@ class _WechatTeacherPageContainerState |
|
|
|
Text( |
|
|
|
styleModel?.officalWxchat?.title ?? '官方微信', |
|
|
|
style: TextStyle( |
|
|
|
color: HexColor.fromHex( |
|
|
|
styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'), |
|
|
|
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'), |
|
|
|
fontSize: 15, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
), |
|
|
@@ -416,10 +397,7 @@ class _WechatTeacherPageContainerState |
|
|
|
styleModel.officalWxchat.list.forEach((element) { |
|
|
|
widgets.add(WechatTeachetItem(element, styleModel)); |
|
|
|
widgets.add(Container( |
|
|
|
margin: EdgeInsets.only(top: 4, bottom: 4), |
|
|
|
width: double.infinity, |
|
|
|
height: 0.5, |
|
|
|
color: Color(0xffebebeb))); |
|
|
|
margin: EdgeInsets.only(top: 4, bottom: 4), width: double.infinity, height: 0.5, color: Color(0xffebebeb))); |
|
|
|
}); |
|
|
|
widgets.removeLast(); |
|
|
|
} else { |
|
|
|