import 'package:fis_common/index.dart';
import 'package:fis_vid/common/env.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vid_player_demo/pages/single_image.dart/view.dart';
import 'package:vid_player_demo/widgets/image_cache.dart';

import 'pages/canvas_player/view.dart';
import 'pages/image_player/view.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: <String, WidgetBuilder>{
        '/': (BuildContext context) =>
            const MyHomePage(title: 'Vid Player Demo Home Page'),
        '/single_image': (BuildContext context) => const SingleImageView(),
        '/image_player': (BuildContext context) => const ImagePlayerView(),
        '/canvas_player': (BuildContext context) => const CanvasPlayerView(),
      },
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            const ShowImageCache(),
            const SizedBox(height: 24),
            ElevatedButton(
              child: const Text('Single Image'),
              onPressed: () => Navigator.pushNamed(context, '/single_image'),
            ),
            const SizedBox(height: 8),
            ElevatedButton(
                onPressed: () => Navigator.pushNamed(context, '/image_player'),
                child: const Text('Image Player')),
            const SizedBox(height: 8),
            ElevatedButton(
                onPressed: () => Navigator.pushNamed(context, '/canvas_player'),
                child: const Text('Canvas Player')),
            const SizedBox(height: 24),
          ],
        ),
      ),
    );
  }
}
