import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:myhr_facescan/models/template.dart';
import 'package:myhr_facescan_example/enroll/finish.dart';
import 'package:myhr_facescan_example/env.dart';
import 'package:myhr_facescan/active_liveness/index.dart';
import 'package:myhr_facescan_example/main.dart';

class LivenessPage extends StatelessWidget {
  const LivenessPage({super.key, required this.templates});

  final List<TemplateModel> templates;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Liveness Detection'),
      ),
      body: SafeArea(
          child: ActiveLivenessVerifier(
        licenseKey: Env.luxandLicenseKey,
        onFinish: (success, template) {
          if (success) {
            Get.off(FinishPage(templates: templates));
          } else {
            Get.snackbar('Failed', 'You\'re not human.');
            Get.offAll(const HomePage());
          }
        },
      )),
    );
  }
}
