1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'index.dart';
- class CardReaderDialog extends GetView<CardReaderController> {
- const CardReaderDialog({Key? key}) : super(key: key);
- // 主视图
- Widget _buildView() {
- const designWidth = 1280.0; // 设计尺寸宽度:1280
- final width = Get.width;
- final scale = width / designWidth; // 计算缩放比例
- return Container(
- width: Get.width * 0.6 / scale,
- height: Get.height * 0.6 / scale,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(10),
- ),
- child: Column(
- children: [
- _buildHead(),
- // const Expanded(child: NoCardReaderView()),
- Expanded(
- child: controller.isCardReaderConnected
- ? const CardReaderView()
- : const NoCardReaderView()),
- ],
- ),
- );
- }
- @override
- Widget build(BuildContext context) {
- return GetBuilder<CardReaderController>(
- init: CardReaderController(),
- id: "card_reader",
- builder: (_) {
- return Dialog(
- child: _buildView(),
- );
- },
- );
- }
- /// 构建弹窗顶部,右侧显示关闭按钮
- Widget _buildHead() {
- return SizedBox(
- height: 50,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- IconButton(
- onPressed: () => Get.back(),
- icon: const Icon(
- Icons.close,
- size: 30,
- ),
- ),
- ],
- ),
- );
- }
- }
|