import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:xiao_pet_tracker/xiao_connector/cubit/xiao_connector_cubit.dart';

class ConnectedView extends StatelessWidget {
  const ConnectedView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Xiao Connector'),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text(
                '''
        You are connected to the Xiao Sense.
        Now you can open the live feed.''',
                textAlign: TextAlign.center,
              ),
              const SizedBox(
                height: 48,
              ),
              ElevatedButton(
                onPressed: () {
                  context.read<XiaoConnectorCubit>().startCapturing();
                },
                child: const Text('Open Live Feed'),
              ),
              const SizedBox(
                height: 48,
              ),
              ElevatedButton(
                onPressed: () {
                  context.read<XiaoConnectorCubit>().disconnectDevice();
                },
                child: const Text('Disconnect'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
