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.
128 lines
3.6 KiB
128 lines
3.6 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../controllers/meeting_connect_controller.dart';
|
|
|
|
class MeetingConnectView extends GetView<MeetingConnectController> {
|
|
const MeetingConnectView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Scaffold(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50],
|
|
appBar: _buildAppBar(isDarkMode),
|
|
body: _buildBody(isDarkMode),
|
|
);
|
|
}
|
|
|
|
PreferredSizeWidget _buildAppBar(bool isDarkMode) {
|
|
return AppBar(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white,
|
|
elevation: 0.5,
|
|
leading: IconButton(
|
|
icon: Icon(
|
|
Icons.arrow_back_ios,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
size: 20.sp,
|
|
),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
title: Text(
|
|
'蓝牙连接',
|
|
style: TextStyle(
|
|
fontSize: 17.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
);
|
|
}
|
|
|
|
Widget _buildBody(bool isDarkMode) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Obx(
|
|
() => Padding(
|
|
padding: EdgeInsets.only(bottom: 30.w),
|
|
child: Text(
|
|
controller.stateStr.value,
|
|
style: TextStyle(
|
|
fontSize: 20.sp,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Obx(
|
|
() => controller.isRescan.value
|
|
? _button('重新连接', Icons.refresh, onTap: () {
|
|
controller.startScan();
|
|
})
|
|
: const SizedBox(),
|
|
),
|
|
Obx(
|
|
() => Text(
|
|
controller.importedFilesStr.value,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
),
|
|
),
|
|
Obx(
|
|
() => controller.isImportedFiles.value
|
|
? Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 10.w),
|
|
child: _button('导入文件', Icons.file_download, onTap: () {
|
|
controller.stateStr.value = '正在开启Wi-Fi...';
|
|
controller.importedFilesStr.value = '';
|
|
controller.isImportedFiles.value = false;
|
|
controller.sendData([0x5a, 0x02, 0x87, 0x01]);
|
|
}),
|
|
)
|
|
: const SizedBox(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _button(String text, IconData icon, {Function()? onTap}) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
width: 150.w,
|
|
height: 42.w,
|
|
decoration: BoxDecoration(
|
|
color: Colors.black,
|
|
borderRadius: BorderRadius.circular(42.w),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
color: Colors.white,
|
|
size: 20.sp,
|
|
),
|
|
5.horizontalSpace,
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|