import 'dart:io';

import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:url_launcher/url_launcher.dart';

class UpdateAvailableScreen extends StatelessWidget {
  static const String routeName = "/UpdateAvailableScreen";

  UpdateAvailableScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Hero(tag: "logo", child: "logo".toSvgAsset(height: 64)),
          48.height,
          Text(
            "Update Available",
            style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
          ),
          24.height,
          Text(
            "A new update is available on store.\nUpdate now to enjoy the latest features, improvements, and bug fixes for a smoother experience! ",
            textAlign: TextAlign.center,
            style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
          ),
          24.height,
          AppFilledButton(
              label: context.translation.update,
              maxWidth: true,
              onPressed: () {
                if (Platform.isAndroid || Platform.isIOS) {
                  final appId = Platform.isAndroid ? 'com.hmg.atoms' : '6446684161';
                  final url = Uri.parse(Platform.isAndroid ? "market://details?id=$appId" : "https://apps.apple.com/app/id$appId");
                  launchUrl(
                    url,
                    mode: LaunchMode.externalApplication,
                  );
                }
              }),
        ],
      ).paddingAll(24),
    );
  }
}
