import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/views/widgets/my_textField.dart';
import 'controller/login_controller.dart';

class LoginPage extends StatelessWidget {
  final LoginController controller = Get.put(LoginController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const CupertinoNavigationBar(
        middle: Text('Login'),
      ),
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Form(
            key: controller.formKey,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                const SizedBox(height: 20),
                MyTextForm(
                    controller: controller.email,
                    label: 'email',
                    hint: 'email',
                    type: TextInputType.emailAddress),
                const SizedBox(height: 20),
                MyTextForm(
                    controller: controller.password,
                    label: 'Password',
                    hint: 'Password',
                    type: TextInputType.name),
                const SizedBox(height: 40),
                CupertinoButton.filled(
                  child: const Text('Login'),
                  onPressed: () {
                    controller.login();
                  },
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
