Update: 2026-06-13 15:43:50
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:siro_rider/constant/colors.dart';
|
||||
import 'package:siro_rider/controller/home/profile/invites_rewards_controller.dart';
|
||||
|
||||
class QRScannerPage extends StatefulWidget {
|
||||
@override
|
||||
_QRScannerPageState createState() => _QRScannerPageState();
|
||||
}
|
||||
|
||||
class _QRScannerPageState extends State<QRScannerPage> {
|
||||
final InvitesRewardsController controller = Get.find<InvitesRewardsController>();
|
||||
bool _isScanned = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
title: Text("Scan QR Code".tr, style: const TextStyle(color: Colors.white)),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
MobileScanner(
|
||||
onDetect: (capture) {
|
||||
if (_isScanned) return;
|
||||
final List<Barcode> barcodes = capture.barcodes;
|
||||
for (final barcode in barcodes) {
|
||||
if (barcode.rawValue != null) {
|
||||
setState(() => _isScanned = true);
|
||||
Get.back(); // close scanner page
|
||||
controller.processScannedQRCode(barcode.rawValue!);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
height: 250,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.primaryColor, width: 3),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 50,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Align QR Code within the frame".tr,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import '../../../constant/links.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/home/profile/invit_controller.dart';
|
||||
import '../../../controller/home/profile/invites_rewards_controller.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'qr_scanner_page.dart';
|
||||
import '../../../print.dart';
|
||||
|
||||
class ShareAppPage extends StatelessWidget {
|
||||
@@ -48,12 +46,6 @@ class ShareAppPage extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
backgroundColor: AppColor.primaryColor,
|
||||
onPressed: () => Get.to(() => QRScannerPage()),
|
||||
icon: const Icon(CupertinoIcons.qrcode_viewfinder, color: Colors.white),
|
||||
label: Text("Scan QR".tr, style: const TextStyle(color: Colors.white)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,8 +53,6 @@ class ShareAppPage extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildQRCodeSection(),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -603,51 +593,7 @@ class ShareAppPage extends StatelessWidget {
|
||||
// );
|
||||
}
|
||||
|
||||
Widget _buildQRCodeSection() {
|
||||
return GetBuilder<InvitesRewardsController>(
|
||||
builder: (rewardsController) {
|
||||
if (rewardsController.isLoading) {
|
||||
return const Center(child: CupertinoActivityIndicator());
|
||||
}
|
||||
String qrData =
|
||||
'https://${AppLink.appDomain}/?inviteCode=${rewardsController.referralCode ?? ''}';
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Your QR Code".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
if (rewardsController.referralCode != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: QrImageView(
|
||||
data: qrData,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (rewardsController.referralCode != null)
|
||||
Text(
|
||||
rewardsController.referralCode!,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUnifiedRewardsList() {
|
||||
return GetBuilder<InvitesRewardsController>(
|
||||
|
||||
Reference in New Issue
Block a user