This commit is contained in:
Juan Felipe Duarte
2023-04-16 17:34:18 -05:00
parent 86e3b47693
commit a22d17b199
16 changed files with 1132 additions and 407 deletions
+255
View File
@@ -0,0 +1,255 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/components/drawer_menu.dart';
import 'package:prosappco/src/components/primary_btn.dart';
import 'package:prosappco/src/screens/professional.dart';
class ServiceScreen extends StatefulWidget {
const ServiceScreen({super.key});
@override
State<ServiceScreen> createState() => _ServiceScreenState();
}
class _ServiceScreenState extends State<ServiceScreen> {
final FirebaseStorage storage = FirebaseStorage.instance;
final uid = AuthenticationRepository.instance.getCurrentUserUid();
var _ciudad = '';
var _photo = '...';
var _estado = '...';
@override
void initState() {
super.initState();
if (_estado == '...') {
AuthenticationRepository.instance
.getState(uid.toString())
.then((String s) => setState(() {
_estado = s;
}));
}
if (_ciudad == '') {
AuthenticationRepository.instance
.getCity(uid.toString())
.then((String s) => setState(() {
_ciudad = s;
}));
}
if (_photo == '...') {
AuthenticationRepository.instance
.getPhoto(uid.toString())
.then((String s) => setState(() {
_photo = s;
}));
}
}
@override
Widget build(BuildContext context) {
final User? user = FirebaseAuth.instance.currentUser;
List<String> opc = ["Servicio", "Opción 1", "Opción 2", "Opción 3"];
String defaultValue = opc[0];
String city = _ciudad.toString();
String state = _estado.toString();
return SafeArea(
child: Scaffold(
backgroundColor: Color(0xFFD6F4FF),
drawer: DrawerMenu(
ref: storage.ref().child(_photo),
userName: user?.displayName ?? '',
userPhoneNumber: user?.phoneNumber ?? '',
userCity: city,
userState: state),
body: SingleChildScrollView(
reverse: true,
child: Stack(
children: [
Padding(
padding: const EdgeInsets.all(20.0),
child: Builder(
builder: (BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
shape: const CircleBorder(),
elevation: 3,
minimumSize: const Size(50, 50),
),
child: const Icon(
Icons.menu,
color: Colors.black,
size: 30,
),
onPressed: () {
Scaffold.of(context).openDrawer();
},
);
},
),
),
Padding(
padding: const EdgeInsets.only(top: 23, left: 100, right: 25),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.4),
spreadRadius: 1,
blurRadius: 2,
offset:
const Offset(1, 2), // changes position of shadow
),
],
),
child: DropdownButtonFormField(
value: defaultValue,
elevation: 0,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(50),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(50),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(50),
borderSide: BorderSide.none,
),
),
items: opc.map((e) {
return DropdownMenuItem(
value: e,
child: Text(
e,
style: const TextStyle(fontWeight: FontWeight.bold),
),
);
}).toList(),
onChanged: (value) {
print(value);
},
),
),
),
],
),
),
bottomNavigationBar: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(50), topLeft: Radius.circular(50))),
height: MediaQuery.of(context).size.height / 2.3,
child: Column(
children: [
const SizedBox(height: 15),
SizedBox(
width: 300,
child: Form(
child: Column(
children: [
TextFormField(
// controller: _cedulaController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.near_me),
hintText: 'Dirección'),
),
const SizedBox(height: 15),
TextFormField(
// controller: _cedulaController,
readOnly: true,
onTap: () async {
final String? profesional = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfessionalScreen();
},
),
) as String?;
if (profesional != null) {
setState(() {
// _profession = profesional;
});
}
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.assignment_ind_rounded),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Seleccionar profesional'),
),
const SizedBox(height: 15),
Row(
children: [
SizedBox(
width: 150,
child: TextFormField(
decoration: const InputDecoration(
suffixIcon: Icon(Icons.arrow_drop_down),
prefixIcon: Icon(Icons.calendar_month),
hintText: 'Fecha'),
)),
SizedBox(
width: 150,
child: TextFormField(
decoration: const InputDecoration(
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Hora'),
)),
],
),
const SizedBox(height: 15),
TextFormField(
// controller: _cedulaController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.message_outlined),
hintText: 'Observaciones'),
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 50),
),
child: const Text(
'Solicitar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
],
),
),
),
],
),
),
),
);
}
}