Initial commit: JustAMessenger v0.1.0

Серверная часть (Go):
- WebSocket сервер с бинарным протоколом
- XChaCha20-Poly1305 шифрование
- zstd сжатие с дедупликацией (64KB чанки)
- SQLite хранилище (WAL режим)
- Управление гильдиями, каналами, ролями
- Федерация между серверами (ed25519)
- REST API + WebSocket endpoints

Клиентская часть (Flutter):
- Material Design 3 тёмная тема (Discord-like)
- WebSocket соединение с сервером
- Экраны: сплэш, логин, домашний, гильдии, чат
- Модели: пользователи, гильдии, каналы, сообщения, роли
- Сервисы: соединение, API, криптография, тема
- Виджеты: иконки гильдий, сообщения, ввод чата
- Web сборка (PWA)

Документация:
- AGENTS.md — контекст для ИИ ассистентов
- docs/protocol.md — спецификация протокола
This commit is contained in:
SashegDev
2026-06-06 22:39:14 +00:00
commit 096c4d0a2d
40 changed files with 5054 additions and 0 deletions
+237
View File
@@ -0,0 +1,237 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/connection_service.dart';
import '../services/api_service.dart';
import '../services/theme_service.dart';
import '../models/message.dart';
import '../models/channel.dart';
import '../models/guild.dart';
import '../widgets/message_bubble.dart';
import '../widgets/chat_input.dart';
class ChatScreen extends StatefulWidget {
const ChatScreen({super.key});
@override
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
final TextEditingController _messageController = TextEditingController();
final ScrollController _scrollController = ScrollController();
final List<Message> _messages = [];
StreamSubscription? _sub;
bool _loading = true;
bool _atBottom = true;
late Channel _channel;
late Guild _guild;
@override
void didChangeDependencies() {
super.didChangeDependencies();
final args = ModalRoute.of(context)?.settings.arguments as Map?;
if (args != null) {
_channel = args['channel'] as Channel;
_guild = args['guild'] as Guild;
}
}
@override
void initState() {
super.initState();
_scrollController.addListener(_onScroll);
WidgetsBinding.instance.addPostFrameCallback((_) => _loadMessages());
_sub = context.read<ConnectionService>().messageStream.listen(_onMessage);
}
@override
void dispose() {
_sub?.cancel();
_messageController.dispose();
_scrollController.dispose();
super.dispose();
}
void _onScroll() {
if (_scrollController.hasClients) {
final atBottom = _scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 50;
if (atBottom != _atBottom) {
setState(() => _atBottom = atBottom);
}
}
}
Future<void> _loadMessages() async {
try {
final conn = context.read<ConnectionService>();
final api = ApiService();
api.updateFromWsUrl(conn.serverUrl);
final messages = await api.getMessages(_channel.id);
if (mounted) {
setState(() {
_messages.addAll(messages.reversed);
_loading = false;
});
_scrollToBottom();
}
} catch (_) {
if (mounted) setState(() => _loading = false);
}
}
void _scrollToBottom() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_scrollController.hasClients) {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
);
}
});
}
void _onMessage(Map<String, dynamic> data) {
final msgChannelId = data['channel_id'] as String?;
if (msgChannelId != _channel.id) return;
final msg = Message.fromJson(data);
setState(() => _messages.add(msg));
if (_atBottom) _scrollToBottom();
}
void _sendMessage(String text) {
if (text.trim().isEmpty) return;
final conn = context.read<ConnectionService>();
final content = Uint8List.fromList(utf8.encode(text));
conn.sendMessage(channelId: _channel.id, content: content);
_messageController.clear();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ThemeService.backgroundPrimary,
body: Column(
children: [
_buildHeader(),
Expanded(
child: _loading
? const Center(child: CircularProgressIndicator(strokeWidth: 2))
: _messages.isEmpty
? _buildEmptyState()
: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
itemCount: _messages.length,
itemBuilder: (context, index) {
final msg = _messages[index];
final showAuthor = index == 0 ||
_messages[index - 1].authorId != msg.authorId;
return MessageBubble(
message: msg,
showAuthor: showAuthor,
onReply: (m) => _messageController.text = '@${m.authorUsername ?? "unknown"} ',
);
},
),
),
ChatInput(
controller: _messageController,
onSendMessage: _sendMessage,
channelId: _channel.id,
),
],
),
);
}
Widget _buildHeader() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
decoration: const BoxDecoration(
color: ThemeService.surfaceSecondary,
border: Border(bottom: BorderSide(color: Color(0xFF3F4147))),
),
child: Row(
children: [
Icon(
_channel.isText ? Icons.tag : Icons.volume_up,
size: 20,
color: ThemeService.textMuted,
),
const SizedBox(width: 8),
Text(
_channel.name,
style: const TextStyle(
color: ThemeService.textPrimary,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
const Spacer(),
if (_channel.isVoice)
IconButton(
icon: const Icon(Icons.call, size: 20),
color: ThemeService.success,
onPressed: () {},
tooltip: 'Start call',
),
IconButton(
icon: const Icon(Icons.search, size: 20),
color: ThemeService.textSecondary,
onPressed: () {},
tooltip: 'Search',
),
],
),
);
}
Widget _buildEmptyState() {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
_channel.isText ? Icons.tag : Icons.volume_up,
size: 48,
color: ThemeService.textMuted.withValues(alpha: 0.5),
),
const SizedBox(height: 12),
Text(
'#${_channel.name}',
style: const TextStyle(
color: ThemeService.textPrimary,
fontSize: 20,
fontWeight: FontWeight.w700,
),
),
if (_channel.topic != null && _channel.topic!.isNotEmpty) ...[
const SizedBox(height: 4),
Text(
_channel.topic!,
style: const TextStyle(
color: ThemeService.textSecondary,
fontSize: 13,
),
),
],
const SizedBox(height: 16),
Text(
'No messages yet. Start the conversation!',
style: TextStyle(
color: ThemeService.textMuted.withValues(alpha: 0.8),
fontSize: 14,
),
),
],
),
);
}
}
+26
View File
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import '../services/theme_service.dart';
import '../models/guild.dart';
class GuildScreen extends StatelessWidget {
const GuildScreen({super.key});
@override
Widget build(BuildContext context) {
final args = ModalRoute.of(context)?.settings.arguments as Map?;
final guild = args?['guild'] as Guild?;
return Scaffold(
backgroundColor: ThemeService.backgroundPrimary,
appBar: AppBar(
title: Text(guild?.name ?? 'Guild'),
),
body: Center(
child: Text(
'Guild: ${guild?.name ?? "Unknown"}',
style: const TextStyle(color: ThemeService.textPrimary),
),
),
);
}
}
+425
View File
@@ -0,0 +1,425 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/connection_service.dart';
import '../services/api_service.dart';
import '../services/theme_service.dart';
import '../models/guild.dart';
import '../models/channel.dart';
import '../models/role.dart';
import '../widgets/guild_icon.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final ApiService _api = ApiService();
List<Guild> _guilds = [];
Guild? _selectedGuild;
bool _loading = true;
@override
void initState() {
super.initState();
_loadGuilds();
}
Future<void> _loadGuilds() async {
final conn = context.read<ConnectionService>();
if (conn.userId == null) return;
_api.updateFromWsUrl(conn.serverUrl);
try {
final guilds = await _api.getGuilds(conn.userId!);
if (mounted) {
setState(() {
_guilds = guilds;
_loading = false;
});
}
} catch (e) {
if (mounted) setState(() => _loading = false);
}
}
void _showCreateGuildDialog() {
final nameController = TextEditingController();
showDialog(
context: context,
builder: (ctx) => AlertDialog(
backgroundColor: ThemeService.surfaceSecondary,
title: const Text('Create Guild',
style: TextStyle(color: ThemeService.textPrimary)),
content: TextField(
controller: nameController,
decoration: const InputDecoration(
hintText: 'Guild name',
hintStyle: TextStyle(color: ThemeService.textMuted),
),
style: const TextStyle(color: ThemeService.textPrimary),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('Cancel'),
),
ElevatedButton(
onPressed: () async {
final conn = context.read<ConnectionService>();
if (nameController.text.isNotEmpty && conn.userId != null) {
await _api.createGuild(nameController.text, conn.userId!);
if (ctx.mounted) Navigator.pop(ctx);
_loadGuilds();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: ThemeService.primary,
),
child: const Text('Create'),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ThemeService.backgroundTertiary,
body: Row(
children: [
Container(
width: 72,
color: ThemeService.backgroundTertiary,
child: Column(
children: [
const SizedBox(height: 12),
_buildHomeButton(),
const SizedBox(height: 8),
const Divider(
color: Color(0xFF3F4147),
height: 2,
indent: 20,
endIndent: 20,
),
const SizedBox(height: 8),
Expanded(
child: _loading
? const Center(
child: CircularProgressIndicator(strokeWidth: 2))
: ListView.builder(
itemCount: _guilds.length + 1,
itemBuilder: (context, index) {
if (index == 0) return _buildAddGuildButton();
final guild = _guilds[index - 1];
return _buildGuildItem(guild);
},
),
),
_buildUserMenu(),
],
),
),
if (_selectedGuild != null)
Expanded(
child: _buildChannelList(),
)
else
const Expanded(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.chat_bubble_outline,
color: ThemeService.textMuted, size: 64),
SizedBox(height: 16),
Text(
'Select a guild',
style: TextStyle(
color: ThemeService.textMuted,
fontSize: 18,
),
),
SizedBox(height: 8),
Text(
'Choose a guild from the left or create a new one',
style: TextStyle(
color: ThemeService.textSecondary,
fontSize: 13,
),
),
],
),
),
),
],
),
);
}
Widget _buildHomeButton() {
return GestureDetector(
onTap: () => setState(() => _selectedGuild = null),
child: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: _selectedGuild == null
? ThemeService.primary
: ThemeService.surfacePrimary,
borderRadius: BorderRadius.circular(_selectedGuild == null ? 14 : 24),
),
child: const Icon(Icons.home, color: Colors.white, size: 24),
),
);
}
Widget _buildGuildItem(Guild guild) {
final selected = _selectedGuild?.id == guild.id;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: GestureDetector(
onTap: () => _loadGuildDetail(guild),
child: GuildIcon(
name: guild.name,
icon: guild.icon,
selected: selected,
size: 48,
),
),
);
}
Widget _buildAddGuildButton() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: GestureDetector(
onTap: _showCreateGuildDialog,
child: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: ThemeService.surfacePrimary,
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: ThemeService.success.withValues(alpha: 0.5),
width: 2,
),
),
child: const Icon(Icons.add, color: ThemeService.success, size: 28),
),
),
);
}
Future<void> _loadGuildDetail(Guild guild) async {
try {
final data = await _api.getGuild(guild.id);
if (mounted) {
setState(() {
guild.channels = (data['channels'] as List)
.map((c) => Channel.fromJson(c))
.toList();
guild.roles = (data['roles'] as List)
.map((r) => Role.fromJson(r))
.toList();
guild.categories = (data['categories'] as List)
.map((c) => Category.fromJson(c))
.toList();
_selectedGuild = guild;
});
}
} catch (_) {}
}
Widget _buildChannelList() {
if (_selectedGuild == null) return const SizedBox();
final guild = _selectedGuild!;
final textChannels =
guild.channels.where((c) => c.isText).toList();
final voiceChannels =
guild.channels.where((c) => c.isVoice).toList();
return Container(
color: ThemeService.surfaceSecondary,
width: 240,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Color(0xFF3F4147)),
),
),
child: Row(
children: [
Expanded(
child: Text(
guild.name,
style: const TextStyle(
color: ThemeService.textPrimary,
fontWeight: FontWeight.w700,
fontSize: 16,
),
overflow: TextOverflow.ellipsis,
),
),
const Icon(Icons.expand_more,
color: ThemeService.textSecondary, size: 20),
],
),
),
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
if (textChannels.isNotEmpty) ...[
_buildChannelSection('TEXT CHANNELS'),
...textChannels.map((c) => _buildChannelItem(c)),
],
if (voiceChannels.isNotEmpty) ...[
const SizedBox(height: 16),
_buildChannelSection('VOICE CHANNELS'),
...voiceChannels.map((c) => _buildChannelItem(c)),
],
],
),
),
],
),
);
}
Widget _buildChannelSection(String title) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Row(
children: [
const Icon(Icons.keyboard_arrow_down,
size: 12, color: ThemeService.textSecondary),
const SizedBox(width: 4),
Text(
title,
style: const TextStyle(
color: ThemeService.textSecondary,
fontSize: 11,
fontWeight: FontWeight.w700,
letterSpacing: 0.5,
),
),
],
),
);
}
Widget _buildChannelItem(Channel channel) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(4),
onTap: () {
Navigator.pushNamed(context, '/chat', arguments: {
'channel': channel,
'guild': _selectedGuild,
});
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
child: Row(
children: [
Icon(
channel.isText ? Icons.tag : Icons.volume_up,
size: 18,
color: ThemeService.textMuted,
),
const SizedBox(width: 6),
Expanded(
child: Text(
channel.name,
style: const TextStyle(
color: ThemeService.textSecondary,
fontSize: 14,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
),
),
);
}
Widget _buildUserMenu() {
final conn = context.watch<ConnectionService>();
return Container(
padding: const EdgeInsets.all(8),
color: ThemeService.backgroundSecondary,
child: Row(
children: [
Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: ThemeService.primary,
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: Text(
(conn.username ?? '?')[0].toUpperCase(),
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.w700),
),
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
conn.username ?? 'Unknown',
style: const TextStyle(
color: ThemeService.textPrimary,
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
Text(
conn.isConnected ? 'Connected' : 'Disconnected',
style: TextStyle(
color: conn.isConnected
? ThemeService.success
: ThemeService.danger,
fontSize: 11,
),
),
],
),
),
IconButton(
icon: const Icon(Icons.settings, size: 18),
color: ThemeService.textSecondary,
onPressed: () => Navigator.pushNamed(context, '/settings'),
constraints: const BoxConstraints(),
padding: const EdgeInsets.all(4),
),
],
),
);
}
}
+176
View File
@@ -0,0 +1,176 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/connection_service.dart';
import '../services/theme_service.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final _usernameController = TextEditingController();
final _serverUrlController = TextEditingController(text: 'ws://localhost:8443/ws');
bool _loading = false;
String? _error;
@override
void dispose() {
_usernameController.dispose();
_serverUrlController.dispose();
super.dispose();
}
Future<void> _connect() async {
setState(() {
_loading = true;
_error = null;
});
try {
final conn = context.read<ConnectionService>();
conn.serverUrl = _serverUrlController.text.trim();
await conn.connect();
final username = _usernameController.text.trim();
if (username.isNotEmpty) {
conn.authenticate(username: username);
}
await Future.delayed(const Duration(seconds: 1));
if (mounted) {
Navigator.pushReplacementNamed(context, '/home');
}
} catch (e) {
setState(() => _error = 'Connection failed: $e');
} finally {
if (mounted) setState(() => _loading = false);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ThemeService.backgroundPrimary,
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 72,
height: 72,
decoration: BoxDecoration(
color: ThemeService.primary,
borderRadius: BorderRadius.circular(18),
),
child: const Center(
child: Text('JAM',
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.w800)),
),
),
const SizedBox(height: 32),
const Text(
'Welcome to JustAMessenger',
style: TextStyle(
color: ThemeService.textPrimary,
fontSize: 24,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 8),
const Text(
'Connect to a server to get started',
style: TextStyle(
color: ThemeService.textSecondary,
fontSize: 14,
),
),
const SizedBox(height: 32),
TextField(
controller: _serverUrlController,
decoration: const InputDecoration(
labelText: 'Server URL',
hintText: 'ws://localhost:8443/ws',
prefixIcon: Icon(Icons.dns_outlined),
),
style: const TextStyle(color: ThemeService.textPrimary),
),
const SizedBox(height: 16),
TextField(
controller: _usernameController,
decoration: const InputDecoration(
labelText: 'Username',
hintText: 'Enter your username',
prefixIcon: Icon(Icons.person_outline),
),
style: const TextStyle(color: ThemeService.textPrimary),
textCapitalization: TextCapitalization.none,
),
if (_error != null) ...[
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: ThemeService.danger.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: ThemeService.danger.withValues(alpha: 0.3)),
),
child: Row(
children: [
const Icon(Icons.error_outline,
color: ThemeService.danger, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(_error!,
style: const TextStyle(
color: ThemeService.danger, fontSize: 13)),
),
],
),
),
],
const SizedBox(height: 24),
SizedBox(
width: double.infinity,
height: 48,
child: ElevatedButton(
onPressed: _loading ? null : _connect,
style: ElevatedButton.styleFrom(
backgroundColor: ThemeService.primary,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
),
child: _loading
? const SizedBox(
width: 22,
height: 22,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
: const Text('Connect',
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w600)),
),
),
],
),
),
),
);
}
}
+178
View File
@@ -0,0 +1,178 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/connection_service.dart';
import '../services/theme_service.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
final conn = context.watch<ConnectionService>();
return Scaffold(
backgroundColor: ThemeService.backgroundPrimary,
appBar: AppBar(
title: const Text('Settings'),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildSection('Account'),
_buildTile(
icon: Icons.person,
title: 'Username',
subtitle: conn.username ?? 'Not set',
onTap: () {},
),
_buildTile(
icon: Icons.link,
title: 'Connected to',
subtitle: conn.serverUrl,
onTap: () {},
),
_buildTile(
icon: conn.isConnected ? Icons.cloud_done : Icons.cloud_off,
title: 'Status',
subtitle: conn.isConnected ? 'Connected' : 'Disconnected',
trailing: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: conn.isConnected
? ThemeService.success
: ThemeService.danger,
shape: BoxShape.circle,
),
),
),
const SizedBox(height: 24),
_buildSection('Appearance'),
_buildTile(
icon: Icons.palette,
title: 'Theme',
subtitle: 'Dark (JAM Default)',
onTap: () {},
),
_buildTile(
icon: Icons.font_download,
title: 'Font Size',
subtitle: 'Default',
onTap: () {},
),
const SizedBox(height: 24),
_buildSection('Privacy & Security'),
_buildTile(
icon: Icons.lock,
title: 'Encryption',
subtitle: 'XChaCha20-Poly1305',
onTap: () {},
),
_buildTile(
icon: Icons.timer,
title: 'Self-destructing messages',
subtitle: 'Off',
onTap: () {},
),
_buildTile(
icon: Icons.visibility_off,
title: 'Secret Chats',
subtitle: 'End-to-end encrypted',
onTap: () {},
),
const SizedBox(height: 24),
_buildSection('Storage & Data'),
_buildTile(
icon: Icons.storage,
title: 'Cache',
subtitle: 'Clear cached data',
onTap: () {},
),
_buildTile(
icon: Icons.download,
title: 'Auto-download',
subtitle: 'Wi-Fi only',
onTap: () {},
),
const SizedBox(height: 24),
_buildSection('About'),
_buildTile(
icon: Icons.info,
title: 'Version',
subtitle: '0.1.0',
onTap: () {},
),
const SizedBox(height: 32),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () {
conn.disconnect();
Navigator.pushReplacementNamed(context, '/login');
},
icon: const Icon(Icons.logout, color: ThemeService.danger),
label: const Text(
'Disconnect',
style: TextStyle(color: ThemeService.danger),
),
style: OutlinedButton.styleFrom(
side: const BorderSide(color: ThemeService.danger),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
const SizedBox(height: 32),
],
),
);
}
Widget _buildSection(String title) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
title.toUpperCase(),
style: const TextStyle(
color: ThemeService.textMuted,
fontSize: 12,
fontWeight: FontWeight.w700,
letterSpacing: 0.5,
),
),
);
}
Widget _buildTile({
required IconData icon,
required String title,
required String subtitle,
Widget? trailing,
VoidCallback? onTap,
}) {
return ListTile(
leading: Icon(icon, color: ThemeService.textSecondary, size: 22),
title: Text(
title,
style: const TextStyle(
color: ThemeService.textPrimary,
fontSize: 15,
),
),
subtitle: Text(
subtitle,
style: const TextStyle(
color: ThemeService.textSecondary,
fontSize: 13,
),
),
trailing: trailing ?? const Icon(Icons.chevron_right,
color: ThemeService.textMuted, size: 20),
onTap: onTap,
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
);
}
}
+110
View File
@@ -0,0 +1,110 @@
import 'package:flutter/material.dart';
import '../services/theme_service.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _fadeIn;
late Animation<double> _scale;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1500),
);
_fadeIn = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
);
_scale = Tween<double>(begin: 0.8, end: 1).animate(
CurvedAnimation(parent: _controller, curve: Curves.elasticOut),
);
_controller.forward();
Future.delayed(const Duration(seconds: 2), () {
if (mounted) Navigator.pushReplacementNamed(context, '/login');
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ThemeService.backgroundPrimary,
body: Center(
child: AnimatedBuilder(
animation: _controller,
builder: (context, child) => Opacity(
opacity: _fadeIn.value,
child: Transform.scale(
scale: _scale.value,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: ThemeService.primary,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: ThemeService.primary.withValues(alpha: 0.4),
blurRadius: 30,
spreadRadius: 5,
),
],
),
child: const Center(
child: Text(
'JAM',
style: TextStyle(
color: Colors.white,
fontSize: 36,
fontWeight: FontWeight.w800,
letterSpacing: 2,
),
),
),
),
const SizedBox(height: 24),
const Text(
'JustAMessenger',
style: TextStyle(
color: ThemeService.textPrimary,
fontSize: 28,
fontWeight: FontWeight.w700,
letterSpacing: 1,
),
),
const SizedBox(height: 8),
Text(
'Lightweight · Decentralized · Secure',
style: TextStyle(
color: ThemeService.textSecondary.withValues(alpha: 0.7),
fontSize: 14,
letterSpacing: 0.5,
),
),
],
),
),
),
),
),
);
}
}