You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

4 years ago
import 'package:bytedesk_kefu/bytedesk_kefu.dart';
import 'package:flutter/material.dart';
import 'package:list_tile_switch/list_tile_switch.dart';
// 消息声音、振动设置页面
class SettingPage extends StatefulWidget {
3 years ago
const SettingPage({Key? key}) : super(key: key);
4 years ago
@override
_SettingPageState createState() => _SettingPageState();
}
class _SettingPageState extends State<SettingPage> {
4 years ago
bool _playAudioOnSendMessage = false;
bool _playAudioOnReceiveMessage = false;
4 years ago
bool _vibrateOnReceiveMessage = false;
//
@override
void initState() {
3 years ago
_playAudioOnSendMessage = BytedeskKefu.getPlayAudioOnSendMessage()!;
_playAudioOnReceiveMessage = BytedeskKefu.getPlayAudioOnReceiveMessage()!;
_vibrateOnReceiveMessage = BytedeskKefu.getVibrateOnReceiveMessage()!;
4 years ago
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
3 years ago
title: const Text('消息设置'),
4 years ago
elevation: 0,
),
body: ListView(
children: ListTile.divideTiles(
context: context,
tiles: [
4 years ago
ListTileSwitch(
value: _playAudioOnSendMessage,
onChanged: (value) {
setState(() {
_playAudioOnSendMessage = value;
});
BytedeskKefu.setPlayAudioOnSendMessage(value);
},
3 years ago
title: const Text('发送消息时播放声音'),
4 years ago
),
ListTileSwitch(
value: _playAudioOnReceiveMessage,
onChanged: (value) {
setState(() {
_playAudioOnReceiveMessage = value;
});
BytedeskKefu.setPlayAudioOnReceiveMessage(value);
},
3 years ago
title: const Text('收到消息时播放声音'),
4 years ago
),
4 years ago
ListTileSwitch(
value: _vibrateOnReceiveMessage,
onChanged: (value) {
setState(() {
_vibrateOnReceiveMessage = value;
});
// 注意需要在安卓AndroidManifest.xml添加权限<uses-permission android:name="android.permission.VIBRATE"/>
BytedeskKefu.setVibrateOnReceiveMessage(value);
},
3 years ago
title: const Text('收到消息时振动'),
4 years ago
),
],
).toList()),
);
}
}