132 lines
3.7 KiB
Dart
132 lines
3.7 KiB
Dart
import 'package:chat/configs/app_colors.dart';
|
|
import 'package:chat/views/home/widgets/pop_menu_item.dart';
|
|
import 'package:chat/views/public/scan_page.dart';
|
|
import 'package:chat/widgets/custom_avatar.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
|
class UserQrCodePage extends StatefulWidget {
|
|
const UserQrCodePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<UserQrCodePage> createState() => _UserQrCodePageState();
|
|
}
|
|
|
|
class _UserQrCodePageState extends State<UserQrCodePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('我的二维码'),
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () {
|
|
_showLongPressMenu();
|
|
},
|
|
icon: const Icon(Icons.more_horiz),
|
|
),
|
|
],
|
|
),
|
|
body: Center(
|
|
child: Container(
|
|
width: Get.width - 32,
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.white,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
CustomAvatar(
|
|
'',
|
|
size: 64,
|
|
radius: 6,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: const [
|
|
Text(
|
|
'Jason',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 32),
|
|
QrImage(
|
|
data: 'BEFRIEND|5',
|
|
version: 3,
|
|
size: Get.width * 0.8,
|
|
),
|
|
const SizedBox(height: 32),
|
|
const Text(
|
|
'扫一扫上面的二维码,加我共力好友',
|
|
style: TextStyle(
|
|
color: AppColors.unactive,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _showLongPressMenu() async {
|
|
showModalBottomSheet(
|
|
context: Get.context!,
|
|
isScrollControlled: true,
|
|
backgroundColor: AppColors.white,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(8)),
|
|
),
|
|
builder: (context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
PopMenuItem(
|
|
'保存到手机',
|
|
onTap: () {},
|
|
),
|
|
const Divider(height: 0),
|
|
PopMenuItem(
|
|
'扫描二维码',
|
|
onTap: () {
|
|
Get.back();
|
|
Permission.camera.request().isGranted.then((value) {
|
|
if (value) {
|
|
Get.to(const ScanPage());
|
|
}
|
|
});
|
|
},
|
|
),
|
|
const Divider(height: 0),
|
|
const Divider(height: 0.4),
|
|
Container(
|
|
color: AppColors.page,
|
|
height: 8,
|
|
),
|
|
const Divider(height: 0.4),
|
|
PopMenuItem(
|
|
'取消',
|
|
onTap: () {
|
|
Get.back();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|