Files
eatvio_app/lib/features/welcome/presentation/pages/welcome_screen.dart

161 lines
7.4 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:eatvio_app/app_keys.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/prefs.dart';
import 'package:eatvio_app/core/prefs_keys.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/token_storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
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) {
FlutterNativeSplash.remove();
return Scaffold(
body: Stack(
clipBehavior: Clip.none,
children: [
Positioned(
left: -20,
top: -20,
right: -20,
bottom: -20,
child: Image.asset(
'assets/images/bg_welcome.png',
fit: BoxFit.cover,
),
),
Positioned.fill(
child: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
final textScale = MediaQuery.textScalerOf(context).scale(1);
final topGap = textScale > 1.2 ? 24.0 : 80.0;
return SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 16),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight - 16,
),
child: IntrinsicHeight(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: topGap),
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(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const SizedBox(height: 16),
const Text(
'Добро пожаловать!',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w800,
height: 1,
),
),
const SizedBox(height: 20),
const Text(
'Это первая версия приложения,\nи мы активно работаем над его\nулучшением. Если вы заметите ошибку\nили у вас есть идея — пожалуйста,\nсообщите нам!\n\nВаша помощь бесценна',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.15,
),
),
const SizedBox(height: 24),
InkWell(
key: AppKeys.welcomeScreenButton,
onTap: () async {
final sharedPreferences = sl<Prefs>();
await sharedPreferences.setBool(
PrefsKeys.welcomeScreenWasShowed,
true,
);
if (await TokenStorage.haveTokenInStorage()) {
goRouter.go('/feed-screen');
} else {
goRouter.go('/auth-screen');
}
},
borderRadius: BorderRadius.circular(8),
child: Ink(
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(
8,
),
),
child: ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 52,
),
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 14,
),
child: Center(
child: Text(
'Начать пользоваться',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
height: 1,
color: Colors.white,
),
),
),
),
),
),
),
const SizedBox(height: 16),
],
),
),
),
),
],
),
),
),
);
},
),
),
),
],
),
);
}
}