Untitled
unknown
plain_text
7 months ago
21 kB
5
Indexable
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Especializacare',
theme: ThemeData(
primarySwatch: Colors.pink,
scaffoldBackgroundColor: Colors.white,
),
home: const WelcomeScreen(),
);
}
}
// 🔹 Tela de Boas-Vindas Moderna
class WelcomeScreen extends StatelessWidget {
const WelcomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Colors.redAccent, Colors.pinkAccent],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/logo.png', height: 180), // Substitua pelo seu logo
Text(
"Especializacare",
style: GoogleFonts.poppins(
fontSize: 36,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
const SizedBox(height: 10),
Text(
"Seu cuidado especializado, a um clique de distância!",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(fontSize: 16, color: Colors.white70),
),
const SizedBox(height: 40),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PatientRegistrationScreen()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
padding:
const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
elevation: 5,
),
child: Text(
"Começar",
style: GoogleFonts.poppins(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.pink),
),
),
],
),
),
);
}
}
// 🔹 Tela de Cadastro Prévio do Paciente
class PatientRegistrationScreen extends StatefulWidget {
const PatientRegistrationScreen({super.key});
@override
State<PatientRegistrationScreen> createState() =>
_PatientRegistrationScreenState();
}
class _PatientRegistrationScreenState extends State<PatientRegistrationScreen> {
final _formKey = GlobalKey<FormState>();
final TextEditingController _nameController = TextEditingController();
final TextEditingController _ageController = TextEditingController();
final TextEditingController _weightController = TextEditingController();
final TextEditingController _heightController = TextEditingController();
// Função auxiliar para converter string para double, tratando a vÃrgula como decimal
double? parseStringToDouble(String? value) {
if (value == null || value.isEmpty) {
return null;
}
final cleanedValue = value.replaceAll(',', '.');
return double.tryParse(cleanedValue);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Cadastro"), backgroundColor: Colors.pink),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
controller: _nameController,
decoration: const InputDecoration(labelText: 'Nome Completo'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, digite seu nome.';
}
return null;
},
),
TextFormField(
controller: _ageController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(labelText: 'Idade'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, digite sua idade.';
}
final age = int.tryParse(value);
if (age == null || age <= 0) {
return 'Por favor, digite uma idade válida.';
}
return null;
},
),
TextFormField(
controller: _weightController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(labelText: 'Peso (em kg)'),
validator: (value) {
final weight = parseStringToDouble(value);
if (weight == null || weight <= 0) {
return 'Por favor, digite um peso válido.';
}
return null;
},
),
TextFormField(
controller: _heightController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(labelText: 'Altura (em metros)'),
validator: (value) {
final height = parseStringToDouble(value);
if (height == null || height <= 0) {
return 'Por favor, digite uma altura válida.';
}
return null;
},
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AppointmentSchedulingScreen(
weight: parseStringToDouble(_weightController.text) ?? 0.0,
height: parseStringToDouble(_heightController.text) ?? 0.0,
),
),
);
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.pink,
padding:
const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
),
child: const Text("Continuar para Agendamento",
style: TextStyle(color: Colors.white)),
),
],
),
),
),
);
}
@override
void dispose() {
_nameController.dispose();
_ageController.dispose();
_weightController.dispose();
_heightController.dispose();
super.dispose();
}
}
// 🔹 Tela para Fazer o Agendamento com os Médicos DisponÃveis
class AppointmentSchedulingScreen extends StatefulWidget {
final double weight;
final double height;
const AppointmentSchedulingScreen({super.key, required this.weight, required this.height});
@override
State<AppointmentSchedulingScreen> createState() =>
_AppointmentSchedulingScreenState();
}
class _AppointmentSchedulingScreenState
extends State<AppointmentSchedulingScreen> {
String? _selectedDoctor;
DateTime? _selectedDate;
TimeOfDay? _selectedTime;
final List<Map<String, String>> _availableDoctors = [
{'name': 'Dra. Ana Paula', 'description': 'Cardiologista com foco em prevenção.'},
{'name': 'Dr. Carlos Alberto', 'description': 'Dermatologista especialista em acne e rosácea.'},
{'name': 'Dr. Mariana Silva', 'description': 'Pediatra com experiência em desenvolvimento infantil.'},
{'name': 'Dr. João Pedro', 'description': 'ClÃnico Geral para consultas de rotina e check-ups.'},
{'name': 'Dra. Sofia Mendes', 'description': 'Ginecologista e obstetra.'},
{'name': 'Dr. Ricardo Alves', 'description': 'Ortopedista especializado em lesões esportivas.'},
{'name': 'Dra. Laura Castro', 'description': 'Oftalmologista com foco em cirurgia refrativa.'},
{'name': 'Dr. Gustavo Ferreira', 'description': 'Neurologista especialista em dores de cabeça.'},
{'name': 'Dra. PatrÃcia Oliveira', 'description': 'Endocrinologista com experiência em diabetes.'},
{'name': 'Dr. Bruno Rocha', 'description': 'Urologista geral.'},
{'name': 'Dra. Amanda Souza', 'description': 'Psiquiatra com abordagem integrativa.'},
{'name': 'Dr. Rafael Costa', 'description': 'Gastroenterologista especialista em doenças inflamatórias intestinais.'},
{'name': 'Dra. Isabela Pereira', 'description': 'Reumatologista com foco em artrite reumatoide.'},
{'name': 'Dr. Lucas Gomes', 'description': 'Otorrinolaringologista.'},
{'name': 'Dra. Fernanda Nunes', 'description': 'Pneumologista especialista em asma.'},
{'name': 'Dr. Eduardo Vieira', 'description': 'Nefrologista.'},
{'name': 'Dra. Carolina Martins', 'description': 'Hematologista.'},
{'name': 'Dr. Thiago Santos', 'description': 'Infectologista.'},
{'name': 'Dra. Juliana Ribeiro', 'description': 'Alergista e imunologista.'},
{'name': 'Dr. Leonardo Sousa', 'description': 'Cirurgião geral.'},
{'name': 'Dra. Beatriz Oliveira', 'description': 'Cardiologista intervencionista.'},
{'name': 'Dr. VinÃcius Costa', 'description': 'Dermatologista com foco em estética.'},
{'name': 'Dra. Camila Ferreira', 'description': 'Pediatra especialista em neonatologia.'},
{'name': 'Dr. André Rocha', 'description': 'ClÃnico Geral com foco em geriatria.'},
{'name': 'Dra. Manuela Mendes', 'description': 'Ginecologista especialista em fertilidade.'},
{'name': 'Dr. Pedro Alves', 'description': 'Ortopedista especialista em cirurgia de joelho.'},
{'name': 'Dra. Renata Castro', 'description': 'Oftalmologista especialista em glaucoma.'},
{'name': 'Dr. Marcelo Ferreira', 'description': 'Neurologista especialista em epilepsia.'},
{'name': 'Dra. Simone Oliveira', 'description': 'Endocrinologista com foco em tireoide.'},
{'name': 'Dr. Gustavo Rocha', 'description': 'Urologista especialista em oncologia.'},
];
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2026),
);
if (picked != null && picked != _selectedDate) {
setState(() {
_selectedDate = picked;
});
}
}
Future<void> _selectTime(BuildContext context) async {
final TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
if (picked != null && picked != _selectedTime) {
setState(() {
_selectedTime = picked;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Agendamento"), backgroundColor: Colors.pink),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DropdownButtonFormField<Map<String, String>>(
decoration: const InputDecoration(labelText: 'Selecione o Médico'),
value: _availableDoctors.firstWhere((doctor) => doctor['name'] == _selectedDoctor, orElse: () => _availableDoctors.first),
items: _availableDoctors.map((Map<String, String> doctor) {
return DropdownMenuItem<Map<String, String>>(
value: doctor,
child: Text(doctor['name']!),
);
}).toList(),
onChanged: (Map<String, String>? newValue) {
setState(() {
_selectedDoctor = newValue?['name'];
});
},
validator: (value) {
if (value == null) {
return 'Por favor, selecione um médico.';
}
return null;
},
),
// Aqui você pode adicionar um widget para exibir a descrição do médico selecionado
// Exemplo:
// if (_selectedDoctor != null) {
// Text(_availableDoctors.firstWhere((doctor) => doctor['name'] == _selectedDoctor)['description']!);
// }
const SizedBox(height: 20),
Row(
children: <Widget>[
Expanded(
child: Text(
_selectedDate == null
? 'Nenhuma data selecionada'
: 'Data: ${_selectedDate!.day}/${_selectedDate!.month}/${_selectedDate!.year}',
),
),
ElevatedButton(
onPressed: () => _selectDate(context),
child: const Text('Selecionar Data'),
),
],
),
const SizedBox(height: 20),
Row(
children: <Widget>[
Expanded(
child: Text(
_selectedTime == null
? 'Nenhum horário selecionado'
: 'Horário: ${_selectedTime!.format(context)}',
),
),
ElevatedButton(
onPressed: () => _selectTime(context),
child: const Text('Selecionar Horário'),
),
],
),
const SizedBox(height: 40),
ElevatedButton(
onPressed: () {
if (_selectedDoctor != null &&
_selectedDate != null &&
_selectedTime != null) {
final selectedDoctorData = _availableDoctors.firstWhere((doctor) => doctor['name'] == _selectedDoctor);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AppointmentConfirmationScreen(
doctor: _selectedDoctor!,
date: _selectedDate!,
time: _selectedTime!,
weight: widget.weight,
height: widget.height,
doctorDescription: selectedDoctorData['description']!, // Passando a descrição
),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, selecione o médico, a data e o horário.')),
);
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
padding:
const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
),
child: const Text("Confirmar Agendamento",
style: TextStyle(color: Colors.white)),
),
],
),
),
);
}
}
// 🔹 Tela de Confirmação de Agendamento
class AppointmentConfirmationScreen extends StatelessWidget {
final String doctor;
final DateTime date;
final TimeOfDay time;
final double weight;
final double height;
final String doctorDescription; // Adicionando a descrição do médico
const AppointmentConfirmationScreen({
super.key,
required this.doctor,
required this.date,
required this.time,
required this.weight,
required this.height,
required this.doctorDescription, // Recebendo a descrição
});
double calculateIMC() {
if (height <= 0) return 0.0;
return weight / (height * height);
}
String getIMCMessage(double imc) {
if (imc < 18.5) {
return 'Seu IMC está abaixo do peso.';
} else if (imc >= 18.5 && imc < 25) {
return 'Seu IMC está dentro da faixa saudável.';
} else if (imc >= 25 && imc < 30) {
return 'Seu IMC indica sobrepeso.';
} else {
String message = 'Seu IMC indica obesidade. Consulte um médico.';
if (imc > 35) {
message += ' (Você está gordo.)';
}
return message;
}
}
@override
Widget build(BuildContext context) {
final imc = calculateIMC();
final imcMessage = getIMCMessage(imc);
return Scaffold(
appBar: AppBar(title: const Text("Confirmação"), backgroundColor: Colors.green),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Icon(Icons.check_circle_outline,
color: Colors.green, size: 100),
const SizedBox(height: 20),
Text(
"Agendamento Confirmado!",
style: GoogleFonts.poppins(
fontSize: 24, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(height: 10),
Text(
"Seu agendamento com:",
style: GoogleFonts.poppins(fontSize: 18),
textAlign: TextAlign.center,
),
Text(
doctor,
style: GoogleFonts.poppins(
fontSize: 20, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
const SizedBox(height: 5),
Text(
doctorDescription, // Exibindo a descrição do médico
style: GoogleFonts.poppins(fontSize: 14, color: Colors.grey[600]),
textAlign: TextAlign.center,
),
const SizedBox(height: 10),
Text(
"Para o dia:",
style: GoogleFonts.poppins(fontSize: 18),
textAlign: TextAlign.center,
),
Text(
"${date.day}/${date.month}/${date.year}",
style: GoogleFonts.poppins(
fontSize: 20, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
const SizedBox(height: 10),
Text(
"Às:",
style: GoogleFonts.poppins(fontSize: 18),
textAlign: TextAlign.center,
),
Text(
time.format(context),
style: GoogleFonts.poppins(
fontSize: 20, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
Text(
"Seu IMC é: ${imc.toStringAsFixed(2)}",
style: GoogleFonts.poppins(fontSize: 18, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
Text(
imcMessage,
style: GoogleFonts.poppins(fontSize: 16),
textAlign: TextAlign.center,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: () {
Navigator.popUntil(context, (route) => route.isFirst);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.pink,
padding:
const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
),
child: const Text("Voltar para a Tela Inicial",
style: TextStyle(color: Colors.white)),
),
],
),
),
),
);
}
}Editor is loading...
Leave a Comment