feat: update screen

This commit is contained in:
mso7nueh
2025-04-29 12:01:13 +03:00
parent b74d683e2c
commit 6b48eaf8fe
4 changed files with 149 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/websockets/ws_manager.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/features/auth/presentation/pages/auth_screen.dart';
@@ -52,18 +54,21 @@ import 'package:eatvio_app/features/settings/presentation/pages/physical_form_sc
import 'package:eatvio_app/features/settings/presentation/pages/pressure_screen.dart';
import 'package:eatvio_app/features/settings/presentation/pages/settings_screen.dart';
import 'package:eatvio_app/features/support/presentation/pages/support_screen.dart';
import 'package:eatvio_app/features/update_screen/presentation/update_screen.dart';
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
import 'package:eatvio_app/features/welcome/presentation/pages/welcome_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:version/version.dart';
class AppRouter {
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
static GoRouter appRouter = GoRouter(
initialLocation: '/welcome-screen',
initialLocation: '/update-screen',
navigatorKey: navigatorKey,
routes: [
GoRoute(
@@ -139,6 +144,23 @@ class AppRouter {
}
},
),
GoRoute(
path: '/update-screen',
name: 'updateScreen',
builder: (context, state) => const UpdateScreen(),
redirect: (context, state) async {
final versions = (await sl<Dio>().get('$baseUrl/api/app_versions')).data;
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version;
Version currentVersion = Version.parse(version);
Version latestVersion = Version.parse(versions['min_version']);
if (latestVersion > currentVersion) {
return null;
} else {
return '/welcome-screen';
}
},
),
GoRoute(
path: '/consultant-finance-screen',
name: 'consultantFinanceScreen',

View File

@@ -0,0 +1,109 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:lottie/lottie.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../../core/theme/theme_helper.dart';
class UpdateScreen extends StatelessWidget {
const UpdateScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
clipBehavior: Clip.none,
children: [
Positioned(
left: -20,
top: -20,
right: -20,
bottom: -20,
child: Lottie.asset(
'assets/splash/bg.json',
fit: BoxFit.cover,
),
),
Positioned.fill(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 40),
SvgPicture.asset('assets/images/logo_welcome.svg'),
const Spacer(),
Padding(
padding: const EdgeInsets.all(16),
child: Material(
borderRadius: BorderRadius.circular(14),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
const SizedBox(height: 20),
const Text(
'Пора обновиться! ⚡',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w800,
height: 1,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
const Text(
'Мы выпустили важное обновление с новыми функциями и исправлениями. Чтобы продолжить пользоваться приложением без сбоев, обновите его прямо сейчас.',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 52),
child: InkWell(
onTap: () async {
final Uri url = Platform.isAndroid
? Uri.parse('https://www.rustore.ru/catalog/app/com.eatvioapp.app')
: Uri.parse('https://apps.apple.com/app/idYOUR_APP_ID');
await launchUrl(url);
},
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(20),
),
child: const Center(
child: Text(
'Обновить',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
height: 1,
color: Colors.white,
),
),
),
),
),
),
const SizedBox(height: 20),
],
),
),
),
),
],
),
),
],
),
);
}
}

View File

@@ -6,9 +6,22 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../../../core/theme/theme_helper.dart';
class WelcomeScreen extends StatelessWidget {
class WelcomeScreen extends StatefulWidget {
const WelcomeScreen({super.key});
@override
State<WelcomeScreen> createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
late final GoRouter goRouter;
@override
void initState() {
super.initState();
goRouter = GoRouter.of(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -68,7 +81,7 @@ class WelcomeScreen extends StatelessWidget {
onTap: () async {
final sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.setBool('welcomeScreenWasShowed', true);
GoRouter.of(context).go('/my-profile-screen');
goRouter.go('/my-profile-screen');
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -68,6 +68,8 @@ dependencies:
path: ^1.9.0
collection: ^1.19.0
shared_preferences: ^2.5.3
version: ^3.0.2
package_info_plus: ^8.3.0
dependency_overrides:
intl: ^0.19.0