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.

210 lines
6.7 KiB

3 years ago
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/qr/qr_share_image.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
class QrSharePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _QrSharePage();
}
}
class _QrSharePage extends State<QrSharePage> {
String phone = "";
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
if (value.getString('user') != null && value.getString('user') != "") {
phone = UserInfo.fromJson(jsonDecode(value.getString('user'))).phone;
setState(() {});
}
});
buildImageInfo();
}
@override
void dispose() {
SmartDialog.dismiss();
3 years ago
super.dispose();
3 years ago
}
@override
Widget build(BuildContext context) {
if (height == null || height == 0)
height = MediaQuery.of(context).size.height;
return Scaffold(
appBar: MyAppBar(
title: "",
titleColor: Colors.black,
background: Color(0xFFF7F7F7),
leadingColor: Colors.black,
action: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(right: 16.w),
child: InkWell(
onTap: () {
3 years ago
if (phone == null || phone == "") return;
3 years ago
SmartDialog.show(
3 years ago
widget: QrShareImagePage(phone),
clickBgDismissTemp: true,
isPenetrateTemp: false,
);
3 years ago
},
3 years ago
child: Icon(
Icons.share,
color: Colors.black,
size: 24.w,
3 years ago
),
),
),
),
body: SingleChildScrollView(
child: Container(
height: height,
child: Stack(
children: [
// if (image != null)
Positioned(
child: Image.asset(
"assets/image/qr_share_bg.png",
fit: BoxFit.fill,
),
top: 0,
left: 0,
bottom: 0,
right: 0,
),
Positioned(
child: Container(
width: MediaQuery.of(context).size.width,
height: height * 0.635,
padding:
EdgeInsets.symmetric(vertical: 28.h, horizontal: 19.w),
child: Stack(
children: [
Positioned(
child: Image.asset(
"assets/image/qr_share_info_bg.png",
fit: BoxFit.fill,
),
top: 0,
left: 0,
bottom: 0,
right: 0,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
shareTypeTitle("方式一"),
Container(
margin: EdgeInsets.only(left: 16.w, right: 24.w),
child: Text(
"截屏保存下方二维码,邀请他人微信扫一扫识别,长按关注后,完成小游戏,领取优惠券后,即邀请成功哦!",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF2E3552),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Container(
width: 152.w,
height: 152.w,
decoration: BoxDecoration(
border: Border.all(
3 years ago
color: Color(0xFF2E3552),
width: 1,
),
3 years ago
),
child: QrImage(
3 years ago
data:
"http://mp.hx.lotus-wallet.com/pages/invite/index?mobile=${phone ?? ""}",
3 years ago
version: QrVersions.auto,
size: 200.w,
gapless: true,
),
),
shareTypeTitle("方式二"),
Container(
margin: EdgeInsets.only(left: 16.w, right: 24.w),
child: Text(
"也可以直接点击右上方的分享给到你想要邀请的人。",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF2E3552),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
),
SizedBox(
height: 1.h,
),
],
),
],
),
),
left: 0,
bottom: 0,
right: 0,
),
],
),
),
),
);
}
Widget shareTypeTitle(typeText) {
return Container(
width: 90.w,
height: 30.h,
child: Text(
typeText,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 18.sp,
color: Color(0xFF2E3552),
),
),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xFFFFC93B),
3 years ago
border: Border.all(
color: Color(0xFF2E3552),
width: 1,
),
3 years ago
),
);
}
Image image;
double height;
buildImageInfo() async {
image = Image.asset("assets/image/qr_share_bg.png");
image.image
.resolve(ImageConfiguration())
.addListener(ImageStreamListener((ImageInfo info, bool _) {
height = info.image.height.toDouble();
setState(() {});
}));
}
}