import 'package:flutter/material.dart'; import 'host_screen.dart'; import 'viewer_screen.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State createState() => _HomeScreenState(); } class _HomeScreenState extends State { final _serverCtrl = TextEditingController(text: 'ws://localhost:3000'); @override void dispose() { _serverCtrl.dispose(); super.dispose(); } void _goHost() { final url = _serverCtrl.text.trim(); if (url.isEmpty) return; Navigator.push( context, MaterialPageRoute(builder: (_) => HostScreen(serverUrl: url)), ); } void _goViewer() { final url = _serverCtrl.text.trim(); if (url.isEmpty) return; Navigator.push( context, MaterialPageRoute(builder: (_) => ViewerScreen(serverUrl: url)), ); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 400), child: Padding( padding: const EdgeInsets.all(32), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( 'Pulsar', style: Theme.of(context).textTheme.displayMedium?.copyWith( fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary, ), textAlign: TextAlign.center, ), const SizedBox(height: 8), Text( 'Remote Desktop', style: Theme.of(context).textTheme.titleMedium?.copyWith( color: Colors.grey, ), textAlign: TextAlign.center, ), const SizedBox(height: 48), TextField( controller: _serverCtrl, decoration: const InputDecoration( labelText: 'Signalling Server URL', border: OutlineInputBorder(), prefixIcon: Icon(Icons.dns_outlined), ), ), const SizedBox(height: 32), FilledButton.icon( onPressed: _goHost, icon: const Icon(Icons.monitor), label: const Text('Host'), style: FilledButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), ), ), const SizedBox(height: 12), OutlinedButton.icon( onPressed: _goViewer, icon: const Icon(Icons.connected_tv), label: const Text('Connect'), style: OutlinedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), ), ), ], ), ), ), ), ); } }