feat(app): SafeArea insets refactoring

This commit is contained in:
2024-06-03 16:00:48 +03:00
parent d3a041d951
commit 795dc48629
26 changed files with 121 additions and 142 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,4 +1,3 @@
export 'package:connectivity_plus/connectivity_plus.dart';
export 'package:flutter_bloc/flutter_bloc.dart';
export 'package:eatvio_app/core/constants/constants.dart';
export 'package:eatvio_app/core/errors/exceptions.dart';

View File

@@ -41,15 +41,14 @@ class ChatSelectScreen extends StatelessWidget {
_buildScreen(BuildContext context, ChatSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -84,7 +83,7 @@ class ChatSelectScreen extends StatelessWidget {
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -61,11 +61,11 @@ class DiaryEditScreen extends StatelessWidget {
child: Stack(
children: [
FormBuilder(
child: SafeArea(
child: Scaffold(
child: Scaffold(
backgroundColor: Color.fromARGB(255, 240, 242, 245),
resizeToAvoidBottomInset: true,
body: SizedBox(
body: SafeArea(
child: SizedBox(
width: double.maxFinite,
child: Column(
children: [
@@ -94,9 +94,8 @@ class DiaryEditScreen extends StatelessWidget {
],
),
),
bottomNavigationBar: _buildBottomBar(context),
),
),
bottomNavigationBar: _buildBottomBar(context) ),
),
Positioned(
left: 16.h,

View File

@@ -39,14 +39,13 @@ class DietCreateScreen extends StatelessWidget {
_buildDietCreate(BuildContext context, DietCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
child: ListView(children: [
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -88,7 +87,7 @@ class DietCreateScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -41,14 +41,13 @@ class DietEditScreen extends StatelessWidget {
_buildDietEdit(BuildContext context, DietEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
child: ListView(children: [
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -105,7 +104,7 @@ class DietEditScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -40,11 +40,11 @@ class DietSelectScreen extends StatelessWidget {
_buildSetingsScreen(BuildContext context, DietSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
@@ -107,8 +107,8 @@ class DietSelectScreen extends StatelessWidget {
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
bottomNavigationBar: _buildBottomBar(context),
);
}

View File

@@ -41,10 +41,10 @@ class DietScreen extends StatelessWidget {
_buildDiet(BuildContext context, DietLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
@@ -117,7 +117,7 @@ class DietScreen extends StatelessWidget {
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
///Handling route based on bottom click actions

View File

@@ -40,14 +40,13 @@ class BlogPostCreateScreen extends StatelessWidget {
_buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -95,7 +94,7 @@ class BlogPostCreateScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -42,14 +42,13 @@ class BlogPostEditScreen extends StatelessWidget {
_buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -111,7 +110,7 @@ class BlogPostEditScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -46,26 +46,25 @@ class BlogPostScreen extends StatelessWidget {
_buildBlogPost(BuildContext context, BlogPostLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 15.v),
_buildHeaderRow(context, state),
SizedBox(height: 15.v),
_buildBlogPostData(context, state),
SizedBox(height: 15.v),
_buildTextField(context, state),
SizedBox(height: 15.v),
_buildCommentSection(context, state),
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
_buildHeaderRow(context, state),
SizedBox(height: 15.v),
_buildBlogPostData(context, state),
SizedBox(height: 15.v),
_buildTextField(context, state),
SizedBox(height: 15.v),
_buildCommentSection(context, state),
],
),
),
),bottomNavigationBar: _buildBottomBar(context));
}
_buildHeaderRow(BuildContext context, BlogPostLoadedState state) {

View File

@@ -40,11 +40,11 @@ class FeedScreen extends StatelessWidget {
_buildFeedScreen(BuildContext context, FeedLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
@@ -53,7 +53,6 @@ class FeedScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 20),
_buildSearch(),
SizedBox(height: 20),
_buildMenu(context, state),
@@ -64,9 +63,8 @@ class FeedScreen extends StatelessWidget {
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
bottomNavigationBar: _buildBottomBar(context),);
}
_buildSearch() {

View File

@@ -39,14 +39,13 @@ class PlanCreateScreen extends StatelessWidget {
_buildPlanCreate(BuildContext context, PlanCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -88,7 +87,7 @@ class PlanCreateScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -41,14 +41,13 @@ class PlanEditScreen extends StatelessWidget {
_buildPlanEdit(BuildContext context, PlanEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
child: ListView(children: [
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -105,7 +104,7 @@ class PlanEditScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -40,11 +40,11 @@ class PlanSelectScreen extends StatelessWidget {
_buildSetingsScreen(BuildContext context, PlanSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
@@ -106,9 +106,9 @@ class PlanSelectScreen extends StatelessWidget {
),
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
),
bottomNavigationBar: _buildBottomBar(context),
);
}

View File

@@ -41,10 +41,10 @@ class PlanScreen extends StatelessWidget {
_buildPlan(BuildContext context, PlanLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
@@ -115,7 +115,7 @@ class PlanScreen extends StatelessWidget {
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}

View File

@@ -48,6 +48,10 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
data.containsKey('userDetails') &&
data.containsKey('chartPoints') &&
data.containsKey('circumferences')) {
final avatarBox = await Hive.openBox('avatar');
final avatar = data['user']['profile_photo_path'];
print(avatar);
avatarBox.put('avatar', avatar);
if (state is MyProfileLoadedState) {
var currentState = state as MyProfileLoadedState;
var plans = []

View File

@@ -50,18 +50,17 @@ class MyProfileScreen extends StatelessWidget {
_buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(children: [
SizedBox(height: 30.v),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
@@ -134,8 +133,7 @@ class MyProfileScreen extends StatelessWidget {
.toList(),
)),
SizedBox(height: 5.v),
])))),
bottomNavigationBar: _buildBottomBar(context)));
]))))), bottomNavigationBar: _buildBottomBar(context));
}
/// Section Widget
@@ -166,8 +164,7 @@ class MyProfileScreen extends StatelessWidget {
);
}
addImage(BuildContext context) {
return () async {
addImage(BuildContext context) async {
final picker = ImagePicker();
List<XFile>? images = await picker.pickMultiImage();
if (images.isNotEmpty) {
@@ -175,7 +172,6 @@ class MyProfileScreen extends StatelessWidget {
context.read<MyProfileBloc>().add(UploadAvatar(image));
}
}
};
}
onTapSettings(BuildContext context) {

View File

@@ -44,11 +44,11 @@ class MySettingsScreen extends StatelessWidget {
_buildSetingsScreen(BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
@@ -170,9 +170,9 @@ class MySettingsScreen extends StatelessWidget {
),
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
),
bottomNavigationBar: _buildBottomBar(context),
);
}

View File

@@ -39,14 +39,13 @@ class RecipeCreateScreen extends StatelessWidget {
_buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
child: ListView(children: [
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -93,7 +92,7 @@ class RecipeCreateScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -41,14 +41,13 @@ class RecipeEditScreen extends StatelessWidget {
_buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
child: ListView(children: [
Container(
margin: EdgeInsets.only(
left: 16.h,
@@ -110,7 +109,7 @@ class RecipeEditScreen extends StatelessWidget {
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
}

View File

@@ -40,11 +40,11 @@ class RecipeSelectScreen extends StatelessWidget {
_buildRecipeScreen(BuildContext context, RecipeSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
@@ -106,9 +106,9 @@ class RecipeSelectScreen extends StatelessWidget {
),
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
),
bottomNavigationBar: _buildBottomBar(context),
);
}

View File

@@ -41,10 +41,10 @@ class RecipeScreen extends StatelessWidget {
_buildRecipe(BuildContext context, RecipeLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
body: SafeArea(
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
@@ -115,7 +115,7 @@ class RecipeScreen extends StatelessWidget {
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
), bottomNavigationBar: _buildBottomBar(context));
}
///Handling route based on bottom click actions

View File

@@ -126,6 +126,8 @@ class AppRoutes {
static const String planCreateScreen = '/planCreate';
static const String glossaryScreen = '/glossary';
static Map<String, WidgetBuilder> get routes => {
dateOfBirthScreen: DateOfBirthScreen.builder,
cityOfLivingScreen: CityOfLivingScreen.builder,

View File

@@ -21,7 +21,6 @@ class AppbarSubtitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTapCall,
child: Padding(
padding: margin ?? EdgeInsets.zero,
child: Text(
@@ -33,8 +32,4 @@ class AppbarSubtitle extends StatelessWidget {
),
);
}
void onTapCall() {
onTap!.call();
}
}

View File

@@ -56,7 +56,7 @@ class CustomBottomBarState extends State<CustomBottomBar> {
@override
Widget build(BuildContext context) {
return Container(
height: 83.v,
height: 100.v,
decoration: BoxDecoration(
border: Border.all(
color: appTheme.whiteA700,
@@ -105,21 +105,18 @@ class CustomBottomBarState extends State<CustomBottomBar> {
double iconWidth;
if (index == 0) {
// Для логотипа-
iconHeight = 52.v; // Увеличиваем высоту
iconWidth = 48.h; // Меняем ширину, чтобы сохранить пропорции
iconHeight = 50.v;
iconWidth = 50.h;
} else if (index == bottomMenuList.length - 2) {
// Для колокольчика
iconHeight = 20.v; // Уменьшаем высоту
iconWidth = 20.h; // Меняем ширину, чтобы сохранить пропорции
iconHeight = 20.v;
iconWidth = 20.h;
} else if (index == bottomMenuList.length - 1) {
// Для колокольчика
iconHeight = 40.v; // Уменьшаем высоту
iconWidth = 40.h; // Меняем ширину, чтобы сохранить пропорции
iconHeight = 40.v;
iconWidth = 40.h;
} else {
// Для остальных иконок
iconHeight = 24.v; // Стандартная высота
iconWidth = 19.h; // Стандартная ширина
iconHeight = 24.v;
iconWidth = 19.h;
}
return BottomNavigationBarItem(
@@ -142,10 +139,9 @@ class CustomBottomBarState extends State<CustomBottomBar> {
shadowColor: Colors.white,
surfaceTintColor: Colors.white,
position: RelativeRect.fromLTRB(
// Указываем позицию справа по центру
MediaQuery.of(context).size.width -
50, // Расположение от правого края
kToolbarHeight + 340, // Расположение от верхнего края
50,
kToolbarHeight + 340,
0, // Не смещаем по горизонтали
0, // Не смещаем по вертикали
),