- Replace Firebase Auth with JWT stored in SharedPreferences - Replace Firestore with REST API calls via new ApiService - Replace Firebase Storage with POST /storage/upload - Remove firebase_auth, firebase_core, cloud_firestore, firebase_storage, firebase_messaging, google_sign_in deps - Add api_service.dart as central HTTP client Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
263 lines
12 KiB
Dart
263 lines
12 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:intl_phone_field/intl_phone_field.dart';
|
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
|
import 'package:prosappco/src/components/primary_btn.dart';
|
|
import 'package:prosappco/src/controllers/new_phone_controller.dart';
|
|
|
|
class NewNumberScreen extends StatefulWidget {
|
|
const NewNumberScreen({super.key});
|
|
|
|
@override
|
|
State<NewNumberScreen> createState() => _NewNumberScreenState();
|
|
}
|
|
|
|
class _NewNumberScreenState extends State<NewNumberScreen> {
|
|
final controller = Get.put(NewPhoneController());
|
|
String completePhoneNumber = '';
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: PopAppbar(
|
|
onPressed: () {
|
|
_formKey.currentState!.reset();
|
|
Navigator.pop(context);
|
|
},
|
|
label: 'Añadir numero',
|
|
),
|
|
body: !kIsWeb
|
|
? Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 0, vertical: 20),
|
|
margin: const EdgeInsets.only(top: 30, left: 50, right: 50),
|
|
child: Column(
|
|
children: [
|
|
const Padding(
|
|
padding: EdgeInsets.only(bottom: 5),
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: Text('Numero de celular',
|
|
style: TextStyle(
|
|
fontSize: 18.0, color: Color(0xFF65676B))),
|
|
)),
|
|
Form(
|
|
key: _formKey,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
child: IntlPhoneField(
|
|
controller: controller.newPhoneNo,
|
|
initialCountryCode: 'CO',
|
|
onChanged: (newPhoneNo) {
|
|
completePhoneNumber = newPhoneNo.completeNumber;
|
|
},
|
|
decoration: const InputDecoration(
|
|
border: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
errorBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: Color.fromARGB(255, 184, 0, 0)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
fillColor: Color.fromARGB(255, 239, 239, 239),
|
|
filled: true,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(bottom: 30),
|
|
child: Text(
|
|
'Se enviará un código a este número de celular',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 13.0, color: Color(0xFF65676B))),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(top: 10, bottom: 30),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20, vertical: 15),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFD6F4FF),
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.grey.withOpacity(0.5),
|
|
spreadRadius: 1,
|
|
blurRadius: 5,
|
|
offset: const Offset(1, 3),
|
|
),
|
|
],
|
|
),
|
|
child: const Row(
|
|
children: [
|
|
Icon(
|
|
Icons.error_outline,
|
|
size: 27,
|
|
color: Colors.black54,
|
|
),
|
|
SizedBox(width: 15),
|
|
Expanded(
|
|
child: Text(
|
|
'¡Al actualizar tu número, se cerrará la sesión para confirmar que eres tú!.',
|
|
style:
|
|
TextStyle(color: Colors.black, fontSize: 14),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 30),
|
|
child: Center(
|
|
child: PrimaryButtom(
|
|
onPressed: () {
|
|
controller.updatePhoneNumber(
|
|
completePhoneNumber.toString());
|
|
},
|
|
label: 'Actualizar número'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
: Center(
|
|
child: Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 0, vertical: 20),
|
|
width: 400,
|
|
margin: const EdgeInsets.only(top: 30, left: 50, right: 50),
|
|
child: Column(
|
|
children: [
|
|
const Padding(
|
|
padding: EdgeInsets.only(bottom: 5),
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: Text('Numero de celular',
|
|
style: TextStyle(
|
|
fontSize: 18.0, color: Color(0xFF65676B))),
|
|
)),
|
|
Form(
|
|
key: _formKey,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
child: IntlPhoneField(
|
|
controller: controller.newPhoneNo,
|
|
initialCountryCode: 'CO',
|
|
onChanged: (newPhoneNo) {
|
|
completePhoneNumber = newPhoneNo.completeNumber;
|
|
},
|
|
decoration: const InputDecoration(
|
|
border: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
errorBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: Color.fromARGB(255, 184, 0, 0)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(color: Color(0xFFECECEC)),
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(50),
|
|
)),
|
|
fillColor: Color.fromARGB(255, 239, 239, 239),
|
|
filled: true,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(bottom: 30),
|
|
child: Text(
|
|
'Se enviará un código a este número de celular',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 13.0, color: Color(0xFF65676B))),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(top: 10, bottom: 30),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20, vertical: 15),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFD6F4FF),
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.grey.withOpacity(0.5),
|
|
spreadRadius: 1,
|
|
blurRadius: 5,
|
|
offset: const Offset(1, 3),
|
|
),
|
|
],
|
|
),
|
|
child: const Row(
|
|
children: [
|
|
Icon(
|
|
Icons.error_outline,
|
|
size: 27,
|
|
color: Colors.black54,
|
|
),
|
|
SizedBox(width: 15),
|
|
Expanded(
|
|
child: Text(
|
|
'¡Al actualizar tu número, se cerrará la sesión para confirmar que eres tú!.',
|
|
style: TextStyle(
|
|
color: Colors.black, fontSize: 14),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 30),
|
|
child: Center(
|
|
child: PrimaryButtom(
|
|
onPressed: () {
|
|
controller.updatePhoneNumber(
|
|
completePhoneNumber.toString());
|
|
},
|
|
label: 'Actualizar número'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|