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.
130 lines
4.3 KiB
130 lines
4.3 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_colors.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_text_style.dart';
|
|
import 'package:hadi_hoda_flutter/core/status/base_status.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/convert_size.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/my_image.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/widgets/error/error_state.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/domain/entities/download_entity.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_event.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_state.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/ui/widgets/intro_loading_widget.dart';
|
|
|
|
class IntroPage extends StatefulWidget {
|
|
const IntroPage({super.key});
|
|
|
|
@override
|
|
State<IntroPage> createState() => _IntroPageState();
|
|
}
|
|
|
|
class _IntroPageState extends State<IntroPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
context.read<IntroBloc>().add(GetFilesEvent());
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
height: context.heightScreen,
|
|
width: context.widthScreen,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0XFF00154C),
|
|
Color(0XFF150532),
|
|
],
|
|
),
|
|
image: DecorationImage(
|
|
image: AssetImage(MyAssets.pattern),
|
|
scale: 3,
|
|
repeat: ImageRepeat.repeat,
|
|
colorFilter: ColorFilter.mode(
|
|
Colors.white.withValues(alpha: 0.2),
|
|
BlendMode.srcIn,
|
|
),
|
|
),
|
|
),
|
|
child: BlocBuilder<IntroBloc, IntroState>(
|
|
buildWhen: (previous, current) =>
|
|
previous.getFilesStatus != current.getFilesStatus,
|
|
builder: (context, state) {
|
|
if (state.getFilesStatus is BaseError) {
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: MediaQuery.viewPaddingOf(context).bottom + MySpaces.s16,
|
|
horizontal: 60,
|
|
),
|
|
child: ErrorState(
|
|
onTap: () => context.read<IntroBloc>().add(GetFilesEvent()),
|
|
),
|
|
);
|
|
} else {
|
|
return Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
_image(),
|
|
_text(context),
|
|
_loading(context),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
MyImage _image() {
|
|
return MyImage(
|
|
image: MyAssets.hadiHoda,
|
|
size: 200,
|
|
);
|
|
}
|
|
|
|
Widget _text(BuildContext context) {
|
|
return PositionedDirectional(
|
|
bottom: 130,
|
|
child: Column(
|
|
spacing: MySpaces.s6,
|
|
children: [
|
|
Text(
|
|
context.translate.please_wait,
|
|
style: Marhey.medium22.copyWith(
|
|
color: MyColors.white,
|
|
),
|
|
),
|
|
StreamBuilder<DownloadEntity>(
|
|
initialData: DownloadEntity(),
|
|
stream: context.read<IntroBloc>().loadingStream,
|
|
builder: (context, snapshot) => Text(
|
|
'${context.translate.downloading_data} (${snapshot.data?.count.toMB ?? 0.0}mb / ${snapshot.data?.total.toMB ?? 0.0}mb)',
|
|
style: Marhey.medium12.copyWith(
|
|
color: MyColors.white,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Positioned _loading(BuildContext context) {
|
|
return Positioned(
|
|
bottom: MediaQuery.viewPaddingOf(context).bottom + MySpaces.s16,
|
|
child: IntroLoadingWidget(
|
|
loadingStream: context.read<IntroBloc>().loadingStream,
|
|
),
|
|
);
|
|
}
|
|
}
|