You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

144 lines
3.8 KiB

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
import 'package:hadi_hoda_flutter/core/utils/screen_size.dart';
import 'package:hadi_hoda_flutter/core/utils/set_platform_size.dart';
import 'package:hadi_hoda_flutter/core/widgets/animations/rotation_anim.dart';
import 'package:hadi_hoda_flutter/core/widgets/images/my_image.dart';
import 'package:hadi_hoda_flutter/features/splash/presentation/bloc/splash_bloc.dart';
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> with SingleTickerProviderStateMixin{
late AnimationController _controller;
late Animation<double> _translateY;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 900),
);
_translateY = Tween<double>(begin: 40, end: 0).animate(
CurvedAnimation(
parent: _controller,
curve: Curves.easeOutBack, // gives that slight bounce
),
);
_controller.forward();
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<SplashBloc>().goToHomePage(context);
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: context.heightScreen,
width: context.widthScreen,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0XFF00154C),
Color(0XFF150532),
],
),
image: DecorationImage(
image: const AssetImage(MyAssets.pattern),
scale: 3,
repeat: ImageRepeat.repeat,
colorFilter: ColorFilter.mode(
Colors.white.withValues(alpha: 0.22),
BlendMode.srcIn,
),
),
),
child: Center(
child: AnimatedBuilder(
animation: _translateY,
builder: (context, child) {
return Transform.translate(
offset: Offset(0, _translateY.value),
child: child,
);
},
child: Image.asset(
'assets/images/splash_logo.png',
height: 245,
width: 245,
),
),
),
// Stack(
// alignment: Alignment.center,
// children: [
// Positioned.fill(child: _image()),
// _loading(context),
// ],
// ),
),
);
}
Widget _image() {
return const Stack(
alignment: Alignment.center,
children: [
MyImage(
image: MyAssets.hadiHoda,
),
Positioned(
right: 0,
left: 0,
top: 0,
bottom: 0,
child: Center(
child: Padding(
padding: EdgeInsets.only(bottom: 140, right: 235),
child: Opacity(
opacity: .94,
child: MyImage(
image: MyAssets.globe,
),
),
),
),
),
],
);
}
Positioned _loading(BuildContext context) {
return Positioned(
bottom: MySpaces.s40,
right: 0,
left: 0,
child: RotationAnim(
child: MyImage(
image: MyAssets.loading,
size: setSize(context: context, mobile: 70, tablet: 100),
),
)
);
}
}