import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:terepi_seged/pages/socket_test/presentation/controllers/socket_test_controller.dart';

class SocketTestView extends GetView<SocketTestController> {
  const SocketTestView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        extendBody: true,
        backgroundColor: Colors.black.withOpacity(0.05),
        appBar: AppBar(
          elevation: 0.0,
          title: const Text('Socket test (Ntrip caster)'),
          leading: IconButton(
            icon: const Icon(Icons.arrow_back_ios),
            color: Colors.white,
            onPressed: () {
              Get.back();
            },
          ),
        ),
        body: Column(children: [
          Column(
            children: [
              const Center(
                child: Text("SocketTestView"),
              ),
              TextButton(
                  onPressed: () async {
                    controller.googleLogIn();
                  },
                  child: const Text('Google log in ...')),
              TextButton(
                  onPressed: () async {
                    print("Pressed connect ....");
                    controller.connect();
                  },
                  child: const Text('Connect to NTRIP caster')),
              TextButton(
                  onPressed: () async {
                    controller.disconnect();
                  },
                  child: const Text('Disconnect'))
            ],
          ),
          Expanded(
              flex: 1,
              child: SingleChildScrollView(
                  scrollDirection: Axis.vertical,
                  child: Obx(() => Text(
                        controller.message.value,
                        style: const TextStyle(color: Colors.white),
                      ))))
        ]));
  }
}
