import 'dart:io' show Platform;

import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class UpdatePage extends StatelessWidget {
  final String? message;
  final String? androidLink;
  final String? iosLink;

  const UpdatePage({Key? key, this.message, this.androidLink, this.iosLink}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: AppScaffold(
        isShowAppBar: false,
        backgroundColor: Colors.white,
        body: SingleChildScrollView(
          physics: BouncingScrollPhysics(),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(
                'assets/images/update_rocket_image.png',
                width: double.maxFinite,
                fit: BoxFit.fill,
              ),
              Image.asset('assets/images/HMG_logo.png'),
              SizedBox(
                height: 8,
              ),
              AppText(
                TranslationBase.of(context).updateTheApp.toUpperCase(),
                fontSize: 17,
                fontWeight: FontWeight.w600,
              ),
              SizedBox(
                height: 12,
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: AppText(
                  message ?? "Update the app",
                  fontSize: 12,
                ),
              )
            ],
          ),
        ),
        bottomSheet: Container(
          height: 80,
          child: Container(
            // padding: const EdgeInsets.all(8.0),
            margin: EdgeInsets.all(15),
            child: AppButton(
              color: Colors.red[800]!,
              onPressed: () {
                if (Platform.isIOS)
                  launchUrl(Uri.parse(iosLink!));
                else
                  launchUrl(Uri.parse(androidLink!));
              },
              title: TranslationBase.of(context).updateNow.toUpperCase(),
            ),
          ),
        ),
      ),
    );
  }
}
