feat(input): Wire up camera and OCR scanner buttons
This commit is contained in:
parent
b92ac20c0b
commit
3979086c10
|
|
@ -210,17 +210,66 @@ class _InputScreenState extends State<InputScreen> {
|
|||
}
|
||||
|
||||
void _onCameraTap() {
|
||||
// TODO: Implement camera capture
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Camera - Coming soon')),
|
||||
);
|
||||
// Camera tap also opens OCR scanner (same functionality)
|
||||
_openOcrScanner();
|
||||
}
|
||||
|
||||
void _onOcrTap() {
|
||||
// TODO: Implement OCR scanning
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('OCR - Coming soon')),
|
||||
);
|
||||
_openOcrScanner();
|
||||
}
|
||||
|
||||
Future<void> _openOcrScanner() async {
|
||||
if (_isProcessing) return;
|
||||
|
||||
setState(() => _isProcessing = true);
|
||||
|
||||
try {
|
||||
final result = await Navigator.of(context).push<OcrCaptureResult>(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const OcrCaptureScreen(
|
||||
enableLivePreview: true,
|
||||
keepImage: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (result != null && result.text.isNotEmpty) {
|
||||
// Append or replace text based on current content
|
||||
if (_textController.text.isEmpty) {
|
||||
_textController.text = result.text;
|
||||
} else {
|
||||
// Append with newline separator
|
||||
_textController.text = '${_textController.text}\n\n${result.text}';
|
||||
}
|
||||
|
||||
// Move cursor to end
|
||||
_textController.selection = TextSelection.fromPosition(
|
||||
TextPosition(offset: _textController.text.length),
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Extracted ${result.blocks.length} text blocks'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('OCR failed: $e'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isProcessing = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onVoiceTap() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue