From 441272590046fdcc6f6fec0dbf4727a3a2cb4e85 Mon Sep 17 00:00:00 2001 From: EnricoGia Date: Wed, 25 Oct 2023 21:54:53 -0300 Subject: [PATCH] Alterando cores home e appointments --- mobile/lib/appointments.dart | 500 +++++++++++++++++++---------------- mobile/lib/home.dart | 19 +- mobile/lib/main.dart | 2 +- 3 files changed, 283 insertions(+), 238 deletions(-) diff --git a/mobile/lib/appointments.dart b/mobile/lib/appointments.dart index b233cf8..05b6489 100644 --- a/mobile/lib/appointments.dart +++ b/mobile/lib/appointments.dart @@ -3,6 +3,8 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; +import 'package:mauagendar/main.dart'; + class Appointment { final int id; final String title; @@ -223,7 +225,9 @@ class _CompromissosState extends State { @override Widget build(BuildContext context) { return Scaffold( + backgroundColor: backgroundColor, appBar: AppBar( + backgroundColor: accentColor.withOpacity(0.1), leading: IconButton( icon: const Icon(Icons.arrow_back), onPressed: () => Navigator.pop(context), @@ -233,275 +237,305 @@ class _CompromissosState extends State { body: SingleChildScrollView( child: Form( key: _formKey, - child: Column( - children: [ - const SizedBox(height: 16), - Column( - children: _appointments.map((appointment) { - return Container( - padding: const EdgeInsets.all(16), - margin: - const EdgeInsets.symmetric(vertical: 8, horizontal: 16), - decoration: BoxDecoration( - border: Border.all(color: Colors.purple[300]!), - borderRadius: BorderRadius.circular(8), + child: Container( + alignment: Alignment.topCenter, + child: SizedBox( + width: 800, + child: Column( + children: [ + const SizedBox(height: 16), + Column( + children: _appointments.map((appointment) { + return Container( + padding: const EdgeInsets.all(16), + margin: const EdgeInsets.symmetric( + vertical: 8, horizontal: 16), + decoration: BoxDecoration( + border: Border.all(color: accentColor.withOpacity(0.2)), + borderRadius: BorderRadius.circular(8), + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + primaryColor.withOpacity(0.2), + accentColor.withOpacity(0.2), + ], + )), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + appointment.title, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + const SizedBox(height: 8), + Text( + appointment.description, + style: const TextStyle( + color: Colors.white, + ), + ), + const SizedBox(height: 8), + Text( + 'Tempo de Início: ${appointment.startTime}', + style: const TextStyle( + color: Colors.white, + ), + ), + const SizedBox(height: 8), + Text( + 'Prazo: ${appointment.endTime}', + style: const TextStyle( + color: Colors.white, + ), + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + TextButton( + onPressed: () => + _deleteAppointment(appointment.id), + child: Text( + 'Deletar', + style: TextStyle( + color: Colors.red[500], + ), + ), + ), + TextButton( + onPressed: () => setState(() { + _newAppointment = appointment.copyWith(); + _titleController.text = appointment.title; + _descriptionController.text = + appointment.description; + _startTimeController.text = + appointment.startTime; + _endTimeController.text = + appointment.endTime; + }), + child: Text( + 'Editar', + style: TextStyle( + color: Colors.blue[500], + ), + ), + ), + ], + ), + ], + ), + ); + }).toList(), + ), + const SizedBox(height: 16), + const Text( + 'Criar ou Atualizar Compromisso', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, ), + ), + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - appointment.title, + TextFormField( + controller: _titleController, + decoration: const InputDecoration( + labelText: 'Título', + ), style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, color: Colors.white, ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor, insira um título'; + } + return null; + }, + onChanged: (value) { + setState(() { + _newAppointment = + _newAppointment.copyWith(title: value); + }); + }, ), - const SizedBox(height: 8), - Text( - appointment.description, + const SizedBox(height: 16), + TextFormField( + controller: _descriptionController, + decoration: const InputDecoration( + labelText: 'Descrição', + ), style: const TextStyle( color: Colors.white, ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor, insira uma descrição'; + } + return null; + }, + onChanged: (value) { + setState(() { + _newAppointment = + _newAppointment.copyWith(description: value); + }); + }, ), - const SizedBox(height: 8), - Text( - 'Tempo de Início: ${appointment.startTime}', + const SizedBox(height: 16), + TextFormField( + controller: _startTimeController, + decoration: const InputDecoration( + labelText: 'Tempo de Início', + ), style: const TextStyle( color: Colors.white, ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor, insira um tempo de início'; + } + return null; + }, + onChanged: (value) { + setState(() { + _newAppointment = + _newAppointment.copyWith(startTime: value); + }); + }, ), - const SizedBox(height: 8), - Text( - 'Prazo: ${appointment.endTime}', + const SizedBox(height: 16), + TextFormField( + controller: _endTimeController, + decoration: const InputDecoration( + labelText: 'Prazo', + ), style: const TextStyle( color: Colors.white, ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor, insira um prazo'; + } + return null; + }, + onChanged: (value) { + setState(() { + _newAppointment = + _newAppointment.copyWith(endTime: value); + }); + }, ), const SizedBox(height: 16), Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - TextButton( - onPressed: () => - _deleteAppointment(appointment.id), - child: Text( - 'Deletar', - style: TextStyle( - color: Colors.red[500], + ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + _createAppointment().catchError((error) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Error'), + content: Text(error.toString()), + actions: [ + TextButton( + onPressed: () => + Navigator.pop(context), + child: const Text('OK'), + ), + ], + ), + ); + }); + } + }, + style: ElevatedButton.styleFrom( + foregroundColor: textColor, + backgroundColor: primaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), ), ), - ), - TextButton( - onPressed: () => setState(() { - _newAppointment = appointment.copyWith(); - _titleController.text = appointment.title; - _descriptionController.text = - appointment.description; - _startTimeController.text = - appointment.startTime; - _endTimeController.text = appointment.endTime; - }), - child: Text( - 'Editar', + child: const Text( + 'Criar', style: TextStyle( - color: Colors.blue[500], + color: Colors.white, ), ), ), - ], - ), - ], - ), - ); - }).toList(), - ), - const SizedBox(height: 16), - const Text( - 'Criar ou Atualizar Compromisso', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - const SizedBox(height: 16), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextFormField( - controller: _titleController, - decoration: const InputDecoration( - labelText: 'Título', - ), - style: const TextStyle( - color: Colors.white, - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira um título'; - } - return null; - }, - onChanged: (value) { - setState(() { - _newAppointment = - _newAppointment.copyWith(title: value); - }); - }, - ), - const SizedBox(height: 16), - TextFormField( - controller: _descriptionController, - decoration: const InputDecoration( - labelText: 'Descrição', - ), - style: const TextStyle( - color: Colors.white, - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira uma descrição'; - } - return null; - }, - onChanged: (value) { - setState(() { - _newAppointment = - _newAppointment.copyWith(description: value); - }); - }, - ), - const SizedBox(height: 16), - TextFormField( - controller: _startTimeController, - decoration: const InputDecoration( - labelText: 'Tempo de Início', - ), - style: const TextStyle( - color: Colors.white, - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira um tempo de início'; - } - return null; - }, - onChanged: (value) { - setState(() { - _newAppointment = - _newAppointment.copyWith(startTime: value); - }); - }, - ), - const SizedBox(height: 16), - TextFormField( - controller: _endTimeController, - decoration: const InputDecoration( - labelText: 'Prazo', - ), - style: const TextStyle( - color: Colors.white, - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, insira um prazo'; - } - return null; - }, - onChanged: (value) { - setState(() { - _newAppointment = - _newAppointment.copyWith(endTime: value); - }); - }, - ), - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - ElevatedButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - _createAppointment().catchError((error) { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Error'), - content: Text(error.toString()), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: const Text('OK'), + ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + if (_newAppointment.id == 0) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Error'), + content: const Text( + 'Por favor, selecione um compromisso para atualizar'), + actions: [ + TextButton( + onPressed: () => + Navigator.pop(context), + child: const Text('OK'), + ), + ], ), - ], - ), - ); - }); - } - }, - child: const Text( - 'Criar', - style: TextStyle( - color: Colors.white, - ), - ), - ), - ElevatedButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - if (_newAppointment.id == 0) { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Error'), - content: const Text( - 'Por favor, selecione um compromisso para atualizar'), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: const Text('OK'), - ), - ], - ), - ); - } else { - _updateAppointment(_newAppointment.id) - .catchError((error) { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Error'), - content: Text(error.toString()), - actions: [ - TextButton( - onPressed: () => - Navigator.pop(context), - child: const Text('OK'), + ); + } else { + _updateAppointment(_newAppointment.id) + .catchError((error) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Error'), + content: Text(error.toString()), + actions: [ + TextButton( + onPressed: () => + Navigator.pop(context), + child: const Text('OK'), + ), + ], ), - ], - ), - ); - }); - } - } - }, - child: const Text( - 'Atualizar', - style: TextStyle( - color: Colors.white, + ); + }); + } + } + }, + style: ElevatedButton.styleFrom( + foregroundColor: textColor, + backgroundColor: accentColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + ), + ), + child: const Text( + 'Atualizar', + style: TextStyle( + color: Colors.white, + ), + ), ), - ), + ], ), ], ), - ], - ), + ), + const SizedBox(height: 16), + ], ), - const SizedBox(height: 16), - ], + ), ), ), ), diff --git a/mobile/lib/home.dart b/mobile/lib/home.dart index 6f675f1..b237173 100644 --- a/mobile/lib/home.dart +++ b/mobile/lib/home.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:mauagendar/main.dart'; import 'package:mauagendar/user.dart'; import 'package:mauagendar/navbar.dart'; class HomePage extends StatefulWidget { final User user; const HomePage({super.key, required this.user}); - @override _HomePageState createState() => _HomePageState(); } @@ -18,8 +18,14 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { + const LinearGradient gradient = LinearGradient( + colors: [Color.fromARGB(255, 66, 37, 184), Color.fromARGB(255, 146, 46, 189)], + ); + return Scaffold( + backgroundColor: backgroundColor, appBar: AppBar( + backgroundColor: accentColor.withOpacity(0.1), title: const Text('Mauagendar - Home'), actions: [ Navbar( @@ -28,9 +34,14 @@ class _HomePageState extends State { ], ), body: Center( - child: Text( - "Olá ${widget.user.email}!", - style: const TextStyle(color: Colors.deepPurple, fontSize: 24.0), + child: ShaderMask( + shaderCallback: (Rect rect){ + return gradient.createShader(rect); + }, + child: Text( + "Olá ${widget.user.email}!", + style: const TextStyle(color: Colors.deepPurple, fontSize: 80), + ), ), ), ); diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index 320b465..4b17cd0 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -26,7 +26,7 @@ class LoginApp extends StatelessWidget { theme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed( - seedColor: Colors.white, + seedColor: accentColor, // ··· brightness: Brightness.dark, ),