import 'package:auto_route/annotations.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mnemo_cards/di/locator.dart';
import 'package:mnemo_cards/flags.dart';
import 'package:mnemo_cards/widgets/header.dart';
import 'package:url_launcher/url_launcher.dart';

import '../main.dart';
import '../theme/themes.dart';
import '../widgets/shared_pref_button.dart';

@RoutePage()
class AuthPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(
          children: [
            SizedBox(
              height: 64.h - MediaQuery.of(context).padding.top,
            ),
            Text(
              'Mnemo cards',
              style: TextStyle(
                fontSize: 36.sp,
                fontWeight: FontWeight.w500,
                height: 0.85,
              ),
              textAlign: TextAlign.start,
            ),
            SizedBox(
              height: 60.h,
            ),
            Expanded(
              child: Image.asset(
                'images/cerdo.jpg',
                fit: BoxFit.fitWidth,
              ),
            ),
            if (ADMIN_BUILD)
              SharedPrefButton(
                enabledWidget: Text('PROD'),
                disabledWidget: Text('TEST'),
                spKey: 'env',
              ),
            Padding(
              padding:
                  EdgeInsets.symmetric(horizontal: 10.0.w, vertical: 5.0.h),
              child: InkWell(
                onTap: locator.userManager.login,
                child: Container(
                  height: 90.h,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border.all(color: borderGray),
                    borderRadius: BorderRadius.circular(16.0),
                  ),
                  padding: EdgeInsets.all(10.0.w),
                  child: Image.asset(
                    'icons/google.png',
                    height: 88.h,
                  ),
                ),
              ),
            ),
            Padding(
              padding:
                  EdgeInsets.symmetric(horizontal: 10.0.w, vertical: 10.0.h),
              child: RichText(
                  text: TextSpan(
                    children: [
                      TextSpan(
                          text:
                              'Присоединяясь, я заявляю что прочитал и принимаю '),
                      // TextSpan(
                      //   text: 'условия',
                      //   recognizer: TapGestureRecognizer()
                      //     ..onTap =
                      //         () => launchUrl(Uri.parse('https://www.google.com')),
                      //   style: TextStyle(decoration: TextDecoration.underline),
                      // ),
                      // TextSpan(text: ' и '),
                      TextSpan(
                          text: 'политику конфиденциальности',
                          recognizer: TapGestureRecognizer()
                            ..onTap = () => launchUrl(Uri.parse(
                                'https://www.freeprivacypolicy.com/live/1c2bce51-86c6-4a36-b226-b6c6f50ebf0f')),
                          style:
                              TextStyle(decoration: TextDecoration.underline)),
                      TextSpan(text: '.'),
                    ],
                    style: TextStyle(
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w300,
                      height: 1.1,
                      color: borderGray,
                    ),
                  ),
                  textAlign: TextAlign.center),
            ),
          ],
        ),
      ),
    );
  }
}
