правки лаунчера

This commit is contained in:
2026-03-22 14:15:50 +04:00
parent 8ed2b692b6
commit 4edfb52396
14 changed files with 533 additions and 54 deletions
+36 -5
View File
@@ -29,17 +29,20 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
_preferencesRepository = preferencesRepository,
_session = session,
_manifest = manifest,
super(HomeScreenState(
model: HomeScreenModel.initial().copyWith(
isAuthenticated: true,
remoteBuildHash: manifest.buildHash,
super(
HomeScreenState(
model: HomeScreenModel.initial().copyWith(
isAuthenticated: true,
remoteBuildHash: manifest.buildHash,
),
),
)) {
) {
on<HomeScreenLoad>(_onHomeScreenLoad);
on<HomeScreenSyncRequested>(_onHomeScreenSyncRequested);
on<HomeScreenOutputDirRequested>(_onHomeScreenOutputDirRequested);
on<HomeScreenPauseRequested>(_onHomeScreenPauseRequested);
on<HomeScreenPlayRequested>(_onHomeScreenPlayRequested);
on<HomeScreenLogoutRequested>(_onHomeScreenLogoutRequested);
on<HomeScreenSyncStatusChanged>(_onHomeScreenSyncStatusChanged);
on<HomeScreenSyncFailed>(_onHomeScreenSyncFailed);
@@ -220,6 +223,34 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
}
}
Future<void> _onHomeScreenLogoutRequested(
HomeScreenLogoutRequested event,
Emitter<HomeScreenState> emit,
) async {
_pauseRequested = true;
await _syncSubscription?.cancel();
_syncSubscription = null;
await _preferencesRepository.clearLauncherSession();
emit(
HomeScreenState(
model: state.model.copyWith(
phase: HomeScreenPhase.idle,
isAuthenticated: false,
progress: const DownloadProgress.initial(),
statusText:
'Сессия завершена. Войдите снова.',
currentPath: null,
errorMessage: null,
localBuildHash: null,
remoteBuildHash: null,
processedFiles: 0,
totalFiles: 0,
),
),
);
}
Future<void> _onHomeScreenSyncStatusChanged(
HomeScreenSyncStatusChanged event,
Emitter<HomeScreenState> emit,
@@ -13,6 +13,8 @@ final class HomeScreenPauseRequested extends HomeScreenEvent {}
final class HomeScreenPlayRequested extends HomeScreenEvent {}
final class HomeScreenLogoutRequested extends HomeScreenEvent {}
final class HomeScreenSyncStatusChanged extends HomeScreenEvent {
final ClientSyncStatus status;
+46 -27
View File
@@ -1,8 +1,10 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:moonwell_launcher/app/home_screen/bloc/home_screen_bloc.dart';
import 'package:moonwell_launcher/app/home_screen/home_screen_content.dart';
import 'package:moonwell_launcher/app/login_screen/login_screen.dart';
import 'package:moonwell_launcher/app/theme/mw_theme.dart';
import 'package:moonwell_launcher/features/launcher/application/client_sync_use_case.dart';
import 'package:moonwell_launcher/features/launcher/data/game_installation_service.dart';
@@ -28,35 +30,50 @@ class HomeScreen extends StatelessWidget {
session: session,
manifest: manifest,
),
child: Scaffold(
body: Stack(
children: [
// Background image
Positioned.fill(
child: Image.asset('assets/background.png', fit: BoxFit.cover),
child: BlocListener<HomeScreenBloc, HomeScreenState>(
listenWhen: (previous, current) =>
previous.model.isAuthenticated && !current.model.isAuthenticated,
listener: (context, state) async {
await Navigator.of(context).pushReplacement(
PageRouteBuilder(
pageBuilder: (_, __, ___) => const LoginScreen(),
transitionsBuilder: (_, animation, __, child) {
return FadeTransition(opacity: animation, child: child);
},
transitionDuration: const Duration(milliseconds: 250),
),
// Gradient overlay
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
MWColors.abyss.withAlpha(180),
MWColors.abyss.withAlpha(220),
MWColors.abyss.withAlpha(240),
],
stops: const [0.0, 0.5, 1.0],
);
},
child: Scaffold(
body: Stack(
children: [
// Background image
Positioned.fill(
child: Image.asset('assets/background.png', fit: BoxFit.cover),
),
// Gradient overlay
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
MWColors.abyss.withAlpha(180),
MWColors.abyss.withAlpha(220),
MWColors.abyss.withAlpha(240),
],
stops: const [0.0, 0.5, 1.0],
),
),
),
),
),
// Main content
const Positioned.fill(child: HomeScreenContent()),
// Custom title bar
const Positioned(top: 0, left: 0, right: 0, child: _TitleBar()),
],
// Main content
const Positioned.fill(child: HomeScreenContent()),
// Custom title bar
const Positioned(top: 0, left: 0, right: 0, child: _TitleBar()),
],
),
),
),
);
@@ -95,7 +112,9 @@ class _TitleBar extends StatelessWidget {
),
_TitleBarButton(
icon: Icons.close,
onTap: () => SystemNavigator.pop(),
onTap: () {
unawaited(windowManager.destroy());
},
color: MWColors.error,
),
],
+34 -18
View File
@@ -25,10 +25,7 @@ class HomeScreenContent extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Left panel — News
Expanded(
flex: 3,
child: _NewsPanel(cs: cs),
),
Expanded(flex: 3, child: _NewsPanel(cs: cs)),
// Right panel — Status & Controls
SizedBox(
width: 320,
@@ -72,9 +69,9 @@ class _NewsPanel extends StatelessWidget {
),
Text(
'Новости',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: cs.onSurface,
),
style: Theme.of(
context,
).textTheme.titleLarge?.copyWith(color: cs.onSurface),
),
const SizedBox(height: 12),
// News list
@@ -83,11 +80,7 @@ class _NewsPanel extends StatelessWidget {
shaderCallback: (bounds) => LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white,
Colors.white,
Colors.white.withAlpha(0),
],
colors: [Colors.white, Colors.white, Colors.white.withAlpha(0)],
stops: const [0.0, 0.85, 1.0],
).createShader(bounds),
blendMode: BlendMode.dstIn,
@@ -183,6 +176,25 @@ class _RightPanel extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Align(
alignment: Alignment.centerRight,
child: TextButton.icon(
onPressed: () => context.read<HomeScreenBloc>().add(
HomeScreenLogoutRequested(),
),
icon: const Icon(Icons.logout_rounded, size: 16),
label: const Text('Выйти'),
style: TextButton.styleFrom(
foregroundColor: cs.onSurfaceVariant,
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
),
const SizedBox(height: 12),
const Spacer(),
// Folder selector
GestureDetector(
@@ -211,7 +223,11 @@ class _RightPanel extends StatelessWidget {
),
),
),
Icon(Icons.edit, size: 14, color: cs.onSurfaceVariant.withAlpha(120)),
Icon(
Icons.edit,
size: 14,
color: cs.onSurfaceVariant.withAlpha(120),
),
],
),
),
@@ -230,7 +246,10 @@ class _RightPanel extends StatelessWidget {
children: [
Text(
model.statusText,
style: TextStyle(color: cs.onSurface.withAlpha(180), fontSize: 13),
style: TextStyle(
color: cs.onSurface.withAlpha(180),
fontSize: 13,
),
),
if (model.currentPath != null) ...[
const SizedBox(height: 6),
@@ -302,10 +321,7 @@ class _BottomBar extends StatelessWidget {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
MWColors.abyss.withAlpha(0),
MWColors.abyss.withAlpha(230),
],
colors: [MWColors.abyss.withAlpha(0), MWColors.abyss.withAlpha(230)],
),
),
child: Column(