水印优化+ORC优化
This commit is contained in:
+11
-60
@@ -2,9 +2,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'widgets/manual_entry_tab.dart';
|
||||
import 'widgets/ocr_tab.dart';
|
||||
|
||||
/// 记账页内部 Tab:0=手动记账 1=OCR识别
|
||||
///
|
||||
/// ⚠️ **OCR 已从前端隐藏**(2026-09-28,用户不再需要)。这个 provider 先留着,
|
||||
/// 因为 `widgets/ocr_result_card.dart` 还在引用它 —— OCR 相关的那几个文件
|
||||
/// (`ocr_tab.dart` / `ocr_result_card.dart` / `ocr_provider.dart` /
|
||||
/// `ocr_api.dart` / `ocr_result.dart`)都保留着,没有删。
|
||||
///
|
||||
/// 要恢复 OCR:把下面 body 换回「Tab 栏 + `tabIndex == 0 ? ManualEntryTab : OcrTab`」
|
||||
/// 就行,后端 `/api/ocr/**` 也一直没停。
|
||||
class AddTabNotifier extends Notifier<int> {
|
||||
@override
|
||||
int build() => 0;
|
||||
@@ -14,13 +21,12 @@ class AddTabNotifier extends Notifier<int> {
|
||||
|
||||
final addTabProvider = NotifierProvider<AddTabNotifier, int>(AddTabNotifier.new);
|
||||
|
||||
/// 记账页:手动记账 / OCR识别 双 Tab(复刻 uniApp pages/add/add.vue)
|
||||
/// 记账页(原本是「手动记账 / OCR识别」双 Tab,现在只剩手动记账)
|
||||
class AddPage extends ConsumerWidget {
|
||||
const AddPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tabIndex = ref.watch(addTabProvider);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('添加账单')),
|
||||
body: Container(
|
||||
@@ -31,63 +37,8 @@ class AddPage extends ConsumerWidget {
|
||||
colors: [Color(0xFFFFE5CC), Color(0xFFFFD4A8), Color(0xFFFFC08A)],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
_buildTabs(tabIndex, ref),
|
||||
Expanded(
|
||||
child: tabIndex == 0 ? const ManualEntryTab() : const OcrTab(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabs(int tabIndex, WidgetRef ref) {
|
||||
void setTab(int index) => ref.read(addTabProvider.notifier).set(index);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.9),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: const Color(0xFFC8956E)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_tab('手动记账', 0, tabIndex, setTab),
|
||||
_tab('OCR识别', 1, tabIndex, setTab),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tab(String text, int index, int tabIndex, void Function(int) setTab) {
|
||||
final active = tabIndex == index;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setTab(index),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
gradient: active
|
||||
? const LinearGradient(colors: [Color(0xFFC8956E), Color(0xFFF5D59E)])
|
||||
: null,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: active ? const Color(0xFF5D4037) : const Color(0xFF8D6E63),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// ManualEntryTab 自带 ListView,直接铺满就行
|
||||
child: const ManualEntryTab(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user