Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
flutterbarcode-generatorbarcode-scannergeneratorqrqrcodeqrcode-generatorqrcode-scannerscannerzxingbarcodezxscanner
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.
77 lines
2.6 KiB
77 lines
2.6 KiB
3 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
3 years ago
|
import 'package:zxscanner/models/code.dart';
|
||
|
import 'package:zxscanner/utils/db_service.dart';
|
||
|
import 'package:zxscanner/widgets/common_widgets.dart';
|
||
3 years ago
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||
3 years ago
|
import 'package:hive_flutter/hive_flutter.dart';
|
||
3 years ago
|
|
||
3 years ago
|
class HistoryPage extends StatefulWidget {
|
||
|
const HistoryPage({
|
||
3 years ago
|
Key? key,
|
||
|
}) : super(key: key);
|
||
|
|
||
|
@override
|
||
3 years ago
|
State<HistoryPage> createState() => _HistoryPageState();
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
class _HistoryPageState extends State<HistoryPage> {
|
||
3 years ago
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
3 years ago
|
title: const Text('History'),
|
||
3 years ago
|
),
|
||
3 years ago
|
body: _buildResultList(),
|
||
3 years ago
|
);
|
||
|
}
|
||
|
|
||
|
_buildResultList() {
|
||
3 years ago
|
return ValueListenableBuilder<Box<Code>>(
|
||
|
valueListenable: DbService.instance.getCodes().listenable(),
|
||
|
builder: (context, box, _) {
|
||
|
final results = box.values.toList().cast<Code>();
|
||
|
return results.isEmpty
|
||
|
? const Center(
|
||
|
child: Text(
|
||
|
'No Results',
|
||
|
style: TextStyle(fontSize: 24),
|
||
|
))
|
||
|
: ListView.builder(
|
||
|
itemCount: results.length,
|
||
|
itemBuilder: (context, index) {
|
||
|
final result = results[index];
|
||
3 years ago
|
return ContainerX(
|
||
|
child: ListTile(
|
||
|
title: Text(result.text ?? ''),
|
||
|
subtitle: Text(result.formatName),
|
||
|
trailing: ButtonBar(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
// Copy button
|
||
|
IconButton(
|
||
|
icon: const Icon(FontAwesomeIcons.copy),
|
||
|
onPressed: () {
|
||
|
Clipboard.setData(
|
||
|
ClipboardData(text: result.text));
|
||
|
},
|
||
|
),
|
||
|
// Remove button
|
||
|
IconButton(
|
||
|
icon: const Icon(FontAwesomeIcons.trash,
|
||
|
color: Colors.red),
|
||
|
onPressed: () {
|
||
|
DbService.instance.deleteCode(result);
|
||
|
setState(() {});
|
||
|
},
|
||
|
),
|
||
|
],
|
||
|
),
|
||
3 years ago
|
),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
3 years ago
|
}
|
||
|
}
|