Ver código fonte

1223 微信导师打开微信问题修复

tags/0.0.3+1
23028876916@qq.com 3 anos atrás
pai
commit
5acef154e9
2 arquivos alterados com 72 adições e 72 exclusões
  1. +39
    -61
      lib/pages/wechat_teacher_page/wechat_teacher_page.dart
  2. +33
    -11
      lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart

+ 39
- 61
lib/pages/wechat_teacher_page/wechat_teacher_page.dart Ver arquivo

@@ -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 {


+ 33
- 11
lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart Ver arquivo

@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:url_launcher/url_launcher.dart';

class WechatTeachetItem extends StatelessWidget {
OfficalWxchatList itemStyleModel;
@@ -11,23 +12,35 @@ class WechatTeachetItem extends StatelessWidget {
WechatTeachetItem(this.itemStyleModel, this.styleModel);

/// 拷贝
void _copyText(String text) {
if(!EmptyUtil.isEmpty(text)) {
Clipboard.setData(ClipboardData(text: text));
void _copyText(String text) async {
if (!EmptyUtil.isEmpty(text)) {
await Clipboard.setData(ClipboardData(text: text));
Fluttertoast.showToast(msg: '复制成功~');
}else{
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
Widget build(BuildContext context) {

return Container(
margin: EdgeInsets.only(top: 8, bottom: 8),
child: Row(
@@ -49,10 +62,16 @@ class WechatTeachetItem extends StatelessWidget {
text: TextSpan(children: [
TextSpan(
text: itemStyleModel?.text ?? '',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
TextSpan(
text: ' ${itemStyleModel?.subText ?? ''}',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 11, color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 11,
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
]),
),

@@ -69,7 +88,7 @@ class WechatTeachetItem extends StatelessWidget {
),
),
GestureDetector(
onTap: ()=> _copyText(itemStyleModel?.wechatAccount),
onTap: () => _copyText(itemStyleModel?.wechatAccount),
child: UnconstrainedBox(
child: Container(
decoration: BoxDecoration(
@@ -80,7 +99,9 @@ class WechatTeachetItem extends StatelessWidget {
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')),
style: TextStyle(
fontSize: 13,
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')),
),
),
),
@@ -89,7 +110,7 @@ class WechatTeachetItem extends StatelessWidget {
),
),
GestureDetector(
onLongPress: ()=> _longClickSaveImage(),
onLongPress: () => _longClickSaveImage(itemStyleModel?.qrcode),
child: Column(
children: <Widget>[
Container(
@@ -103,7 +124,8 @@ class WechatTeachetItem extends StatelessWidget {
),
Text(
styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码',
style: TextStyle(fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')),
style: TextStyle(
fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')),
),
],
),


Carregando…
Cancelar
Salvar