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.
		
		
		
		
		
			
		
			
				
					
					
						
							125 lines
						
					
					
						
							3.9 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							125 lines
						
					
					
						
							3.9 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/my_localization.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/slide_down_fade.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/core/widgets/animations/slide_up_fade.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/core/widgets/button/my_yellow_button.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/core/widgets/images/my_image.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/core/widgets/inkwell/my_inkwell.dart';
							 | 
						|
								import 'package:hadi_hoda_flutter/features/home/presentation/bloc/home_bloc.dart';
							 | 
						|
								
							 | 
						|
								class HomePage extends StatelessWidget {
							 | 
						|
								  const HomePage({super.key});
							 | 
						|
								
							 | 
						|
								  @override
							 | 
						|
								  Widget build(BuildContext context) {
							 | 
						|
								    return Scaffold(
							 | 
						|
								      body: PopScope(
							 | 
						|
								        canPop: false,
							 | 
						|
								        onPopInvokedWithResult: context
							 | 
						|
								            .read<HomeBloc>()
							 | 
						|
								            .onPopInvokedWithResult,
							 | 
						|
								        child: DecoratedBox(
							 | 
						|
								          decoration: BoxDecoration(
							 | 
						|
								            image: DecorationImage(
							 | 
						|
								              image: AssetImage(MyAssets.backgroundHome),
							 | 
						|
								              fit: BoxFit.cover,
							 | 
						|
								            ),
							 | 
						|
								          ),
							 | 
						|
								          child: SizedBox.expand(
							 | 
						|
								            child: Stack(
							 | 
						|
								              alignment: Alignment.center,
							 | 
						|
								              children: [
							 | 
						|
								                _music(context),
							 | 
						|
								                _image(context),
							 | 
						|
								                _bottomBtns(context),
							 | 
						|
								              ],
							 | 
						|
								            ),
							 | 
						|
								          ),
							 | 
						|
								        ),
							 | 
						|
								      ),
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								
							 | 
						|
								  Widget _music(BuildContext context) {
							 | 
						|
								    return PositionedDirectional(
							 | 
						|
								      top: setPlatform(android: MySpaces.s36, iOS: MySpaces.s0),
							 | 
						|
								      end: MySpaces.s16,
							 | 
						|
								      child: SafeArea(
							 | 
						|
								        child: SlideDownFade(
							 | 
						|
								          delay: Duration(milliseconds: 200),
							 | 
						|
								          child: StreamBuilder<double>(
							 | 
						|
								            initialData: 1,
							 | 
						|
								            stream: context.read<HomeBloc>().volumeStream,
							 | 
						|
								            builder: (context, snapshot) => MyInkwell(
							 | 
						|
								              onTap: () => context.read<HomeBloc>().changeMute(),
							 | 
						|
								              child: MyImage(
							 | 
						|
								                image: snapshot.data == 0 ? MyAssets.musicOff : MyAssets.musicOn,
							 | 
						|
								              ),
							 | 
						|
								            ),
							 | 
						|
								          ),
							 | 
						|
								        ),
							 | 
						|
								      ),
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								  Positioned _image(BuildContext context) {
							 | 
						|
								    return Positioned(
							 | 
						|
								      top: setSize(context: context, mobile: 0.1.h, tablet: 0.15.h),
							 | 
						|
								      child: Stack(
							 | 
						|
								        children: [
							 | 
						|
								          MyImage(
							 | 
						|
								            image: MyAssets.hadiHoda,
							 | 
						|
								          ),
							 | 
						|
								          PositionedDirectional(
							 | 
						|
								            start: MySpaces.s10,
							 | 
						|
								            top: MySpaces.s40,
							 | 
						|
								            child: MyImage(
							 | 
						|
								              image: MyAssets.globe,
							 | 
						|
								            ),
							 | 
						|
								          ),
							 | 
						|
								        ],
							 | 
						|
								      ),
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								
							 | 
						|
								  Positioned _bottomBtns(BuildContext context) {
							 | 
						|
								    return Positioned(
							 | 
						|
								      bottom: setPlatform(android: MySpaces.s40, iOS: MySpaces.s0),
							 | 
						|
								      left: MySpaces.s16,
							 | 
						|
								      right: MySpaces.s16,
							 | 
						|
								      child: SafeArea(
							 | 
						|
								        child: SlideUpFade(
							 | 
						|
								          delay: Duration(milliseconds: 200),
							 | 
						|
								          child: Row(
							 | 
						|
								            crossAxisAlignment: CrossAxisAlignment.end,
							 | 
						|
								            mainAxisAlignment: MainAxisAlignment.spaceBetween,
							 | 
						|
								            children: [
							 | 
						|
								              MyInkwell(
							 | 
						|
								                onTap: () => context.read<HomeBloc>().goToLanguagePage(context),
							 | 
						|
								                child: MyImage(
							 | 
						|
								                  image: MyAssets.language,
							 | 
						|
								                ),
							 | 
						|
								              ),
							 | 
						|
								              MyYellowButton(
							 | 
						|
								                onTap: () => context.read<HomeBloc>().goToLevelPage(context),
							 | 
						|
								                title: context.translate.start,
							 | 
						|
								              ),
							 | 
						|
								              MyInkwell(
							 | 
						|
								                onTap: () => context.read<HomeBloc>().showAboutUs(context),
							 | 
						|
								                child: MyImage(
							 | 
						|
								                  image: MyAssets.theme,
							 | 
						|
								                ),
							 | 
						|
								              ),
							 | 
						|
								            ],
							 | 
						|
								          ),
							 | 
						|
								        ),
							 | 
						|
								      ),
							 | 
						|
								    );
							 | 
						|
								  }
							 | 
						|
								}
							 |