Files
prosappco/lib/app_view.dart
T
Lizandro GuarnizoandClaude Sonnet 4.6 2c5b237890 feat: SMS OTP phone auth + mandatory phone verification gate
- MyUser: add isPhoneVerified field (from is_phone_verified in API)
- ApiUserRepository: signInWithPhoneNumber calls POST /auth/send-otp,
  verifyOTP calls POST /auth/phone, linkWithOTP calls POST /auth/verify-phone
  Added updateFcmToken and changePassword methods
- AuthBloc: remove Firebase PhoneVerificationService, use repository OTP flow
- app_view.dart: gate authenticated users without verified phone to
  PhoneVerifyRequiredScreen before showing HomeScreen
- welcome_screen.dart: full redesign with gradient header, logo, integrated
  OTP flow (phone → code in same screen), 60s resend timer
- PhoneVerifyRequiredScreen: new screen for users who need to verify phone

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 15:53:43 -05:00

71 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:prosappco/blocs/notification_bloc/notification_bloc.dart';
import 'package:prosappco/screens/authentication/welcome_screen.dart';
import 'package:prosappco/screens/authentication/phone_verify_required_screen.dart';
import 'package:prosappco/screens/home/home_screen.dart';
import 'package:prosappco/screens/splash/splash_screen.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'blocs/authentication_bloc/authentication_bloc.dart';
class MyAppView extends StatelessWidget {
const MyAppView({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Prosappco',
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: const [
Locale('es'),
],
theme: ThemeData(
colorScheme: const ColorScheme.light(
background: Colors.white,
onBackground: Colors.black12,
primary: Color.fromRGBO(66, 164, 239, 1),
onPrimary: Colors.white,
secondary: Colors.white,
onSecondary: Colors.white,
tertiary: Color.fromRGBO(214, 244, 255, 1),
error: Colors.red,
outline: Color(0xFF424242),
secondaryContainer: Colors.red,
),
),
home: BlocConsumer<AuthenticationBloc, AuthenticationState>(
listener: (context, state) {
if (state.status == AuthenticationStatus.authenticated) {
context.read<NotificationBloc>().initializePushNotifications();
}
},
builder: (context, state) {
return _getScreen(state);
},
),
);
}
Widget _getScreen(AuthenticationState state) {
switch (state.status) {
case AuthenticationStatus.authenticated:
final phoneVerified = state.user?.isPhoneVerified ?? false;
if (!phoneVerified) {
return PhoneVerifyRequiredScreen(phone: state.user?.phone);
}
return HomeScreen();
case AuthenticationStatus.unauthenticated:
return const WelcomeScreen();
case AuthenticationStatus.unknown:
return const SplashScreen();
}
}
}