Browse Source

fix some bug

fix_bug
mohsen zamani 2 years ago
parent
commit
7d28218d39
  1. 29
      lib/core/language/language_cubit.dart
  2. 6
      lib/core/select_language/cubit/select_language_cubit.dart
  3. 2
      lib/core/select_language/screen/select_language_screen.dart
  4. 22
      lib/core/utils/app_utils.dart
  5. 23
      lib/core/widgets/more_options_widget.dart
  6. 6
      lib/features/about_us/about_us_screen.dart
  7. 107
      lib/features/main/main_screen.dart
  8. 358
      lib/features/posts/screen/posts_screen.dart
  9. 10
      lib/features/single_post/screen/single_post_screen.dart
  10. 6
      lib/features/single_post/widget/add_comment_widget.dart
  11. 108
      lib/main.dart

29
lib/core/language/language_cubit.dart

@ -13,9 +13,13 @@ enum LanguageState {
} }
enum CurrentLanguage { enum CurrentLanguage {
en,
fa,
ar,
en('en'),
fa('fa'),
ar('ar');
final String value;
const CurrentLanguage(this.value);
} }
class LanguageCubit extends Cubit<BaseCubitType<LanguageState>> { class LanguageCubit extends Cubit<BaseCubitType<LanguageState>> {
@ -28,7 +32,7 @@ class LanguageCubit extends Cubit<BaseCubitType<LanguageState>> {
Future<void> _initial() async { Future<void> _initial() async {
String? language = _repository.getCurrentLanguage(); String? language = _repository.getCurrentLanguage();
if (language == null || language == '') { if (language == null || language == '') {
emit(BaseCubitType(eventName: LanguageState.notSet));
emit(BaseCubitType(eventName: LanguageState.notSet, data: CurrentLanguage.en));
return; return;
} }
switch (language) { switch (language) {
@ -55,7 +59,20 @@ class LanguageCubit extends Cubit<BaseCubitType<LanguageState>> {
return language; return language;
} }
Future<void> changeLanguage() async {
emit(BaseCubitType(eventName: LanguageState.loaded));
Future<void> changeLanguage(String language) async {
switch (language) {
case 'fa':
await Translator.setNewLanguage(Languages.fa);
emit(BaseCubitType(eventName: LanguageState.loaded, data: CurrentLanguage.fa));
return;
case 'en':
await Translator.setNewLanguage(Languages.en);
emit(BaseCubitType(eventName: LanguageState.loaded, data: CurrentLanguage.en));
return;
case 'ar':
await Translator.setNewLanguage(Languages.ar);
emit(BaseCubitType(eventName: LanguageState.loaded, data: CurrentLanguage.ar));
return;
}
} }
} }

6
lib/core/select_language/cubit/select_language_cubit.dart

@ -14,15 +14,15 @@ class SelectLanguageCubit extends Cubit<BaseCubitType<SelectLanguageState>> {
switch (language) { switch (language) {
case 'fa': case 'fa':
await Translator.setNewLanguage(Languages.fa); await Translator.setNewLanguage(Languages.fa);
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: CurrentLanguage.fa));
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: language));
return; return;
case 'en': case 'en':
await Translator.setNewLanguage(Languages.en); await Translator.setNewLanguage(Languages.en);
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: CurrentLanguage.en));
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: language));
return; return;
case 'ar': case 'ar':
await Translator.setNewLanguage(Languages.ar); await Translator.setNewLanguage(Languages.ar);
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: CurrentLanguage.ar));
emit(BaseCubitType(eventName: SelectLanguageState.loaded, data: language));
return; return;
} }
} }

2
lib/core/select_language/screen/select_language_screen.dart

@ -35,7 +35,7 @@ class _SelectLanguageScreenState extends State<SelectLanguageScreen> {
break; break;
case SelectLanguageState.loaded: case SelectLanguageState.loaded:
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
BlocProvider.of<LanguageCubit>(context).changeLanguage();
BlocProvider.of<LanguageCubit>(context).changeLanguage(state.data);
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(

22
lib/core/utils/app_utils.dart

@ -61,7 +61,27 @@ class Utils {
return '${jalali.year}/${jalali.month}/${jalali.day}'; return '${jalali.year}/${jalali.month}/${jalali.day}';
} }
ThemeData getAppTheme(BuildContext context) {
ThemeData getAppTheme(BuildContext context, String language) {
switch (language) {
case 'fa':
return ThemeData(
fontFamily: 'Vazir',
scaffoldBackgroundColor: const Color(0xffE7E7F5),
useMaterial3: true,
);
case 'en':
return ThemeData(
fontFamily: 'Cairo',
scaffoldBackgroundColor: const Color(0xffE7E7F5),
useMaterial3: true,
);
case 'ar':
return ThemeData(
fontFamily: 'Vazir',
scaffoldBackgroundColor: const Color(0xffE7E7F5),
useMaterial3: true,
);
}
return ThemeData( return ThemeData(
fontFamily: 'Vazir', fontFamily: 'Vazir',
scaffoldBackgroundColor: const Color(0xffE7E7F5), scaffoldBackgroundColor: const Color(0xffE7E7F5),

23
lib/core/widgets/more_options_widget.dart

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class MoreOptionsWidget extends StatelessWidget {
final String title;
final Function() onTap;
const MoreOptionsWidget({super.key, required this.title, required this.onTap});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Text(
title,
style: const TextStyle(
color: Color(0xff222D4E),
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
);
}
}

6
lib/features/about_us/about_us_screen.dart

@ -5,6 +5,7 @@ import 'package:sonnat/core/extensions/context_extension.dart';
import 'package:sonnat/core/extensions/string_extension.dart'; import 'package:sonnat/core/extensions/string_extension.dart';
import 'package:sonnat/core/language/translator.dart'; import 'package:sonnat/core/language/translator.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/utils/initializer.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class AboutUsScreen extends StatefulWidget { class AboutUsScreen extends StatefulWidget {
@ -49,8 +50,9 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
}, },
child: SvgPicture.asset(
'ic_back'.svgPath,
child: RotatedBox(
quarterTurns: Initializer.instance.getTextDirection() == TextDirection.ltr ? 90 : 0,
child: SvgPicture.asset('ic_back'.svgPath),
), ),
), ),
), ),

107
lib/features/main/main_screen.dart

@ -4,7 +4,11 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:sonnat/core/extensions/context_extension.dart'; import 'package:sonnat/core/extensions/context_extension.dart';
import 'package:sonnat/core/extensions/string_extension.dart'; import 'package:sonnat/core/extensions/string_extension.dart';
import 'package:sonnat/core/language/translator.dart'; import 'package:sonnat/core/language/translator.dart';
import 'package:sonnat/core/select_language/cubit/select_language_cubit.dart';
import 'package:sonnat/core/select_language/screen/select_language_screen.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/widgets/more_options_widget.dart';
import 'package:sonnat/features/about_us/about_us_screen.dart';
import 'package:sonnat/features/main/widget/main_item_widget.dart'; import 'package:sonnat/features/main/widget/main_item_widget.dart';
import 'package:sonnat/features/posts/cubit/posts_cubit.dart'; import 'package:sonnat/features/posts/cubit/posts_cubit.dart';
import 'package:sonnat/features/posts/screen/posts_screen.dart'; import 'package:sonnat/features/posts/screen/posts_screen.dart';
@ -41,16 +45,31 @@ class _MainScreenState extends State<MainScreen> {
body: SafeArea( body: SafeArea(
child: Column( child: Column(
children: [ children: [
Container(
margin: EdgeInsets.only(
left: context.width * 86 / AppConstants.instance.appWidth,
right: context.width * 86 / AppConstants.instance.appWidth,
),
child: Image.asset(
'ic_main_header'.pngPath,
width: context.width * 200 / AppConstants.instance.appWidth,
height: context.height * 200 / AppConstants.instance.appHeight,
),
Stack(
children: [
Container(
margin: EdgeInsets.only(
left: context.width * 86 / AppConstants.instance.appWidth,
right: context.width * 86 / AppConstants.instance.appWidth,
),
child: Image.asset(
'ic_main_header'.pngPath,
width: context.width * 200 / AppConstants.instance.appWidth,
height: context.height * 200 / AppConstants.instance.appHeight,
),
),
PositionedDirectional(
end: context.width * 35 / AppConstants.instance.appWidth,
top: 16,
child: Align(
alignment: AlignmentDirectional.centerStart,
child: GestureDetector(
onTap: _showOptions,
child: SvgPicture.asset('ic_more'.svgPath),
),
),
),
],
), ),
Text( Text(
Translator.translate('main_header_text'), Translator.translate('main_header_text'),
@ -169,4 +188,72 @@ class _MainScreenState extends State<MainScreen> {
}, },
)); ));
} }
void _showOptions() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return Container(
height: 120,
width: context.width,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white, width: 0.2),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
padding: const EdgeInsets.only(
top: 16,
left: 4,
right: 4,
),
child: Column(
children: [
MoreOptionsWidget(
title: Translator.translate('about_us'),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return const AboutUsScreen();
},
),
);
},
),
const SizedBox(height: 8),
Container(
width: context.width,
height: 1,
color: const Color(0xffD3D8E9),
),
const SizedBox(height: 8),
MoreOptionsWidget(
title: Translator.translate('select_language'),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return BlocProvider(
child: const SelectLanguageScreen(),
create: (context) => SelectLanguageCubit(),
);
},
),
);
},
),
],
),
);
},
);
}
} }

358
lib/features/posts/screen/posts_screen.dart

@ -8,7 +8,9 @@ import 'package:sonnat/core/select_language/cubit/select_language_cubit.dart';
import 'package:sonnat/core/select_language/screen/select_language_screen.dart'; import 'package:sonnat/core/select_language/screen/select_language_screen.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/utils/base_cubit_type.dart'; import 'package:sonnat/core/utils/base_cubit_type.dart';
import 'package:sonnat/core/utils/initializer.dart';
import 'package:sonnat/core/widgets/loading_list_widget.dart'; import 'package:sonnat/core/widgets/loading_list_widget.dart';
import 'package:sonnat/core/widgets/more_options_widget.dart';
import 'package:sonnat/features/about_us/about_us_screen.dart'; import 'package:sonnat/features/about_us/about_us_screen.dart';
import 'package:sonnat/features/posts/cubit/posts_cubit.dart'; import 'package:sonnat/features/posts/cubit/posts_cubit.dart';
import 'package:sonnat/features/posts/widgets/filter_item_widget.dart'; import 'package:sonnat/features/posts/widgets/filter_item_widget.dart';
@ -92,179 +94,205 @@ class _PostsScreenState extends State<PostsScreen> {
_loading = true; _loading = true;
break; break;
} }
return Column(
children: [
SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
Padding(
padding: EdgeInsets.symmetric(horizontal: context.width * 26 / AppConstants.instance.appWidth),
child: _searchMode
? Row(
children: [
Expanded(
child: SearchWidget(
search: (query) {
_cubit.search(query: query);
},
),
),
SizedBox(width: context.width * 12 / AppConstants.instance.appWidth),
GestureDetector(
onTap: () {
_cubit.clearSearch();
setState(() {
_searchMode = !_searchMode;
});
},
child: SvgPicture.asset(
'ic_back'.svgPath,
),
),
],
)
: Stack(
children: [
Align(
alignment: AlignmentDirectional.centerStart,
child: GestureDetector(
onTap: _showOptions,
child: SvgPicture.asset(
'ic_more'.svgPath,
return CustomScrollView(
controller: _controller,
slivers: [
SliverAppBar(
floating: true,
elevation: 0,
backgroundColor: const Color(0xffE7E7F5),
automaticallyImplyLeading: false,
forceElevated: false,
shadowColor: Colors.transparent,
bottom: PreferredSize(
preferredSize: const Size.fromHeight(95),
child: Column(
children: [
SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
Padding(
padding:
EdgeInsets.symmetric(horizontal: context.width * 26 / AppConstants.instance.appWidth),
child: _searchMode
? Row(
children: [
Expanded(
child: SearchWidget(
search: (query) {
_cubit.search(query: query);
},
),
),
SizedBox(width: context.width * 12 / AppConstants.instance.appWidth),
GestureDetector(
onTap: () {
_cubit.clearSearch();
setState(() {
_searchMode = !_searchMode;
});
},
child: SvgPicture.asset(
'ic_back'.svgPath,
),
),
],
)
: Stack(
children: [
Align(
alignment: AlignmentDirectional.centerStart,
child: GestureDetector(
onTap: _showOptions,
child: SvgPicture.asset(
'ic_more'.svgPath,
),
),
),
PositionedDirectional(
start: context.width * 44 / AppConstants.instance.appWidth,
child: GestureDetector(
onTap: () {
setState(() {
_searchMode = !_searchMode;
});
},
child: SvgPicture.asset('ic_rounded_search'.svgPath),
),
),
Align(
alignment: AlignmentDirectional.center,
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
widget.title,
style: const TextStyle(
color: Color(0xff404966),
fontSize: 22,
),
),
),
),
Align(
alignment: AlignmentDirectional.centerEnd,
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: RotatedBox(
quarterTurns:
Initializer.instance.getTextDirection() == TextDirection.ltr ? 90 : 0,
child: SvgPicture.asset('ic_back'.svgPath),
),
),
),
],
), ),
),
),
PositionedDirectional(
start: context.width * 44 / AppConstants.instance.appWidth,
child: GestureDetector(
onTap: () {
setState(() {
_searchMode = !_searchMode;
});
},
child: SvgPicture.asset('ic_rounded_search'.svgPath),
),
),
if (_searchMode)
Padding(
padding: EdgeInsets.only(
top: context.height * 17 / AppConstants.instance.appHeight,
left: context.width * 26 / AppConstants.instance.appWidth,
right: context.width * 26 / AppConstants.instance.appWidth,
), ),
Align(
alignment: AlignmentDirectional.center,
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
widget.title,
child: Row(
children: [
SvgPicture.asset(
'ic_search'.svgPath,
colorFilter: const ColorFilter.mode(
Color(0xff26237A),
BlendMode.srcIn,
),
),
const SizedBox(width: 8),
Text(
'${Translator.translate('search')}:',
style: const TextStyle( style: const TextStyle(
color: Color(0xff404966),
fontSize: 22,
color: Color(0xff26237A),
fontSize: 16,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
_cubit.query,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Color(0xff26237A),
fontSize: 16,
),
), ),
), ),
),
const Spacer(),
Text(
_loading
? 'در حال جستجو'
: _cubit.query.isEmpty
? ''
: _cubit.searchedList.isEmpty
? 'موردی یافت نشد'
: '${_cubit.searchedList.length} مورد یافت شد',
style: const TextStyle(
color: Color(0xff636E88),
fontSize: 12,
),
)
],
), ),
Align(
alignment: AlignmentDirectional.centerEnd,
child: GestureDetector(
),
SizedBox(height: context.height * 35 / AppConstants.instance.appHeight),
SizedBox(
height: context.height * 31 / AppConstants.instance.appHeight,
child: ListView.builder(
padding:
EdgeInsetsDirectional.only(start: context.width * 26 / AppConstants.instance.appWidth),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () { onTap: () {
Navigator.pop(context);
_cubit.changeFilter(index);
}, },
child: SvgPicture.asset(
'ic_back'.svgPath,
child: FilterItemWidget(
title: _filterList[index].title,
selected: index == _selectedFilterIndex,
), ),
),
),
],
),
),
if (_searchMode)
Padding(
padding: EdgeInsets.only(
top: context.height * 17 / AppConstants.instance.appHeight,
left: context.width * 26 / AppConstants.instance.appWidth,
right: context.width * 26 / AppConstants.instance.appWidth,
),
child: Row(
children: [
SvgPicture.asset(
'ic_search'.svgPath,
colorFilter: const ColorFilter.mode(
Color(0xff26237A),
BlendMode.srcIn,
),
),
const SizedBox(width: 8),
Text(
'${Translator.translate('search')}:',
style: const TextStyle(
color: Color(0xff26237A),
fontSize: 16,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
_cubit.query,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Color(0xff26237A),
fontSize: 16,
),
);
},
itemCount: _filterList.length,
scrollDirection: Axis.horizontal,
), ),
), ),
const Spacer(),
Text(
_loading
? 'در حال جستجو'
: _cubit.query.isEmpty
? ''
: _cubit.searchedList.isEmpty
? 'موردی یافت نشد'
: '${_cubit.searchedList.length} مورد یافت شد',
style: const TextStyle(
color: Color(0xff636E88),
fontSize: 12,
),
)
SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
], ],
), ),
), ),
SizedBox(height: context.height * 35 / AppConstants.instance.appHeight),
SizedBox(
height: context.height * 31 / AppConstants.instance.appHeight,
child: ListView.builder(
padding: EdgeInsetsDirectional.only(start: context.width * 26 / AppConstants.instance.appWidth),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
_cubit.changeFilter(index);
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (_loading) {
return const Expanded(child: LoadingListWidget());
}
return ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (_searchMode) {
return GestureDetector(
onTap: () => _clickOnPost(_cubit.searchedList[index]),
child: PostItemWidget(post: _cubit.searchedList[index]),
);
}
return GestureDetector(
onTap: () => _clickOnPost(_cubit.postList[index]),
child: PostItemWidget(post: _cubit.postList[index]),
);
}, },
child: FilterItemWidget(
title: _filterList[index].title,
selected: index == _selectedFilterIndex,
),
itemCount: _searchMode ? _cubit.searchedList.length : _cubit.postList.length,
); );
}, },
itemCount: _filterList.length,
scrollDirection: Axis.horizontal,
childCount: 1,
), ),
), ),
SizedBox(height: context.height * 26 / AppConstants.instance.appHeight),
if (_loading)
const Expanded(child: LoadingListWidget())
else
Expanded(
child: ListView.builder(
controller: _controller,
itemBuilder: (context, index) {
if (_searchMode) {
return GestureDetector(
onTap: () => _clickOnPost(_cubit.searchedList[index]),
child: PostItemWidget(post: _cubit.searchedList[index]),
);
}
return GestureDetector(
onTap: () => _clickOnPost(_cubit.postList[index]),
child: PostItemWidget(post: _cubit.postList[index]),
);
},
itemCount: _searchMode ? _cubit.searchedList.length : _cubit.postList.length,
),
)
], ],
); );
}, },
@ -362,25 +390,3 @@ class FilterItem {
const FilterItem({required this.selected, required this.title}); const FilterItem({required this.selected, required this.title});
} }
class MoreOptionsWidget extends StatelessWidget {
final String title;
final Function() onTap;
const MoreOptionsWidget({super.key, required this.title, required this.onTap});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Text(
title,
style: const TextStyle(
color: Color(0xff222D4E),
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
);
}
}

10
lib/features/single_post/screen/single_post_screen.dart

@ -101,16 +101,6 @@ class _SinglePostScreenState extends State<SinglePostScreen> {
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: SvgPicture.asset('ic_share'.svgPath), child: SvgPicture.asset('ic_share'.svgPath),
), ),
const SizedBox(width: 16),
Padding(
padding: const EdgeInsets.all(8),
child: SvgPicture.asset('ic_bookmark'.svgPath),
),
const SizedBox(width: 16),
Padding(
padding: const EdgeInsets.all(8),
child: SvgPicture.asset('ic_like'.svgPath),
),
const Spacer(), const Spacer(),
Text( Text(
_cubit.commentList.length.toString(), _cubit.commentList.length.toString(),

6
lib/features/single_post/widget/add_comment_widget.dart

@ -4,6 +4,7 @@ import 'package:sonnat/core/extensions/context_extension.dart';
import 'package:sonnat/core/extensions/string_extension.dart'; import 'package:sonnat/core/extensions/string_extension.dart';
import 'package:sonnat/core/language/translator.dart'; import 'package:sonnat/core/language/translator.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/utils/initializer.dart';
class AddCommentWidget extends StatefulWidget { class AddCommentWidget extends StatefulWidget {
final Function(String comment) sendComment; final Function(String comment) sendComment;
@ -57,7 +58,10 @@ class _AddCommentWidgetState extends State<AddCommentWidget> {
}, },
child: Padding( child: Padding(
padding: const EdgeInsetsDirectional.only(end: 18, bottom: 8, top: 8), padding: const EdgeInsetsDirectional.only(end: 18, bottom: 8, top: 8),
child: SvgPicture.asset('ic_send'.svgPath),
child: RotatedBox(
child: SvgPicture.asset('ic_send'.svgPath),
quarterTurns: Initializer.instance.getTextDirection() == TextDirection.ltr ? 90 : 0,
),
), ),
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(

108
lib/main.dart

@ -45,61 +45,67 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<LanguageCubit, BaseCubitType<LanguageState>>( return BlocBuilder<LanguageCubit, BaseCubitType<LanguageState>>(
builder: (context, state) { builder: (context, state) {
return MaterialApp(
builder: (context, child) {
Widget error = const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'خطا در نمابش اطلاعات',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 18,
),
textAlign: TextAlign.center,
),
],
),
);
if (child is Scaffold || child is Navigator) {
error = Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
error,
const Icon(
Icons.error_outline_rounded,
size: 130,
color: Colors.red,
if (state.eventName == LanguageState.notSet || state.eventName == LanguageState.loaded) {
Initializer.instance.setAppDirection(
state.data == CurrentLanguage.fa || state.data == CurrentLanguage.ar ? 'rtl' : 'ltr',
);
return MaterialApp(
builder: (context, child) {
Widget error = const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'خطا در نمابش اطلاعات',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 18,
), ),
],
),
textAlign: TextAlign.center,
),
],
), ),
); );
}
ErrorWidget.builder = (errorDetails) => error;
return ScrollConfiguration(
behavior: DisableScrollEffect().copyWith(scrollbars: false),
child: Directionality(
textDirection: Initializer.instance.getTextDirection(),
child: child!,
),
);
},
theme: Utils.instance.getAppTheme(context),
debugShowCheckedModeBanner: false,
supportedLocales: Translator.supportedLocales(),
initialRoute: '/',
routes: {
'/': (context) => BlocProvider(
create: (context) => SplashCubit(),
child: const SplashScreen(),
if (child is Scaffold || child is Navigator) {
error = Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
error,
const Icon(
Icons.error_outline_rounded,
size: 130,
color: Colors.red,
),
],
),
),
);
}
ErrorWidget.builder = (errorDetails) => error;
return ScrollConfiguration(
behavior: DisableScrollEffect().copyWith(scrollbars: false),
child: Directionality(
textDirection: Initializer.instance.getTextDirection(),
child: child!,
), ),
},
);
);
},
theme: Utils.instance.getAppTheme(context, state.data.value),
debugShowCheckedModeBanner: false,
supportedLocales: Translator.supportedLocales(),
initialRoute: '/',
routes: {
'/': (context) => BlocProvider(
create: (context) => SplashCubit(),
child: const SplashScreen(),
),
},
);
}
return const SizedBox();
}, },
); );
} }

Loading…
Cancel
Save