import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:myhr_facescan_example/active_liveness/index.dart';
import 'package:myhr_facescan_example/enroll/index.dart';
import 'package:myhr_facescan_example/match_face/index.dart';
import 'package:myhr_facescan_example/template_controller.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const GetMaterialApp(home: HomePage());
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    var con = Get.put(TemplateController());

    return Scaffold(
      appBar: AppBar(
        title: const Text('Luxand x Flutter'),
      ),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
                onPressed: () => Get.to(const EnrollPage()),
                child: const Text('Enroll Face')),
            ElevatedButton(
                onPressed: () => Get.to(const ActiveLivenessPage()),
                child: const Text('Active Liveness')),
            ElevatedButton(
                onPressed: () => Get.to(const MatchFacePage()),
                child: const Text('Match Face')),
            ElevatedButton(
                onPressed: () async {
                  con.removeAll();
                  Get.snackbar('Success', 'Template in device is removed.');
                },
                child: const Text('Clear storage')),
            ElevatedButton(
                onPressed: () async {
                  Get.snackbar('Total: ${con.templates.length}', '');
                },
                child: const Text('Get total template')),
          ],
        ),
      ),
    );
  }
}
