11import 'package:flutter/material.dart' ;
22import 'package:flutter_riverpod/flutter_riverpod.dart' ;
33import '../../../../core/utils/locale_settings.dart' ;
4+ import '../../application/providers/android_import_permission_provider.dart' ;
45import '../../application/providers/dashboard_providers.dart' ;
56import '../../application/providers/expense_providers.dart' ;
7+ import '../../application/services/android_finance_import_service.dart' ;
68import '../../application/services/transaction_review_service.dart' ;
79import '../../domain/entities/transaction.dart' ;
810import '../../domain/models/budget_status.dart' ;
@@ -140,12 +142,17 @@ class CoinsDashboardScreen extends ConsumerWidget {
140142 }
141143}
142144
143- class _AndroidImportPermissionCard extends StatelessWidget {
145+ class _AndroidImportPermissionCard extends ConsumerWidget {
144146 const _AndroidImportPermissionCard ();
145147
146148 @override
147- Widget build (BuildContext context) {
149+ Widget build (BuildContext context, WidgetRef ref ) {
148150 final theme = Theme .of (context);
151+ final permissionState = ref.watch (
152+ androidFinanceImportPermissionControllerProvider,
153+ );
154+ final permission = permissionState.valueOrNull;
155+ final enabled = permission == AndroidFinanceImportPermission .enabled;
149156 return Card (
150157 elevation: 0 ,
151158 child: Padding (
@@ -166,24 +173,41 @@ class _AndroidImportPermissionCard extends StatelessWidget {
166173 ),
167174 ),
168175 Chip (
169- label: const Text ('Permission disabled' ),
176+ label: Text (
177+ enabled ? 'Permission enabled' : 'Permission disabled' ,
178+ ),
170179 visualDensity: VisualDensity .compact,
171180 backgroundColor: theme.colorScheme.surfaceContainerHighest,
172181 ),
173182 ],
174183 ),
175184 const SizedBox (height: 8 ),
176185 Text (
177- 'Import bank, UPI, and card alerts only after you enable access. Airo parses locally, ignores OTP/auth messages, and queues matches for review.' ,
186+ enabled
187+ ? 'Airo can now parse supported bank, UPI, and card alerts locally and queue matches for review. OTP/auth messages stay ignored.'
188+ : 'Import bank, UPI, and card alerts only after you enable access. Airo parses locally, ignores OTP/auth messages, and queues matches for review.' ,
178189 style: theme.textTheme.bodyMedium? .copyWith (
179190 color: theme.colorScheme.onSurfaceVariant,
180191 ),
181192 ),
182193 const SizedBox (height: 12 ),
183- OutlinedButton .icon (
184- onPressed: null ,
185- icon: const Icon (Icons .lock_outline),
186- label: const Text ('Enable explicitly later' ),
194+ SwitchListTile .adaptive (
195+ value: enabled,
196+ contentPadding: EdgeInsets .zero,
197+ title: const Text ('Allow local Android import' ),
198+ subtitle: const Text (
199+ 'This only flips Airo\' s local import gate. Android OS inbox/listener permissions are still a separate future step.' ,
200+ ),
201+ onChanged: permissionState.isLoading
202+ ? null
203+ : (value) {
204+ ref
205+ .read (
206+ androidFinanceImportPermissionControllerProvider
207+ .notifier,
208+ )
209+ .setEnabled (value);
210+ },
187211 ),
188212 ],
189213 ),
0 commit comments