Browse Source

修改同步到云端

weicu
tanlongsheng 1 year ago
parent
commit
6d017af997
  1. 4
      lib/data/services/db/database_helper.dart
  2. 13
      lib/data/services/db/sqflite_api.dart
  3. 8
      lib/modules/meeting/controllers/meeting_controller.dart
  4. 24
      lib/modules/meeting/views/meeting_mine_view.dart
  5. 116
      lib/modules/meeting/views/mine/meeting_cloud_view.dart

4
lib/data/services/db/database_helper.dart

@ -36,7 +36,8 @@ class DatabaseHelper {
batch.execute(''' batch.execute('''
CREATE TABLE IF NOT EXISTS user ( CREATE TABLE IF NOT EXISTS user (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
synctime INTEGER synctime INTEGER,
privatecloud INTEGER
) )
'''); ''');
// 商务会议助手列表 // 商务会议助手列表
@ -109,6 +110,7 @@ class DatabaseHelper {
batch.insert('user', { batch.insert('user', {
'id': _userId, 'id': _userId,
'synctime': 0, 'synctime': 0,
'privatecloud': 0,
}); });
// 商务会议助手插入默认模版 // 商务会议助手插入默认模版
batch.insert('meetingcategorytemplate', { batch.insert('meetingcategorytemplate', {

13
lib/data/services/db/sqflite_api.dart

@ -5,6 +5,19 @@ import '../../../core/utils/synchrodata.dart';
import 'database_helper.dart'; import 'database_helper.dart';
class SqfliteApi { class SqfliteApi {
// 获取个人信息
static Future getUser() async {
final db = await DatabaseHelper().database;
List userList = await db.query('user');
return userList.first;
}
// 修改个人信息
static Future editUser(id, Map<String, Object?> user) async {
final db = await DatabaseHelper().database;
await db.update('user', user, where: 'id = ?', whereArgs: [id]);
}
// 获取商务会议助手列表 // 获取商务会议助手列表
static Future getMeetingList() async { static Future getMeetingList() async {
final db = await DatabaseHelper().database; final db = await DatabaseHelper().database;

8
lib/modules/meeting/controllers/meeting_controller.dart

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../data/services/db/sqflite_api.dart';
import '../views/meeting_home_view.dart'; import '../views/meeting_home_view.dart';
import '../views/meeting_mine_view.dart'; import '../views/meeting_mine_view.dart';
@ -16,9 +17,16 @@ class MeetingController extends GetxController {
RxInt pageIndex = 0.obs; RxInt pageIndex = 0.obs;
RxMap user = {}.obs;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
pageController = PageController(initialPage: 0); pageController = PageController(initialPage: 0);
_getUser();
}
void _getUser() async {
user.value = Map.from(await SqfliteApi.getUser());
} }
} }

24
lib/modules/meeting/views/meeting_mine_view.dart

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import '../../../routes/app_routes.dart'; import '../../../routes/app_routes.dart';
import '../../profile/views/unified_avatar.dart'; import '../../profile/views/unified_avatar.dart';
import '../controllers/meeting_controller.dart';
import '../controllers/meeting_mine_controller.dart'; import '../controllers/meeting_mine_controller.dart';
import '../utils/meeting_ui_utils.dart'; import '../utils/meeting_ui_utils.dart';
import 'bottomSheet/statistics_bottom_sheet.dart'; import 'bottomSheet/statistics_bottom_sheet.dart';
@ -20,6 +21,7 @@ class MeetingMineView extends StatefulWidget {
class _MeetingMineViewState extends State<MeetingMineView> class _MeetingMineViewState extends State<MeetingMineView>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
final _controller = Get.put(MeetingMineController()); final _controller = Get.put(MeetingMineController());
final _meetingController = Get.put(MeetingController());
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
@ -71,13 +73,17 @@ class _MeetingMineViewState extends State<MeetingMineView>
), ),
]), ]),
_box([ _box([
_item( Obx(
Icons.cloud_upload_outlined, () => _item(
'Voitrans PRIVATE CLOUD', Icons.cloud_upload_outlined,
description: '开启', 'VOITRANS PRIVATE CLOUD',
onTap: () { description: _meetingController.user['privatecloud'] == 1
Get.to(() => const MeetingCloudView()); ? '开启'
}, : '关闭',
onTap: () {
Get.to(() => const MeetingCloudView());
},
),
), ),
]), ]),
_box([ _box([
@ -89,7 +95,7 @@ class _MeetingMineViewState extends State<MeetingMineView>
), ),
_item( _item(
Icons.settings_remote_outlined, Icons.settings_remote_outlined,
'我的Voitrans设备', '我的VOITRANS设备',
onTap: () {}, onTap: () {},
), ),
]), ]),
@ -103,7 +109,7 @@ class _MeetingMineViewState extends State<MeetingMineView>
), ),
_item( _item(
Icons.info_outline_rounded, Icons.info_outline_rounded,
'关于Voitrans', '关于VOITRANS',
description: 'v1.0.0', description: 'v1.0.0',
onTap: () {}, onTap: () {},
), ),

116
lib/modules/meeting/views/mine/meeting_cloud_view.dart

@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../../data/services/db/sqflite_api.dart';
import '../../controllers/meeting_controller.dart';
import '../../utils/meeting_ui_utils.dart'; import '../../utils/meeting_ui_utils.dart';
class MeetingCloudView extends StatefulWidget { class MeetingCloudView extends StatefulWidget {
@ -12,21 +14,41 @@ class MeetingCloudView extends StatefulWidget {
} }
class _MeetingCloudViewState extends State<MeetingCloudView> { class _MeetingCloudViewState extends State<MeetingCloudView> {
final _controller = Get.put(MeetingController());
bool _isSync = false;
@override
void initState() {
super.initState();
_isSync = _controller.user['privatecloud'] == 1;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark; final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Scaffold( return PopScope(
backgroundColor: MeetingUIUtils.getBackgroundColor(isDarkMode), onPopInvokedWithResult: (didPop, result) {
appBar: _buildAppBar(isDarkMode), int privatecloud = _isSync ? 1 : 0;
body: _buildBody(isDarkMode), if (privatecloud != _controller.user['privatecloud']) {
_controller.user['privatecloud'] = privatecloud;
SqfliteApi.editUser(_controller.user['id'],
Map<String, Object?>.from(_controller.user));
}
},
child: Scaffold(
backgroundColor: MeetingUIUtils.getBackgroundColor(isDarkMode),
appBar: _buildAppBar(isDarkMode),
body: _buildBody(isDarkMode),
),
); );
} }
// 构建应用栏 // 构建应用栏
PreferredSizeWidget _buildAppBar(bool isDarkMode) { PreferredSizeWidget _buildAppBar(bool isDarkMode) {
return AppBar( return AppBar(
backgroundColor: isDarkMode ? Colors.black : Colors.white, backgroundColor: MeetingUIUtils.getBackgroundColor(isDarkMode),
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
elevation: 0.5, elevation: 0.5,
leading: IconButton( leading: IconButton(
@ -50,6 +72,88 @@ class _MeetingCloudViewState extends State<MeetingCloudView> {
} }
Widget _buildBody(bool isDarkMode) { Widget _buildBody(bool isDarkMode) {
return Container(); return Column(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w),
margin: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.w),
decoration: BoxDecoration(
color: MeetingUIUtils.getCardColor(isDarkMode),
borderRadius: BorderRadius.circular(12.w),
boxShadow: MeetingUIUtils.getCardShadow(isDarkMode),
),
child: Column(
children: [
Container(
width: 60.w,
height: 60.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
border: Border.all(
color: Colors.grey,
),
),
child: Icon(
Icons.phone_android,
size: 40.w,
),
),
Padding(
padding: EdgeInsets.only(top: 20.w, bottom: 10.w),
child: Text(
'同步到云端',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
),
),
Text(
'自动将你的录音同步到云端,你可以通过任意VOITRANS APP或VOITRANS Web(web.voitrans.com)播放、管理和分享录音。',
textAlign: TextAlign.center,
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 14.sp,
),
),
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 2.w),
margin: EdgeInsets.symmetric(horizontal: 12.w),
decoration: BoxDecoration(
color: MeetingUIUtils.getCardColor(isDarkMode),
borderRadius: BorderRadius.circular(12.w),
boxShadow: MeetingUIUtils.getCardShadow(isDarkMode),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'同步VOITRANS APP',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 16.sp,
),
),
Transform.scale(
scale: 0.9,
alignment: Alignment.centerRight,
child: Switch(
value: _isSync,
onChanged: (bool value) {
setState(() {
_isSync = value;
});
},
),
),
],
),
),
],
);
} }
} }

Loading…
Cancel
Save