Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:agendamento/controllers/agendar.controller.dart';
- import 'package:agendamento/styles/styles.dart';
- import 'package:agendamento/widgets/button.widget.dart';
- import 'package:agendamento/widgets/custom_radio_buttom.widget.dart';
- import 'package:flutter_mobx/flutter_mobx.dart';
- import 'package:flutter/material.dart';
- import 'package:date_picker_timeline/date_picker_timeline.dart';
- import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
- import 'package:get_it/get_it.dart';
- import 'package:progress_indicators/progress_indicators.dart';
- class AgendarPage extends StatefulWidget {
- @override
- _AgendarPageState createState() => _AgendarPageState();
- }
- class _AgendarPageState extends State<AgendarPage> {
- AgendarController agendamento = GetIt.I.get<AgendarController>();
- @override
- void initState() {
- super.initState();
- }
- DatePickerController _controller = DatePickerController();
- @override
- Widget build(BuildContext context) {
- agendamento.verificaHorarios(DateTime.now());
- return Stack(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(top: 5, bottom: 5),
- color: Colors.white,
- child: ListView(
- children: <Widget>[
- SizedBox(
- height: 125,
- ),
- Observer(
- builder: (_) {
- return Column(
- children: <Widget>[
- Card(
- elevation: 5,
- margin: EdgeInsets.only(top: 15, left: 4, right: 4),
- child: Container(
- padding: EdgeInsets.all(20),
- child: agendamento.feriado
- ? Container(
- child: Center(
- child: Text('Não atendemos nos feriados!',
- style: AppTheme.erroMsg),
- ),
- )
- : agendamento.selectedDate.weekday == 7
- ? Container(
- child: Center(
- child: Text(
- 'Não atendemos aos domingos!',
- style: AppTheme.erroMsg),
- ),
- )
- : agendamento.horarios.length == 0 &&
- agendamento.isLoading
- ? Center(
- child: GlowingProgressIndicator(
- child: Image.asset(
- 'assets/images/icon.png',
- width: 50,
- height: 70),
- ),
- )
- : agendamento.horarios.length == 0
- ? Column(
- children: <Widget>[
- Center(
- child: Text(
- 'Não há mais horários disponíveis nessa data!',
- style: AppTheme.erroMsg,
- textAlign: TextAlign.center,
- ),
- )
- ],
- )
- : agendamento.isLoading
- ? Center(
- child:
- GlowingProgressIndicator(
- child: Image.asset(
- 'assets/images/icon.png',
- width: 50,
- height: 70),
- ),
- )
- : Observer(
- builder: (_) {
- return AnimationLimiter(
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment
- .stretch,
- children:
- AnimationConfiguration
- .toStaggeredList(
- duration:
- const Duration(
- milliseconds:
- 700),
- childAnimationBuilder:
- (widget) =>
- FlipAnimation(
- child: widget,
- ),
- children: <Widget>[
- Center(
- child: Text(
- 'Selecione um horário',
- style: TextStyle(
- fontSize:
- 18.0,
- fontFamily:
- 'Poppins'),
- ),
- ),
- SizedBox(
- height: 10,
- ),
- GridView.builder(
- shrinkWrap: true,
- itemCount:
- agendamento
- .horarios
- .length,
- gridDelegate:
- SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount:
- 3,
- childAspectRatio: MediaQuery.of(
- context)
- .size
- .width /
- (MediaQuery.of(context)
- .size
- .height /
- 4),
- ),
- itemBuilder:
- (BuildContext
- context,
- int index) {
- return Padding(
- padding:
- EdgeInsets
- .all(
- 8),
- child: Observer(
- builder:
- (_) {
- return RaisedButton(
- child:
- new Text(
- agendamento
- .horarios[index],
- style: TextStyle(
- fontFamily:
- 'Poppins'),
- ),
- textColor:
- Colors
- .white,
- shape:
- new RoundedRectangleBorder(
- borderRadius:
- new BorderRadius.circular(30.0),
- ),
- color: agendamento.currentSelectedLabel ==
- agendamento.horarios[
- index]
- ? Color.fromRGBO(
- 247,
- 87,
- 161,
- 1)
- : Colors
- .blue,
- onPressed:
- () {
- agendamento.currentSelected =
- index;
- agendamento
- .currentSelectedLabel = agendamento
- .horarios[
- index];
- agendamento
- .selecionarHora(agendamento.horariosFull[index]);
- },
- );
- }),
- );
- },
- ),
- SizedBox(
- height: 15,
- ),
- ],
- ),
- ),
- );
- },
- ),
- ),
- ),
- agendamento.isLoading
- ? Container()
- : agendamento.selectedDate.weekday == 7 ||
- agendamento.horarios.length == 0
- ? Container()
- : Card(
- elevation: 5,
- margin: EdgeInsets.only(
- top: 10, left: 4, right: 4),
- child: Container(
- padding: EdgeInsets.all(20),
- child: AnimationLimiter(
- child: Column(
- children: AnimationConfiguration
- .toStaggeredList(
- duration:
- const Duration(milliseconds: 700),
- childAnimationBuilder: (widget) =>
- FlipAnimation(
- child: widget,
- ),
- children: <Widget>[
- Center(
- child: Text(
- 'Selecione um serviço',
- style: TextStyle(
- fontSize: 18.0,
- fontFamily: 'Poppins'),
- ),
- ),
- SizedBox(
- height: 10,
- ),
- CustomRadioButton(
- height: 40,
- enableShape: true,
- buttonColor: Colors.white,
- buttonLabels: [
- 'Design sem henna (R\$ 25,00)',
- 'Design com henna (R\$ 35,00)'
- ],
- buttonValues: [
- 'Design sem henna',
- 'Design com henna'
- ],
- radioButtonValue:
- agendamento.selecionarServico,
- horizontal: true,
- selectedColor: Colors.black,
- ),
- SizedBox(
- height: 40,
- ),
- Observer(
- builder: (_) => CriaBotao(
- texto: 'AGENDAR',
- horario:
- agendamento.horaSelecionada,
- servico: agendamento
- .servicoSelecionado,
- context: context,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- SizedBox(
- height: 20,
- ),
- ],
- );
- },
- ),
- ],
- ),
- ),
- Card(
- elevation: 5,
- child: Container(
- height: 120,
- margin: EdgeInsets.all(8),
- child: Column(
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text(
- 'Selecione a data',
- style: TextStyle(fontSize: 18.0, fontFamily: 'Poppins'),
- ),
- ],
- ),
- SizedBox(
- height: 8,
- ),
- DatePicker(
- DateTime.now(),
- width: 60,
- height: 80,
- controller: _controller,
- initialSelectedDate: DateTime.now(),
- selectionColor: Colors.black,
- selectedTextColor: Colors.white,
- daysCount: 10,
- locale: 'pt_BR',
- onDateChange: agendamento.verificaHorarios,
- ),
- ],
- ),
- ),
- ),
- ],
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement