import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:namer_app/list.dart';
import 'package:namer_app/login.dart';
import 'package:namer_app/lang.dart';

void main() {
  runApp(MyApp(
      // items: List<String>.generate(7, (i) => '$i')
      ));
}

final _router = GoRouter(
  routes: [
    GoRoute(path: '/', builder: (context, state) => MyHomePage(), //),
        routes: [
          GoRoute(
            path: 'login',
            builder: (context, state) => LoginPage(),
          ),
          GoRoute(
            path: 'list',
            builder: (context, state) => ListPage(),
          ),
        ]),
  ],
);

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      debugShowCheckedModeBanner: false,
      title: 'TelNow Lat',
      theme: ThemeData(
        useMaterial3: true,
      ),
      routerConfig: _router,
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                colors: [
                  Color(0xffD9D9D9),
                  Color(0xff0F968E),
                  Color(0xff000000)
                ]),
            image: DecorationImage(
              image: AssetImage("assets/images/building.jpg"),
              fit: BoxFit.cover,
            )),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Lang(),
              ],
            ),
            Expanded(
              child: Center(
                  child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    'tel',
                    style: TextStyle(color: Color(0xffFF6600), fontSize: 48),
                  ),
                  Text(
                    'now',
                    style: TextStyle(color: Color(0xffFFFFFF), fontSize: 48),
                  ),
                ],
              )),
            ),
            Padding(
              padding: const EdgeInsets.only(left: 180, right: 180),
              child: Text(
                'Silakan pindai QR terlebih dulu untuk mulai menggunakan aplikasi.',
                softWrap: true,
                textAlign: TextAlign.center,
                style: TextStyle(fontSize: 16, color: Colors.white),
              ),
            ),
            Expanded(
              child: Center(child: Pindai()),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: [
                  Text('Kebijakan Privasi',
                      style: TextStyle(
                          fontSize: 16,
                          decoration: TextDecoration.underline,
                          fontWeight: FontWeight.w400,
                          decorationColor: Colors.white,
                          color: Colors.white)),
                  Text('Versi 4.0.0.0',
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w400,
                        color: Colors.white,
                      ))
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class Pindai extends StatelessWidget {
  const Pindai({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: 257,
        height: 96,
        child: ElevatedButton(
          onPressed: () => context.go('/login'),
          style: ElevatedButton.styleFrom(
            backgroundColor: Color(0xff078C84).withOpacity(0.76),
            side: BorderSide(color: Colors.white),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12.0),
            ),
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                'Pindai QR',
                style: TextStyle(color: Colors.white, fontSize: 20),
              ),
              Image.asset(
                'assets/images/scan_icon_183865.png',
                width: 32,
                height: 32,
                fit: BoxFit.cover,
                color: Color(0xffFFFFFF),
              )
            ],
          ),
        ));
  }
}
