scan asset ui
parent
ad3549b9a4
commit
3cc7176c63
@ -0,0 +1,3 @@
|
||||
<svg width="283" height="283" viewBox="0 0 283 283" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.1" d="M53.0625 66.3281V123.812H35.375V66.3281H53.0625ZM35.375 159.188V216.672H53.0625V159.188H35.375ZM128.234 66.3281V123.812H145.922V66.3281H128.234ZM128.234 159.188V216.672H145.922V159.188H128.234ZM229.938 66.3281V123.812H247.625V66.3281H229.938ZM229.938 159.188V216.672H247.625V159.188H229.938ZM88.4375 66.3281V123.812H97.2812V66.3281H88.4375ZM88.4375 159.188V216.672H97.2812V159.188H88.4375ZM106.125 66.3281V123.812H114.969V66.3281H106.125ZM106.125 159.188V216.672H114.969V159.188H106.125ZM185.719 66.3281V123.812H194.562V66.3281H185.719ZM185.719 159.188V216.672H194.562V159.188H185.719ZM203.406 66.3281V123.812H212.25V66.3281H203.406ZM203.406 159.188V216.672H212.25V159.188H203.406ZM66.3281 66.3281V123.812H79.5938V66.3281H66.3281ZM66.3281 159.188V216.672H79.5938V159.188H66.3281ZM159.188 66.3281V123.812H172.453V66.3281H159.188ZM159.188 159.188V216.672H172.453V159.188H159.188ZM269.734 132.656H13.2656V150.344H269.734V132.656ZM17.6875 48.6406H57.4844V39.7969H8.84375V88.4375H17.6875V48.6406ZM274.156 39.7969H225.516V48.6406H265.312V88.4375H274.156V39.7969ZM57.4844 234.359H17.6875V194.562H8.84375V243.203H57.4844V234.359ZM274.156 194.562H265.312V234.359H225.516V243.203H274.156V194.562Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
|
||||
import '../app_style/app_color.dart';
|
||||
|
||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final String title;
|
||||
final List<Widget> actions;
|
||||
final double bottomCorner;
|
||||
|
||||
const CustomAppBar({this.title, this.actions, this.bottomCorner, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
titleSpacing: 16,
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.arrow_back_ios).onPress(() {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
Text(
|
||||
title ?? "",
|
||||
style: AppTextStyles.heading3?.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
actions: actions,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
bottom: Radius.circular(bottomCorner??0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => Size.fromHeight(60.toScreenHeight);
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
import 'package:qr_code_tools/qr_code_tools.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
|
||||
import '../../../new_views/common_widgets/app_filled_button.dart';
|
||||
import '../../../new_views/common_widgets/custom_app_bar.dart';
|
||||
|
||||
class ScanQrWidget extends StatefulWidget {
|
||||
const ScanQrWidget({Key key, this.title}) : super(key: key);
|
||||
final String title;
|
||||
|
||||
@override
|
||||
_ScanQrWidgetState createState() => _ScanQrWidgetState();
|
||||
}
|
||||
|
||||
class _ScanQrWidgetState extends State<ScanQrWidget> {
|
||||
Barcode result;
|
||||
QRViewController _controller;
|
||||
bool _scanDone = false;
|
||||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR_scanner');
|
||||
|
||||
// In order to get hot reload to work we need to pause the camera if the platform
|
||||
// is android, or resume the camera if the platform is iOS.
|
||||
@override
|
||||
void reassemble() {
|
||||
super.reassemble();
|
||||
if (Platform.isAndroid) {
|
||||
_controller?.pauseCamera();
|
||||
} else if (Platform.isIOS) {
|
||||
_controller?.resumeCamera();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_controller?.dispose();
|
||||
}
|
||||
|
||||
|
||||
_pickManually() async {
|
||||
final picker = ImagePicker();
|
||||
final pickedFile = await picker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
if (pickedFile != null) {
|
||||
try {
|
||||
String qrData = await QrCodeToolsPlugin.decodeFrom(pickedFile.path);
|
||||
if (qrData != null && !_scanDone) {
|
||||
setState(() {
|
||||
_scanDone = true;
|
||||
});
|
||||
Navigator.of(context).pop(qrData);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error QR code: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
QRView(
|
||||
key: qrKey,
|
||||
onQRViewCreated: (QRViewController controller) {
|
||||
setState(() {
|
||||
_controller = controller;
|
||||
});
|
||||
controller.scannedDataStream.listen((scanData) {
|
||||
if (!_scanDone) {
|
||||
_scanDone = true;
|
||||
Navigator.of(context).pop(scanData.code);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
Center(
|
||||
child: 'scan'.toSvgAsset(
|
||||
height: 283.toScreenHeight.toInt(),
|
||||
width: 283.toScreenWidth.toInt(),
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 60.toScreenHeight,
|
||||
child: CustomAppBar(
|
||||
title: widget.title ?? '',
|
||||
bottomCorner: 12,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomSheet: Container(
|
||||
height: 82.toScreenHeight,
|
||||
color: Colors.white,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
height: 50.toScreenHeight,
|
||||
width: 358.toScreenWidth,
|
||||
child: AppFilledButton(
|
||||
label: context.translation.pickManually,
|
||||
onPressed: _pickManually,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue