feat(android): add attachment boxing FJ- scan and submit
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
86
lib/pages/boxing/dialogs/attachment_category_picker.dart
Normal file
86
lib/pages/boxing/dialogs/attachment_category_picker.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pad_scanner/services/api_service.dart';
|
||||
|
||||
/// Show a single-category picker for attachment boxing.
|
||||
/// Returns the selected category, or null.
|
||||
Future<AttachmentCategoryData?> showBoxingAttachmentCategoryPicker({
|
||||
required BuildContext context,
|
||||
required List<AttachmentCategoryData> categories,
|
||||
}) {
|
||||
return showDialog<AttachmentCategoryData>(
|
||||
context: context,
|
||||
builder: (ctx) => _BoxingCategoryPickerDialog(categories: categories),
|
||||
);
|
||||
}
|
||||
|
||||
class _BoxingCategoryPickerDialog extends StatefulWidget {
|
||||
final List<AttachmentCategoryData> categories;
|
||||
const _BoxingCategoryPickerDialog({required this.categories});
|
||||
|
||||
@override
|
||||
State<_BoxingCategoryPickerDialog> createState() =>
|
||||
_BoxingCategoryPickerDialogState();
|
||||
}
|
||||
|
||||
class _BoxingCategoryPickerDialogState
|
||||
extends State<_BoxingCategoryPickerDialog> {
|
||||
int? _selectedId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('选择附件类型'),
|
||||
content: SizedBox(
|
||||
width: 400,
|
||||
child: RadioGroup<int>(
|
||||
groupValue: _selectedId,
|
||||
onChanged: (v) => setState(() => _selectedId = v),
|
||||
child: widget.categories.length <= 6
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.categories
|
||||
.map(
|
||||
(cat) => RadioListTile<int>(
|
||||
dense: true,
|
||||
title: Text(cat.name),
|
||||
value: cat.id,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.categories
|
||||
.map(
|
||||
(cat) => RadioListTile<int>(
|
||||
dense: true,
|
||||
title: Text(cat.name),
|
||||
value: cat.id,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _selectedId != null
|
||||
? () {
|
||||
final cat = widget.categories.firstWhere(
|
||||
(c) => c.id == _selectedId,
|
||||
);
|
||||
Navigator.pop(context, cat);
|
||||
}
|
||||
: null,
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user