Merge pull request 'Keyboard dismisser, focusNode fix for CustomTextField, SafeArea inside Scaffold' (#66) from maxxkim/eatvio_app:main into main

Reviewed-on: https://gittea.eatv.io/eatvio/eatvio_app/pulls/66
Reviewed-by: mike <reshetnick.mike@gmail.com>
This commit is contained in:
2024-06-04 10:09:23 +00:00
24 changed files with 123 additions and 166 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

@@ -27,12 +27,11 @@ class AuthScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body:GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
return BlocBuilder<AuthBloc, AuthState>(builder: (context, state) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
@@ -42,24 +41,16 @@ class AuthScreen extends StatelessWidget {
SizedBox(height: 60.v),
Text("email".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<AuthBloc, AuthState, TextEditingController?>(
selector: (state) => state.emailController,
builder: (context, emailController) {
return CustomTextFormField(
controller: emailController,
textInputAction: TextInputAction.done);
}),
CustomTextFormField(
controller: state.emailController,
textInputAction: TextInputAction.done),
SizedBox(height: 22.v),
Text("password".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v),
BlocSelector<AuthBloc, AuthState, TextEditingController?>(
selector: (state) => state.passwordController,
builder: (context, passwordController) {
return CustomTextFormField(
obscureText: true,
controller: passwordController,
);
}),
CustomTextFormField(
obscureText: true,
controller: state.passwordController,
),
SizedBox(height: 50.v),
NextStepButton(
text: "no_account".tr.toUpperCase(),
@@ -67,27 +58,15 @@ class AuthScreen extends StatelessWidget {
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapNoAccount(context)),
/*NextStepButton(
text: "Тест дневника".toUpperCase(),
margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapDiaryTest(context)),
NextStepButton(
text: "Тест чата".toUpperCase(),
text: "authentificate".tr.toUpperCase(),
margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapProfileTest(context)),*/
BlocBuilder<AuthBloc, AuthState>(builder: (context, state) {
return NextStepButton(
text: "authentificate".tr.toUpperCase(),
margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapAuth(state, context));
}),
]))));
onPressed: onTapAuth(state, context)),
]),
));
});
}
onTapAuth(AuthState state, BuildContext context) {

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

@@ -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

@@ -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

@@ -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

@@ -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,6 @@ class CustomBottomBarState extends State<CustomBottomBar> {
@override
Widget build(BuildContext context) {
return Container(
height: 83.v,
decoration: BoxDecoration(
border: Border.all(
color: appTheme.whiteA700,
@@ -105,21 +104,17 @@ 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 +137,8 @@ class CustomBottomBarState extends State<CustomBottomBar> {
shadowColor: Colors.white,
surfaceTintColor: Colors.white,
position: RelativeRect.fromLTRB(
// Указываем позицию справа по центру
MediaQuery.of(context).size.width -
50, // Расположение от правого края
kToolbarHeight + 340, // Расположение от верхнего края
MediaQuery.of(context).size.width - 50,
kToolbarHeight + 340,
0, // Не смещаем по горизонтали
0, // Не смещаем по вертикали
),

View File

@@ -123,8 +123,8 @@ class CustomTextFormField extends StatelessWidget {
width: width ?? double.maxFinite,
child: TextFormField(
controller: controller,
focusNode: focusNode ?? FocusNode(),
autofocus: autofocus!,
focusNode: focusNode ?? null,
autofocus: autofocus ?? false,
style: textStyle ?? theme.textTheme.titleMedium,
obscureText: obscureText!,
textInputAction: textInputAction,