From 4b22f1c638acd879639f8e9e3605e6094a5dddfe Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 19 Jun 2024 14:38:21 +0300 Subject: [PATCH] refactor(fix): bottomBar --- .../diary_edit_screen/diary_edit_screen.dart | 3 +- .../diet_select_screen.dart | 1 - .../plan_select_screen.dart | 1 - .../my_profile_screen/my_settings_screen.dart | 1 - .../recipe_edit_screen.dart | 72 +++++++++---------- .../recipe_select_screen.dart | 1 - 6 files changed, 36 insertions(+), 43 deletions(-) diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index 4644a7fb..e2be9487 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -1,6 +1,5 @@ // ignore_for_file: unused_local_variable - import 'bloc/diary_edit_bloc.dart'; import 'models/diary_edit_model.dart'; import 'package:flutter/material.dart'; @@ -90,7 +89,7 @@ class DiaryEditScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context) ), + ), ), _buildEndDay(context), ], diff --git a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart index 01d69fb0..68834d09 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -108,7 +108,6 @@ class DietSelectScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ); } diff --git a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart index b876f224..810bd3ae 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -108,7 +108,6 @@ class PlanSelectScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ); } diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart index 6f63f7e3..a5be7c00 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -170,7 +170,6 @@ class MySettingsScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ); } diff --git a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart index 95aee171..c9ce2669 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -14,12 +14,11 @@ import 'package:eatvio_app/widgets/custom_outlined_button.dart'; class RecipeEditScreen extends StatelessWidget { const RecipeEditScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final recipeID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => RecipeEditBloc(RecipeEditState( - recipeModelObj: RecipeEditModel(recipeID: recipeID.toString()))) - ..add(RecipeEditInitialEvent()), + create: (context) => RecipeEditBloc(RecipeEditState(recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))..add(RecipeEditInitialEvent()), child: RecipeEditScreen()); } @@ -55,18 +54,19 @@ class RecipeEditScreen extends StatelessWidget { } return RefreshIndicator( - onRefresh: refreshPage(context), - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: ListView(children: [ + onRefresh: refreshPage(context), + child: Scaffold( + appBar: AppBar( + toolbarHeight: 0, + automaticallyImplyLeading: false, + ), + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: ListView( + children: [ _buldAppBar(context), SizedBox(height: 20.v), _buildRecipeInfo(state, context), @@ -77,8 +77,12 @@ class RecipeEditScreen extends StatelessWidget { ), SizedBox(height: 20.v), _buildAdditional(context, state) - ]), - ))); + ], + ), + ), + ), + ), + ); } _buldAppBar(BuildContext context) { @@ -139,8 +143,8 @@ class RecipeEditScreen extends StatelessWidget { if (state.recipe?['image'] != null) CachedNetworkImage( imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image']), - width: double - .infinity, // Установите ширину равной ширине родительского элемента + width: double.infinity, + // Установите ширину равной ширине родительского элемента height: 200.0, fit: BoxFit.cover, placeholder: (context, url) => CircularProgressIndicator(), @@ -294,9 +298,10 @@ class RecipeEditScreen extends StatelessWidget { if (state.steps?[i]['image'] != null) CachedNetworkImage( imageUrl: dotenv.env['STORAGE_URL']! + (state.steps?[i]['image']), - width: double - .infinity, // Установите ширину равной ширине родительского элемента - height: 200.0, // Задайте постоянную высоту элемента + width: double.infinity, + // Установите ширину равной ширине родительского элемента + height: 200.0, + // Задайте постоянную высоту элемента fit: BoxFit.cover, placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => Icon(Icons.error), @@ -310,8 +315,7 @@ class RecipeEditScreen extends StatelessWidget { text: "Добавить шаг", buttonStyle: CustomButtonStyles.outlinePrimaryTL15, ), - if (isLastStep && - !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага + if (isLastStep && !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага Column( children: [ SizedBox(height: 16.0), @@ -320,8 +324,7 @@ class RecipeEditScreen extends StatelessWidget { Flexible( flex: 5, child: CustomOutlinedButton( - onPressed: () => - context.read().add(AddStep()), + onPressed: () => context.read().add(AddStep()), text: "Добавить шаг", buttonStyle: CustomButtonStyles.outlinePrimaryTL15, ), @@ -331,8 +334,7 @@ class RecipeEditScreen extends StatelessWidget { flex: 1, child: CustomOutlinedButton( text: "х", - onPressed: () => - context.read().add(RemoveStep(i)), + onPressed: () => context.read().add(RemoveStep(i)), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, ), ), @@ -374,9 +376,7 @@ class RecipeEditScreen extends StatelessWidget { Align(alignment: Alignment.centerLeft, child: Text("Теги")), _buildEditableTags(state.tags), SizedBox(height: 8.0), - Align( - alignment: Alignment.centerLeft, - child: Text("Ссылка на видео (необязательно)")), + Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")), CustomTextFormField( controller: state.video_url, hintText: "YouTube", @@ -416,12 +416,10 @@ class RecipeEditScreen extends StatelessWidget { } void _trimTags(newValue) { - List newTagNames = - newValue!.split(',').map((tag) => tag.trim()).toList(); - List> newTags = - newTagNames.map((tagName) => {'name': tagName}).toList(); - print(newTags); - } + List newTagNames = newValue!.split(',').map((tag) => tag.trim()).toList(); + List> newTags = newTagNames.map((tagName) => {'name': tagName}).toList(); + print(newTags); + } Function onTapBack(BuildContext context) { return () { diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart index 1881d3b6..2a3a108e 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -107,7 +107,6 @@ class RecipeSelectScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ); }