master
章文轩 2 years ago
parent 9b8f21ee7e
commit 29fd4a3f5f

@ -7,6 +7,7 @@ import 'package:bytedesk_kefu_example/page/chat_type_page.dart';
import 'package:bytedesk_kefu_example/page/history_thread_page.dart';
import 'package:bytedesk_kefu_example/page/online_status_page.dart';
import 'package:bytedesk_kefu_example/page/setting_page.dart';
import 'package:bytedesk_kefu_example/page/switch_user_page.dart';
import 'package:bytedesk_kefu_example/page/user_info_page.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:flutter/material.dart';
@ -139,6 +140,16 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
}));
},
),
ListTile(
title: Text('切换用户'),
trailing: Icon(Icons.keyboard_arrow_right),
onTap: () {
Navigator.of(context)
.push(new MaterialPageRoute(builder: (context) {
return new SwitchUserPage();
}));
},
),
// ListTile(
// title: Text('退出登录'),
// onTap: () {

@ -0,0 +1,109 @@
import 'package:bytedesk_kefu/bytedesk_kefu.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'user_info_page.dart';
//
class SwitchUserPage extends StatefulWidget {
SwitchUserPage({Key? key}) : super(key: key);
@override
_SwitchUserPageState createState() => _SwitchUserPageState();
}
class _SwitchUserPageState extends State<SwitchUserPage> {
// appkey->->Flutter->->appkey
String _appKey = '81f427ea-4467-4c7c-b0cd-5c0e4b51456f';
// subDomain->->->
String _subDomain = "vip";
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('切换用户'),
elevation: 0,
),
body: ListView(
children: ListTile.divideTiles(
context: context,
tiles: [
ListTile(
title: Text('用户信息'),
trailing: Icon(Icons.keyboard_arrow_right),
onTap: () {
_userInfo();
},
),
ListTile(
title: Text('用户1男'),
onTap: () {
_userBoyLogin();
},
),
ListTile(
title: Text('用户2女'),
onTap: () {
_userGirlLogin();
},
),
ListTile(
title: Text('退出登录'),
onTap: () {
_userLogout();
},
),
],
).toList()),
);
}
void _userInfo() {
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new UserInfoPage();
}));
}
void _userBoyLogin() {
if (BytedeskKefu.isLogin()) {
Fluttertoast.showToast(msg: '请先退出登录');
return;
}
_initWithUsernameAndNicknameAndAvatar(
"myflutteruserboy",
"我是帅哥flutter",
"https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/boy.png",
_appKey,
_subDomain);
}
void _userGirlLogin() {
if (BytedeskKefu.isLogin()) {
Fluttertoast.showToast(msg: '请先退出登录');
return;
}
Fluttertoast.showToast(msg: '登录中');
_initWithUsernameAndNicknameAndAvatar(
"myflutterusergirl",
"我是美女flutter",
"https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png",
_appKey,
_subDomain);
}
void _initWithUsernameAndNicknameAndAvatar(String username, String nickname,
String avatar, String appKey, String subDomain) {
BytedeskKefu.initWithUsernameAndNicknameAndAvatar(username, nickname, avatar, appKey, subDomain);
}
void _userLogout() {
Fluttertoast.showToast(msg: '退出中');
BytedeskKefu.logout();
}
}

@ -594,7 +594,7 @@ class _ChatKFPageState extends State<ChatKFPage>
color: Colors.white
),
// child: _textComposerWidget(),
child: _chatInput(),
child: (BytedeskUtils.isWeb || BytedeskUtils.isAndroid) ? _textComposerWidget() : _chatInput(),
),
],

Loading…
Cancel
Save