import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-registration-viewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';

import 'lacum-registration-page.dart';

class LakumActivationVidaPage extends StatelessWidget {
  TextEditingController _identificationNumberController =
      new TextEditingController();

  @override
  Widget build(BuildContext context) {
    final mediaQuery = MediaQuery.of(context);

    return BaseView<LacumRegistrationViewModel>(
      builder: (_, model, wi) => AppScaffold(
        title: "Acount Activation",
        isShowAppBar: true,
        isShowDecPage: false,
        backgroundColor: Colors.white,
        baseViewModel: model,
        body: Container(
          margin: EdgeInsets.symmetric(vertical: 16, horizontal: 12),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Texts(
                    " This service allows you to activate your LAKUM account after registering through the Vida system. ",
                    fontSize: 14,
                  ),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: TextField(
                      controller: _identificationNumberController,
                      decoration: new InputDecoration(
                        hintText: 'Enter Identification Number',
                      ),
                      style: TextStyle(
                        fontSize: 16,
                        color: Colors.grey.shade700,
                      ),
                    ),
                  ),
                ],
              ),
              Container(
                margin: EdgeInsets.only(top: 4),
                child: BorderedButton(
                  TranslationBase.of(context).accountActivation,
                  backgroundColor:
                      _identificationNumberController.text != null &&
                              _identificationNumberController.text != ""
                          ? Color(0xff60686b)
                          : Color(0xffb0b4b5),
                  textColor: Colors.white,
                  fontSize: 16,
                  hPadding: 8,
                  vPadding: 12,
                  handler: _identificationNumberController.text != null &&
                          _identificationNumberController.text != ""
                      ? () {
                          model
                              .checkLacumAccountActivation(
                                  _identificationNumberController.text)
                              .then((_) => {
                                    if (model.state == ViewState.Idle)
                                      {
                                        Navigator.push(
                                                context,
                                                FadePage(
                                                    page: LakumRegistrationPage(
                                                        _identificationNumberController
                                                            .text)))
                                            .then((status) => {
                                                  if (status == 200)
                                                    {Navigator.pop(context, "")}
                                                  // back to previous page
                                                })
                                      }
                                  });
                        }
                      : null,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
