- Flutter app with chat and terminal screens - WebSocket integration for real-time chat - xterm integration for screen sessions - Markdown rendering with code blocks - JWT authentication Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
94 lines
2.5 KiB
Dart
94 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import 'providers/auth_provider.dart';
|
|
import 'providers/chat_provider.dart';
|
|
import 'screens/login_screen.dart';
|
|
import 'screens/chat_screen.dart';
|
|
|
|
void main() {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
runApp(const CaptainMobileApp());
|
|
}
|
|
|
|
class CaptainMobileApp extends StatelessWidget {
|
|
const CaptainMobileApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiProvider(
|
|
providers: [
|
|
ChangeNotifierProvider(create: (_) => AuthProvider()),
|
|
ChangeNotifierProxyProvider<AuthProvider, ChatProvider>(
|
|
create: (_) => ChatProvider(),
|
|
update: (_, auth, chat) => chat!..updateAuth(auth),
|
|
),
|
|
],
|
|
child: MaterialApp(
|
|
title: 'Captain Claude',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: _buildTheme(Brightness.dark),
|
|
home: const AuthWrapper(),
|
|
),
|
|
);
|
|
}
|
|
|
|
ThemeData _buildTheme(Brightness brightness) {
|
|
final baseTheme = ThemeData(
|
|
brightness: brightness,
|
|
useMaterial3: true,
|
|
colorScheme: ColorScheme.fromSeed(
|
|
seedColor: const Color(0xFFD97706), // Amber/orange accent
|
|
brightness: brightness,
|
|
),
|
|
);
|
|
|
|
return baseTheme.copyWith(
|
|
textTheme: GoogleFonts.interTextTheme(baseTheme.textTheme),
|
|
scaffoldBackgroundColor: const Color(0xFF1A1A1A),
|
|
appBarTheme: const AppBarTheme(
|
|
backgroundColor: Color(0xFF1A1A1A),
|
|
elevation: 0,
|
|
),
|
|
cardTheme: const CardTheme(
|
|
color: Color(0xFF2D2D2D),
|
|
),
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
filled: true,
|
|
fillColor: const Color(0xFF2D2D2D),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide.none,
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class AuthWrapper extends StatelessWidget {
|
|
const AuthWrapper({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer<AuthProvider>(
|
|
builder: (context, auth, _) {
|
|
if (auth.isLoading) {
|
|
return const Scaffold(
|
|
body: Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
);
|
|
}
|
|
|
|
if (auth.isAuthenticated) {
|
|
return const ChatScreen();
|
|
}
|
|
|
|
return const LoginScreen();
|
|
},
|
|
);
|
|
}
|
|
}
|