import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:trans_lark/generated/assets.dart';
import 'package:trans_lark/global/flutter_tts_manager.dart';
import 'package:trans_lark/global/translate_manager.dart';

class TranslateTextFullScreenPage extends StatefulWidget {
  const TranslateTextFullScreenPage({super.key});

  @override
  State<TranslateTextFullScreenPage> createState() =>
      _TranslateTextFullScreenPageState();
}

class _TranslateTextFullScreenPageState
    extends State<TranslateTextFullScreenPage> {
  String showData = "";

  @override
  void initState() {
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);
    showData = Get.arguments["data"];
  }

  @override
  void dispose() {
    super.dispose();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: double.infinity,
        height: double.infinity,
        color: const Color(0xff4ECA8C),
        child: SafeArea(
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Expanded(
                child: ListView(
                  padding: const EdgeInsets.all(10),
                  children: [
                    Text(
                      showData,
                      style: const TextStyle(
                        fontSize: 48,
                        color: Colors.white,
                        height: 1.0,
                      ),
                    ),
                  ],
                ),
              ),
              GestureDetector(
                onTap: () {
                  FlutterTtsManager().translatorTtsPlay(
                    showData,
                    TranslateManager().toLanguageEntity.value.languageCode,
                  );
                },
                child: Padding(
                  padding: const EdgeInsets.only(top: 20),
                  child: ClipOval(
                    child: Container(
                      width: 32,
                      height: 32,
                      color: Colors.white,
                      child: FittedBox(
                        fit: BoxFit.none,
                        child: SvgPicture.asset(
                          Assets.svgSpeaker,
                        ),
                      ),
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
