forked from eatvio/eatvio_app
Merge pull request 'diary' (#31) from eatvio/eatvio_app:diary into revert
Reviewed-on: maxxkim/eatvio_app#31
This commit is contained in:
@@ -3,7 +3,7 @@ name: Android Release
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
flutter_version: "3.19.0"
|
||||
flutter_version: "3.22.0"
|
||||
java_version: "12.x"
|
||||
flutter_channel: "stable"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Eatvio App Android Test
|
||||
on: [pull_request]
|
||||
|
||||
env:
|
||||
flutter_version: "3.19.0"
|
||||
flutter_version: "3.22.0"
|
||||
java_version: "12.x"
|
||||
flutter_channel: "stable"
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 1430;
|
||||
LastUpgradeCheck = 1510;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
LastUpgradeVersion = "1510"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
111
lib/app_router.dart
Normal file
111
lib/app_router.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/chat_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/feed_screen.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
|
||||
import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
|
||||
class AppRouter {
|
||||
static GoRouter appRouter = GoRouter(
|
||||
initialLocation: '/auth-screen',
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/auth-screen',
|
||||
name: 'authScreen',
|
||||
redirect: (context, state) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token != null) {
|
||||
return '/my-profile-screen';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
builder: (context, state) => AuthScreen.builder(context),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'language-select-screen',
|
||||
name: 'languageSelectScreen',
|
||||
builder: (context, state) => LanguageSelectScreen.builder(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
return BottomNavigationBarWidget(child: child);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/my-profile-screen',
|
||||
name: 'myProfileScreen',
|
||||
builder: (context, state) => MyProfileScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/feed-screen',
|
||||
name: 'feedScreen',
|
||||
builder: (context, state) => FeedScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'blog-post-create-screen',
|
||||
name: 'blogPostCreateScreen',
|
||||
builder: (context, state) => BlogPostCreateScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'blog-post-screen',
|
||||
name: 'blogPostScreen',
|
||||
builder: (context, state) => BlogPostScreen.builder(
|
||||
context,
|
||||
state.extra.toString(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/diary-screen',
|
||||
name: 'diaryScreen',
|
||||
builder: (context, state) => DiaryEditScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/chat-select-screen',
|
||||
name: 'chatSelectScreen',
|
||||
builder: (context, state) => ChatSelectScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/my-settings-screen',
|
||||
name: 'mySettingsScreen',
|
||||
builder: (context, state) => MySettingsScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/recipe-select-screen',
|
||||
name: 'recipeSelectScreen',
|
||||
builder: (context, state) => RecipeSelectScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/diet-select-screen',
|
||||
name: 'dietSelectScreen',
|
||||
builder: (context, state) => DietSelectScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/plan-select-screen',
|
||||
name: 'planSelectScreen',
|
||||
builder: (context, state) => PlanSelectScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/glossary-screen',
|
||||
name: 'glossaryScreen',
|
||||
builder: (context, state) => GlossaryScreen.builder(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_select_model.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_model.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/bloc/feed_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/models/feed_model.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@@ -7,6 +16,7 @@ import 'package:path_provider/path_provider.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
var globalMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final appDocumentDir = await getApplicationDocumentsDirectory();
|
||||
@@ -25,18 +35,45 @@ void main() async {
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => ThemeBloc(
|
||||
ThemeState(
|
||||
themeType: PrefUtils().getThemeData(),
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<ThemeBloc>(
|
||||
create: (context) => ThemeBloc(
|
||||
ThemeState(themeType: PrefUtils().getThemeData()),
|
||||
),
|
||||
),
|
||||
),
|
||||
BlocProvider<MyProfileBloc>(
|
||||
create: (context) => MyProfileBloc(
|
||||
MyProfileState(
|
||||
myProfileModelObj: MyProfileModel(),
|
||||
),
|
||||
)..add(MyProfileInitialEvent()),
|
||||
),
|
||||
BlocProvider<FeedBloc>(
|
||||
create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))
|
||||
..add(
|
||||
FeedInitialEvent(),
|
||||
),
|
||||
),
|
||||
BlocProvider<DiaryEditBloc>(
|
||||
create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))
|
||||
..add(
|
||||
DiaryEditInitialEvent(),
|
||||
),
|
||||
),
|
||||
BlocProvider<ChatSelectBloc>(
|
||||
create: (context) => ChatSelectBloc(ChatSelectState(chatSelectModelObj: ChatSelectModel()))
|
||||
..add(
|
||||
ChatSelectInitialEvent(),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: BlocBuilder<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) {
|
||||
return MaterialApp(
|
||||
return MaterialApp.router(
|
||||
theme: theme,
|
||||
title: 'Eatvio',
|
||||
navigatorKey: NavigatorService.navigatorKey,
|
||||
routerConfig: AppRouter.appRouter,
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: [
|
||||
AppLocalizationDelegate(),
|
||||
@@ -50,8 +87,6 @@ class MyApp extends StatelessWidget {
|
||||
'',
|
||||
),
|
||||
],
|
||||
initialRoute: AppRoutes.initialRoute,
|
||||
routes: AppRoutes.routes,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/auth_bloc.dart';
|
||||
import 'models/auth_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
@@ -30,44 +32,40 @@ class AuthScreen extends StatelessWidget {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: _buildAppBar(context),
|
||||
body:GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
SizedBox(height: 36.v),
|
||||
Text("user_authorization".tr,
|
||||
style: theme.textTheme.headlineSmall),
|
||||
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);
|
||||
}),
|
||||
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,
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 50.v),
|
||||
NextStepButton(
|
||||
text: "no_account".tr.toUpperCase(),
|
||||
margin:
|
||||
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: onTapNoAccount(context)),
|
||||
/*NextStepButton(
|
||||
body: GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
SizedBox(height: 36.v),
|
||||
Text("user_authorization".tr, style: theme.textTheme.headlineSmall),
|
||||
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);
|
||||
}),
|
||||
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,
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 50.v),
|
||||
NextStepButton(
|
||||
text: "no_account".tr.toUpperCase(),
|
||||
margin: 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),
|
||||
@@ -79,41 +77,33 @@ class AuthScreen extends StatelessWidget {
|
||||
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));
|
||||
}),
|
||||
]))));
|
||||
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));
|
||||
}),
|
||||
]))));
|
||||
}
|
||||
|
||||
onTapAuth(AuthState state, BuildContext context) {
|
||||
return () async {
|
||||
List<String> errors = validateFields(
|
||||
state.emailController!.text, state.passwordController!.text);
|
||||
List<String> errors = validateFields(state.emailController!.text, state.passwordController!.text);
|
||||
if (errors.isEmpty) {
|
||||
final Map<String, dynamic> credentials = {
|
||||
'email': state.emailController!.text,
|
||||
'password': state.passwordController!.text,
|
||||
};
|
||||
final response = await http.post(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/login'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: json.encode(credentials),
|
||||
encoding: utf8);
|
||||
final response = await http.post(Uri.parse(dotenv.env['SERVER_ROOT']! + '/login'),
|
||||
headers: {'Content-Type': 'application/json'}, body: json.encode(credentials), encoding: utf8);
|
||||
print(response.statusCode);
|
||||
if (response.statusCode == 200) {
|
||||
var res = await jsonDecode(response.body);
|
||||
final box = await Hive.openBox('token');
|
||||
final token = res['token'];
|
||||
box.put('token', token);
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.myProfile,
|
||||
);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -173,16 +163,13 @@ class AuthScreen extends StatelessWidget {
|
||||
|
||||
onTapNoAccount(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pushNamed(context, AppRoutes.languageSelectScreen);
|
||||
GoRouter.of(context).goNamed('languageSelectScreen');
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAppBar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 29.h,
|
||||
centerTitle: true,
|
||||
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
||||
return CustomAppBar(leadingWidth: 29.h, centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
||||
}
|
||||
|
||||
List<String> validateFields(String email, String password) {
|
||||
|
||||
@@ -6,8 +6,6 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
|
||||
class ChatScreen extends StatelessWidget {
|
||||
const ChatScreen({Key? key}) : super(key: key);
|
||||
@@ -59,7 +57,6 @@ class ChatScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildTextField(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,73 +102,6 @@ class ChatScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildTextField(BuildContext context) {
|
||||
return Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 7.h,
|
||||
vertical: 6.v,
|
||||
),
|
||||
decoration: AppDecoration.outlineBlueGray,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgAttach,
|
||||
height: 29.adaptSize,
|
||||
width: 29.adaptSize,
|
||||
margin: EdgeInsets.only(
|
||||
top: 1.v,
|
||||
bottom: 6.v,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 4.h,
|
||||
bottom: 4.v,
|
||||
),
|
||||
child: BlocSelector<ChatBloc, ChatState, TextEditingController?>(
|
||||
selector: (state) => TextEditingController(),
|
||||
builder: (context, messageController) {
|
||||
return CustomTextFormField(
|
||||
controller: messageController,
|
||||
hintText: "Напишите сообщение...",
|
||||
textInputAction: TextInputAction.done,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgMic,
|
||||
height: 24.v,
|
||||
width: 18.h,
|
||||
margin: EdgeInsets.only(
|
||||
left: 11.h,
|
||||
top: 4.v,
|
||||
bottom: 8.v,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Common widget
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
case BottomBarEnum.tf:
|
||||
return AppRoutes.chatScreen;
|
||||
default:
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
|
||||
///Handling page based on route
|
||||
Widget getCurrentPage(
|
||||
BuildContext context,
|
||||
|
||||
@@ -2,89 +2,87 @@ import 'bloc/chat_select_bloc.dart';
|
||||
import 'models/chat_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import '../chat_select_screen/chat_search_view.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart'; // ignore: must_be_immutable
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart'; // ignore: must_be_immutable
|
||||
|
||||
class ChatSelectScreen extends StatelessWidget {
|
||||
const ChatSelectScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<ChatSelectBloc>(
|
||||
create: (context) => ChatSelectBloc(
|
||||
ChatSelectState(chatSelectModelObj: ChatSelectModel()))
|
||||
..add(ChatSelectInitialEvent()),
|
||||
child: ChatSelectScreen());
|
||||
create: (context) => ChatSelectBloc(ChatSelectState(chatSelectModelObj: ChatSelectModel()))..add(ChatSelectInitialEvent()), child: ChatSelectScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ChatSelectBloc, ChatSelectState>(
|
||||
builder: (context, state) {
|
||||
if (state is ChatSelectInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
);
|
||||
} else if (state is ChatSelectLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildScreen(context, state);
|
||||
} else if (state is ChatSelectErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is ChatSelectInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
);
|
||||
} else if (state is ChatSelectLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildScreen(context, state);
|
||||
} else if (state is ChatSelectErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildScreen(BuildContext context, ChatSelectLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomSearchView(
|
||||
controller: state.searchController,
|
||||
hintText: "Поиск",
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomSearchView(
|
||||
controller: state.searchController,
|
||||
hintText: "Поиск",
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildChatList(context, state),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
SizedBox(height: 20.v),
|
||||
_buildChatList(context, state),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +103,3 @@ _buildChatList(BuildContext context, ChatSelectLoadedState state) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/diary_edit_bloc.dart';
|
||||
import 'models/diary_edit_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -13,22 +15,15 @@ import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class DiaryEditScreen extends StatelessWidget {
|
||||
final void Function() onInitialize;
|
||||
DiaryEditScreen({Key? key, required this.onInitialize}) : super(key: key);
|
||||
DiaryEditScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<DiaryEditBloc>(
|
||||
create: (context) =>
|
||||
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))
|
||||
..add(DiaryEditInitialEvent()),
|
||||
child: DiaryEditScreen(
|
||||
onInitialize: () {},
|
||||
));
|
||||
create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))..add(DiaryEditInitialEvent()), child: DiaryEditScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -53,12 +48,11 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiaryEditScreen(
|
||||
BuildContext context, DiaryEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: refreshPage(context),
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
FormBuilder(
|
||||
child: SafeArea(
|
||||
@@ -94,16 +88,10 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 16.h,
|
||||
right: 16.h,
|
||||
bottom: 50.v, // Adjusted position to lift the button higher
|
||||
child: _buildEndDay(context),
|
||||
),
|
||||
_buildEndDay(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -115,7 +103,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 16.h,
|
||||
bottom: 41.v,
|
||||
bottom: 16.v,
|
||||
),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
decoration: BoxDecoration(
|
||||
@@ -157,7 +145,9 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()),
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 1.v),
|
||||
child: Column(
|
||||
@@ -182,16 +172,6 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
onTapBack() {
|
||||
return () {
|
||||
NavigatorService.goBack();
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAddProduct(BuildContext context, DiaryEditLoadedState state) {
|
||||
return CustomOutlinedButton(
|
||||
@@ -260,9 +240,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
borderRadius: BorderRadiusStyle.roundedBorder5,
|
||||
),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: appTheme
|
||||
.blueGray300), // Замените на свой прелоадер при необходимости
|
||||
child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -286,8 +264,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
_buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
List<String> _options =
|
||||
state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
List<String> _options = state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
//print(_options);
|
||||
FocusNode focusNodeName = FocusNode();
|
||||
return Container(
|
||||
@@ -332,9 +309,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
onTap: () => _selectMealTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText: state.mealTimeController
|
||||
?.format(context)
|
||||
.toString(),
|
||||
hintText: state.mealTimeController?.format(context).toString(),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
@@ -348,8 +323,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState,
|
||||
DiaryEditModel?>(
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState, DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
return CustomDropDown(
|
||||
@@ -441,8 +415,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 30.h),
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState,
|
||||
DiaryEditModel?>(
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState, DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
return CustomDropDown(
|
||||
@@ -460,9 +433,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
...state.portions!
|
||||
.map((portion) => _buildProduct(context, portion))
|
||||
.toList(),
|
||||
...state.portions!.map((portion) => _buildProduct(context, portion)).toList(),
|
||||
SizedBox(height: 30.v),
|
||||
/*...state.photos != null
|
||||
? state.photos!.isEmpty
|
||||
@@ -575,14 +546,8 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
child: Text('Отмена'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: triggerModeration(
|
||||
context,
|
||||
state.productNameController!.text,
|
||||
state.caloriesController!.text,
|
||||
state.proteinsController!.text,
|
||||
state.fatsController!.text,
|
||||
state.carbsController!.text,
|
||||
dialogContext),
|
||||
onPressed: triggerModeration(context, state.productNameController!.text, state.caloriesController!.text, state.proteinsController!.text,
|
||||
state.fatsController!.text, state.carbsController!.text, dialogContext),
|
||||
child: Text('Отправить'),
|
||||
),
|
||||
],
|
||||
@@ -591,30 +556,19 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
triggerModeration(
|
||||
BuildContext context,
|
||||
String name,
|
||||
String energyOn100gr,
|
||||
String proteinsOn100gr,
|
||||
String fatsOn100gr,
|
||||
String carbohydratesOn100gr,
|
||||
triggerModeration(BuildContext context, String name, String energyOn100gr, String proteinsOn100gr, String fatsOn100gr, String carbohydratesOn100gr,
|
||||
BuildContext dialogContext) {
|
||||
return () {
|
||||
// Call function to send moderation with the entered values
|
||||
context.read<DiaryEditBloc>().add(SendModeration(
|
||||
name: name,
|
||||
energyOn100gr: energyOn100gr,
|
||||
proteinsOn100gr: proteinsOn100gr,
|
||||
fatsOn100gr: fatsOn100gr,
|
||||
carbohydratesOn100gr: carbohydratesOn100gr));
|
||||
name: name, energyOn100gr: energyOn100gr, proteinsOn100gr: proteinsOn100gr, fatsOn100gr: fatsOn100gr, carbohydratesOn100gr: carbohydratesOn100gr));
|
||||
Navigator.of(dialogContext).pop(); // Dismiss the dialog
|
||||
};
|
||||
}
|
||||
|
||||
popDialog(BuildContext dialogContext) {
|
||||
return () {
|
||||
Navigator.of(dialogContext)
|
||||
.pop(); // Dismiss the dialog on Cancel button press
|
||||
Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press
|
||||
};
|
||||
}
|
||||
|
||||
@@ -624,8 +578,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
selectProduct(AutocompleteOnSelected<String> onSelected, String option,
|
||||
DiaryEditLoadedState state) {
|
||||
selectProduct(AutocompleteOnSelected<String> onSelected, String option, DiaryEditLoadedState state) {
|
||||
state.productNameController?.text = option;
|
||||
return () {
|
||||
onSelected(option);
|
||||
@@ -653,9 +606,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
changeMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
return (value) {
|
||||
context
|
||||
.read<DiaryEditBloc>()
|
||||
.add(ChangeMeal(meals: state.meals, value: value));
|
||||
context.read<DiaryEditBloc>().add(ChangeMeal(meals: state.meals, value: value));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -672,8 +623,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
return CarouselSlider(
|
||||
options: CarouselOptions(height: 340.0),
|
||||
items: state.photos!.map<Widget>((photo) {
|
||||
return _buildPhoto(
|
||||
context, photo); // Assuming photos are stored as strings
|
||||
return _buildPhoto(context, photo); // Assuming photos are stored as strings
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
@@ -699,9 +649,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
top: 5.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['product_name'].length > 8
|
||||
? portion['product_name'].substring(0, 8)
|
||||
: portion['product_name'],
|
||||
portion['product_name'].length > 8 ? portion['product_name'].substring(0, 8) : portion['product_name'],
|
||||
style: CustomTextStyles.titleMedium16,
|
||||
)),
|
||||
Padding(
|
||||
@@ -711,9 +659,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
bottom: 3.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['quantity'].toString() +
|
||||
' ' +
|
||||
portion['portion'].toString().tr,
|
||||
portion['quantity'].toString() + ' ' + portion['portion'].toString().tr,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
@@ -773,15 +719,12 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
removePhoto(BuildContext context, Map<String, dynamic> photo) {
|
||||
return () {
|
||||
context
|
||||
.read<DiaryEditBloc>()
|
||||
.add(RemoveImageEvent(photo['id'].toString(), photo['path']));
|
||||
context.read<DiaryEditBloc>().add(RemoveImageEvent(photo['id'].toString(), photo['path']));
|
||||
};
|
||||
}
|
||||
|
||||
_buildNutritionChart(BuildContext context, DiaryEditLoadedState state) {
|
||||
final List<int> recommendedValues = state
|
||||
.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
||||
final List<int> recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
||||
final List<int> consumedValues = state.consumedChartValues; //
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
@@ -843,37 +786,25 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
BarChartGroupData(x: 0, barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[0] / recommendedValues[0] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[0]], [consumedValues[1]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
color: checkConsumedValues([recommendedValues[0]], [consumedValues[1]]) ? Colors.red : Colors.blue,
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 1, barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[1] / recommendedValues[1] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[1]], [consumedValues[1]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
color: checkConsumedValues([recommendedValues[1]], [consumedValues[1]]) ? Colors.red : Colors.blue,
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 2, barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[2] / recommendedValues[2] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[2]], [consumedValues[2]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
color: checkConsumedValues([recommendedValues[2]], [consumedValues[2]]) ? Colors.red : Colors.blue,
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 3, barRods: [
|
||||
BarChartRodData(
|
||||
toY: consumedValues[3] / recommendedValues[3] * 100,
|
||||
color: checkConsumedValues(
|
||||
[recommendedValues[3]], [consumedValues[3]])
|
||||
? Colors.red
|
||||
: Colors.blue,
|
||||
color: checkConsumedValues([recommendedValues[3]], [consumedValues[3]]) ? Colors.red : Colors.blue,
|
||||
)
|
||||
]),
|
||||
],
|
||||
@@ -1063,9 +994,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
r"Подъем \ отход ко сну",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(state.wakeupExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -1079,8 +1008,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
onTap: () => _selectWakeupTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.wakeupController?.format(context).toString(),
|
||||
hintText: state.wakeupController?.format(context).toString(),
|
||||
prefix: Icon(Icons.sunny),
|
||||
autofocus: false,
|
||||
),
|
||||
@@ -1091,8 +1019,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
onTap: () => _selectRetireTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.retireController?.format(context).toString(),
|
||||
hintText: state.retireController?.format(context).toString(),
|
||||
prefix: Icon(Icons.bed),
|
||||
autofocus: false,
|
||||
),
|
||||
@@ -1139,8 +1066,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
Function() sendFinishDayData(
|
||||
BuildContext dialogContext, BuildContext context) {
|
||||
Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) {
|
||||
return () {
|
||||
closeDialog(dialogContext);
|
||||
context.read<DiaryEditBloc>().add(FinishDay());
|
||||
@@ -1182,9 +1108,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
"Ваше настроение после приема пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(state.moodExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -1242,8 +1166,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> _selectWakeupTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
Future<void> _selectWakeupTime(BuildContext context, DiaryEditLoadedState state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.wakeupController ?? TimeOfDay.now(),
|
||||
@@ -1254,8 +1177,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectRetireTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
Future<void> _selectRetireTime(BuildContext context, DiaryEditLoadedState state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.retireController ?? TimeOfDay.now(),
|
||||
@@ -1266,8 +1188,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectMealTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
Future<void> _selectMealTime(BuildContext context, DiaryEditLoadedState state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.mealTimeController ?? TimeOfDay.now(),
|
||||
@@ -1279,8 +1200,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
bool checkConsumedValues(
|
||||
List<int> recommendedValues, List<int> consumedValues) {
|
||||
bool checkConsumedValues(List<int> recommendedValues, List<int> consumedValues) {
|
||||
for (int i = 0; i < recommendedValues.length; i++) {
|
||||
if (consumedValues[i] > recommendedValues[i]) {
|
||||
// Если хотя бы одно потребленное значение превышает рекомендованное
|
||||
|
||||
@@ -2,16 +2,14 @@ import 'bloc/diet_create_bloc.dart';
|
||||
import 'models/diet_create_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
|
||||
class DietCreateScreen extends StatelessWidget {
|
||||
const DietCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final dietID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<DietCreateBloc>(
|
||||
create: (context) => DietCreateBloc(DietCreateState(
|
||||
dietModelObj: DietCreateModel(dietID: dietID.toString())))
|
||||
..add(DietCreateInitialEvent()),
|
||||
create: (context) => DietCreateBloc(DietCreateState(dietModelObj: DietCreateModel(dietID: dietID.toString())))..add(DietCreateInitialEvent()),
|
||||
child: DietCreateScreen());
|
||||
}
|
||||
|
||||
@@ -40,58 +38,54 @@ class DietCreateScreen extends StatelessWidget {
|
||||
_buildDietCreate(BuildContext context, DietCreateLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.name,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.details,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<DietCreateBloc>().add(CreateDiet()),
|
||||
child: Text('Создать'),
|
||||
)
|
||||
]),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.name,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.details,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () => context.read<DietCreateBloc>().add(CreateDiet()),
|
||||
child: Text('Создать'),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -2,18 +2,16 @@ import 'bloc/diet_edit_bloc.dart';
|
||||
import 'models/diet_edit_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class DietEditScreen extends StatelessWidget {
|
||||
const DietEditScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final dietID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<DietEditBloc>(
|
||||
create: (context) => DietEditBloc(DietEditState(
|
||||
dietModelObj: DietEditModel(dietID: dietID.toString())))
|
||||
..add(DietEditInitialEvent()),
|
||||
create: (context) => DietEditBloc(DietEditState(dietModelObj: DietEditModel(dietID: dietID.toString())))..add(DietEditInitialEvent()),
|
||||
child: DietEditScreen());
|
||||
}
|
||||
|
||||
@@ -42,42 +40,43 @@ class DietEditScreen extends StatelessWidget {
|
||||
_buildDietEdit(BuildContext context, DietEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.diet?['image'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
@@ -97,18 +96,16 @@ class DietEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<DietEditBloc>().add(EditDiet()),
|
||||
onPressed: () => context.read<DietEditBloc>().add(EditDiet()),
|
||||
child: Text('Сохранить'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/diet_select_bloc.dart';
|
||||
import 'models/diet_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -39,75 +40,71 @@ class DietSelectScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildSetingsScreen(BuildContext context, DietSelectLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: onTapBack(context),
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Диеты",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Диеты",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildDietList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildDietList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -174,10 +171,6 @@ class DietSelectScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,16 @@ import 'bloc/diet_show_bloc.dart';
|
||||
import 'models/diet_show_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class DietScreen extends StatelessWidget {
|
||||
const DietScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final dietID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<DietBloc>(
|
||||
create: (context) => DietBloc(
|
||||
DietState(dietModelObj: DietModel(dietID: dietID.toString())))
|
||||
..add(DietInitialEvent()),
|
||||
child: DietScreen());
|
||||
create: (context) => DietBloc(DietState(dietModelObj: DietModel(dietID: dietID.toString())))..add(DietInitialEvent()), child: DietScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -42,92 +39,78 @@ class DietScreen extends StatelessWidget {
|
||||
_buildDiet(BuildContext context, DietLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.diet?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.diet?['name'], style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.diet?['details'],
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietEditScreen,
|
||||
arguments: state.diet?['id'].toString(),
|
||||
),
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.diet?['name'],
|
||||
style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.diet?['details'],
|
||||
ElevatedButton(
|
||||
onPressed: () => context.read<DietBloc>().add(DeleteEntry(state.diet?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietEditScreen,
|
||||
arguments: state.diet?['id'].toString(),
|
||||
),
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => context
|
||||
.read<DietBloc>()
|
||||
.add(DeleteEntry(state.diet?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
)
|
||||
]),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
case BottomBarEnum.tf:
|
||||
return AppRoutes.dietScreen;
|
||||
default:
|
||||
return "/";
|
||||
}
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling page based on route
|
||||
@@ -143,10 +126,6 @@ class DietScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
|
||||
@@ -2,18 +2,16 @@ import 'bloc/blog_post_create_bloc.dart';
|
||||
import 'models/blog_post_create_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
|
||||
class BlogPostCreateScreen extends StatelessWidget {
|
||||
const BlogPostCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final blog_postID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<BlogPostCreateBloc>(
|
||||
create: (context) => BlogPostCreateBloc(BlogPostCreateState(
|
||||
blog_postModelObj:
|
||||
BlogPostCreateModel(blog_postID: blog_postID.toString())))
|
||||
create: (context) => BlogPostCreateBloc(BlogPostCreateState(blog_postModelObj: BlogPostCreateModel(blog_postID: blog_postID.toString())))
|
||||
..add(BlogPostCreateInitialEvent()),
|
||||
child: BlogPostCreateScreen());
|
||||
}
|
||||
@@ -41,92 +39,85 @@ class BlogPostCreateScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Text("Заголовок новости", style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
validator: _validateTitle,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 8.0),
|
||||
Text("Ссылка на YouTube", style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.youtube_url,
|
||||
validator: _validateYouTubeLink,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Text("Заголовок новости",
|
||||
style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
validator: _validateTitle,
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text("Ссылка на YouTube",
|
||||
style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.youtube_url,
|
||||
validator: _validateYouTubeLink,
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text("Описание", style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
validator: _validateDescription,
|
||||
maxLines: 6,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Add widget for image upload here
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => _submitForm(
|
||||
context,
|
||||
state.title!.text,
|
||||
state.description!.text,
|
||||
state.youtube_url!.text),
|
||||
buttonStyle:
|
||||
CustomButtonStyles.outlinePrimaryTL15,
|
||||
text: 'Создать',
|
||||
),
|
||||
],
|
||||
),
|
||||
]))
|
||||
])),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
SizedBox(height: 8.0),
|
||||
Text("Описание", style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
validator: _validateDescription,
|
||||
maxLines: 6,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Add widget for image upload here
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtube_url!.text),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
text: 'Создать',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_submitForm(
|
||||
BuildContext context, String title, String description, String youtubeURL) {
|
||||
_submitForm(BuildContext context, String title, String description, String youtubeURL) {
|
||||
String? titleError = _validateTitle(title);
|
||||
String? descriptionError = _validateDescription(description);
|
||||
String? youtubeURLError = _validateYouTubeLink(youtubeURL);
|
||||
|
||||
if (titleError != null ||
|
||||
descriptionError != null ||
|
||||
youtubeURLError != null) {
|
||||
if (titleError != null || descriptionError != null || youtubeURLError != null) {
|
||||
// Display error messages or handle invalid input as needed
|
||||
// For example, show a snackbar with the error message
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
|
||||
SnackBar(content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
|
||||
);
|
||||
} else {
|
||||
// Proceed with form submission
|
||||
@@ -158,11 +149,6 @@ String? _validateYouTubeLink(value) {
|
||||
}
|
||||
|
||||
bool _isValidUrl(String url) {
|
||||
final RegExp urlRegExp =
|
||||
new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
|
||||
final RegExp urlRegExp = new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
|
||||
return urlRegExp.hasMatch(url);
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -2,19 +2,17 @@ import 'bloc/blog_post_edit_bloc.dart';
|
||||
import 'models/blog_post_edit_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class BlogPostEditScreen extends StatelessWidget {
|
||||
const BlogPostEditScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final blog_postID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<BlogPostEditBloc>(
|
||||
create: (context) => BlogPostEditBloc(BlogPostEditState(
|
||||
blog_postModelObj:
|
||||
BlogPostEditModel(blog_postID: blog_postID.toString())))
|
||||
..add(BlogPostEditInitialEvent()),
|
||||
create: (context) =>
|
||||
BlogPostEditBloc(BlogPostEditState(blog_postModelObj: BlogPostEditModel(blog_postID: blog_postID.toString())))..add(BlogPostEditInitialEvent()),
|
||||
child: BlogPostEditScreen());
|
||||
}
|
||||
|
||||
@@ -43,42 +41,43 @@ class BlogPostEditScreen extends StatelessWidget {
|
||||
_buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.blog_post?['image'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
@@ -103,18 +102,16 @@ class BlogPostEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<BlogPostEditBloc>().add(EditBlogPost()),
|
||||
onPressed: () => context.read<BlogPostEditBloc>().add(EditBlogPost()),
|
||||
child: Text('Сохранить'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/blog_post_bloc.dart';
|
||||
import 'models/blog_post_model.dart';
|
||||
import 'widgets/comment_widget.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
@@ -12,60 +13,73 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class BlogPostScreen extends StatelessWidget {
|
||||
const BlogPostScreen({Key? key}) : super(key: key);
|
||||
static Widget builder(BuildContext context) {
|
||||
final blog_postID = ModalRoute.of(context)!.settings.arguments;
|
||||
|
||||
static Widget builder(BuildContext context, String blog_postID) {
|
||||
return BlocProvider<BlogPostBloc>(
|
||||
create: (context) => BlogPostBloc(BlogPostState(
|
||||
blog_postModelObj:
|
||||
BlogPostModel(blog_postID: blog_postID.toString())))
|
||||
..add(BlogPostInitialEvent()),
|
||||
child: BlogPostScreen());
|
||||
create: (context) => BlogPostBloc(
|
||||
BlogPostState(
|
||||
blog_postModelObj: BlogPostModel(
|
||||
blog_postID: blog_postID.toString(),
|
||||
),
|
||||
),
|
||||
)..add(
|
||||
BlogPostInitialEvent(),
|
||||
),
|
||||
child: BlogPostScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<BlogPostBloc, BlogPostState>(
|
||||
builder: (context, state) {
|
||||
if (state is BlogPostInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is BlogPostLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildBlogPost(context, state);
|
||||
} else if (state is BlogPostErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
return Center(
|
||||
child: Text(state.errorMessage),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildBlogPost(BuildContext context, BlogPostLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: 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)));
|
||||
child: 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),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildHeaderRow(BuildContext context, BlogPostLoadedState state) {
|
||||
@@ -92,8 +106,9 @@ class BlogPostScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
onTap: () => NavigatorService.goBack()),
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 1.v),
|
||||
child: Row(
|
||||
@@ -106,8 +121,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.author?['profile_photo_path'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.author?['profile_photo_path'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
@@ -181,8 +195,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy')
|
||||
.format(DateTime.parse(state.blog_post?['updated_at'])),
|
||||
DateFormat('dd.MM.yyyy').format(DateTime.parse(state.blog_post?['updated_at'])),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
)),
|
||||
SizedBox(height: 16.0),
|
||||
@@ -342,9 +355,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
onPressed: () => context
|
||||
.read<BlogPostBloc>()
|
||||
.add(CreateComment(state.commentController!.text)),
|
||||
onPressed: () => context.read<BlogPostBloc>().add(CreateComment(state.commentController!.text)),
|
||||
// Установите прозрачный фон
|
||||
)
|
||||
],
|
||||
@@ -377,12 +388,8 @@ class BlogPostScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/feed_bloc.dart';
|
||||
import 'models/feed_model.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/widgets/feed_search_view.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/widgets/feed_scroll_item.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -12,10 +13,7 @@ import 'package:intl/intl.dart';
|
||||
|
||||
class FeedScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<FeedBloc>(
|
||||
create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))
|
||||
..add(FeedInitialEvent()),
|
||||
child: FeedScreen());
|
||||
return BlocProvider<FeedBloc>(create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))..add(FeedInitialEvent()), child: FeedScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -64,7 +62,6 @@ class FeedScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -106,10 +103,7 @@ class FeedScreen extends StatelessWidget {
|
||||
flex: 1,
|
||||
child: CustomOutlinedButton(
|
||||
text: "+",
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostCreateScreen,
|
||||
),
|
||||
onPressed: () => GoRouter.of(context).goNamed('blogPostCreateScreen'),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
@@ -154,8 +148,7 @@ class FeedScreen extends StatelessWidget {
|
||||
child: Column(children: [
|
||||
ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(post["author"]['profile_photo_path'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (post["author"]['profile_photo_path'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
@@ -172,14 +165,12 @@ class FeedScreen extends StatelessWidget {
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(
|
||||
DateFormat('dd.MM.yyyy')
|
||||
.format(DateTime.parse(post?['post']['updated_at'])),
|
||||
DateFormat('dd.MM.yyyy').format(DateTime.parse(post?['post']['updated_at'])),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostScreen,
|
||||
arguments: post?['post']['id'].toString(),
|
||||
onTap: () => GoRouter.of(context).goNamed(
|
||||
'blogPostScreen',
|
||||
extra: post?['post']['id'].toString(),
|
||||
),
|
||||
trailing: PopupMenuButton<String>(
|
||||
onSelected: (value) => print("tap"),
|
||||
@@ -220,13 +211,11 @@ class FeedScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(post?['post']['image'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (post?['post']['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8.0)),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
||||
child: Image(
|
||||
image: imageProvider,
|
||||
),
|
||||
@@ -277,10 +266,6 @@ class FeedScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_drop_down.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart';
|
||||
@@ -12,12 +11,10 @@ import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossar
|
||||
|
||||
class GlossaryScreen extends StatelessWidget {
|
||||
const GlossaryScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<GlossaryBloc>(
|
||||
create: (context) =>
|
||||
GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel()))
|
||||
..add(GlossaryInitialEvent()),
|
||||
child: GlossaryScreen());
|
||||
create: (context) => GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel()))..add(GlossaryInitialEvent()), child: GlossaryScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,32 +40,28 @@ class GlossaryScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildGlossary(BuildContext context, GlossaryLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 20),
|
||||
_buildSearch(context),
|
||||
SizedBox(height: 20),
|
||||
_buildMenu(context),
|
||||
SizedBox(height: 20),
|
||||
_buildProducts(context, state)
|
||||
],
|
||||
),
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 20),
|
||||
_buildSearch(context),
|
||||
SizedBox(height: 20),
|
||||
_buildMenu(context),
|
||||
SizedBox(height: 20),
|
||||
_buildProducts(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -184,16 +177,12 @@ class GlossaryScreen extends StatelessWidget {
|
||||
vertical: 9,
|
||||
),
|
||||
onChanged: _changeProductGroup(context, state),
|
||||
width: MediaQuery.of(context)
|
||||
.size
|
||||
.width, // Set a percentage value as per your layout
|
||||
width: MediaQuery.of(context).size.width, // Set a percentage value as per your layout
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text("*КБЖУ указано за 100гр")),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("*КБЖУ указано за 100гр")),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
@@ -268,8 +257,7 @@ class GlossaryScreen extends StatelessWidget {
|
||||
child: Column(children: [
|
||||
Text("Жиры - ${product['fats_on_100gr'].toString()}"),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
"Углеводы - ${product['carbohydrates_on_100gr'].toString()}")
|
||||
Text("Углеводы - ${product['carbohydrates_on_100gr'].toString()}")
|
||||
]),
|
||||
)
|
||||
])
|
||||
@@ -298,16 +286,6 @@ class GlossaryScreen extends StatelessWidget {
|
||||
return result;
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
case BottomBarEnum.tf:
|
||||
return AppRoutes.glossaryScreen;
|
||||
default:
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
|
||||
///Handling page based on route
|
||||
Widget getCurrentPage(
|
||||
BuildContext context,
|
||||
@@ -321,10 +299,6 @@ class GlossaryScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
_changeProductGroup(BuildContext context, GlossaryLoadedState state) {
|
||||
return (value) {
|
||||
context.read<GlossaryBloc>().add(ChangeProductGroup(value.id));
|
||||
|
||||
@@ -2,16 +2,14 @@ import 'bloc/plan_create_bloc.dart';
|
||||
import 'models/plan_create_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
|
||||
class PlanCreateScreen extends StatelessWidget {
|
||||
const PlanCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final planID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<PlanCreateBloc>(
|
||||
create: (context) => PlanCreateBloc(PlanCreateState(
|
||||
planModelObj: PlanCreateModel(planID: planID.toString())))
|
||||
..add(PlanCreateInitialEvent()),
|
||||
create: (context) => PlanCreateBloc(PlanCreateState(planModelObj: PlanCreateModel(planID: planID.toString())))..add(PlanCreateInitialEvent()),
|
||||
child: PlanCreateScreen());
|
||||
}
|
||||
|
||||
@@ -40,58 +38,56 @@ class PlanCreateScreen extends StatelessWidget {
|
||||
_buildPlanCreate(BuildContext context, PlanCreateLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.name,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.details,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<PlanCreateBloc>().add(CreatePlan()),
|
||||
child: Text('Создать'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.name,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.details,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () => context.read<PlanCreateBloc>().add(CreatePlan()),
|
||||
child: Text('Создать'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -2,18 +2,16 @@ import 'bloc/plan_edit_bloc.dart';
|
||||
import 'models/plan_edit_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class PlanEditScreen extends StatelessWidget {
|
||||
const PlanEditScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final planID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<PlanEditBloc>(
|
||||
create: (context) => PlanEditBloc(PlanEditState(
|
||||
planModelObj: PlanEditModel(planID: planID.toString())))
|
||||
..add(PlanEditInitialEvent()),
|
||||
create: (context) => PlanEditBloc(PlanEditState(planModelObj: PlanEditModel(planID: planID.toString())))..add(PlanEditInitialEvent()),
|
||||
child: PlanEditScreen());
|
||||
}
|
||||
|
||||
@@ -42,42 +40,43 @@ class PlanEditScreen extends StatelessWidget {
|
||||
_buildPlanEdit(BuildContext context, PlanEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.plan?['image'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
@@ -97,18 +96,16 @@ class PlanEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<PlanEditBloc>().add(EditPlan()),
|
||||
onPressed: () => context.read<PlanEditBloc>().add(EditPlan()),
|
||||
child: Text('Сохранить'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/plan_select_bloc.dart';
|
||||
import 'models/plan_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -39,75 +40,71 @@ class PlanSelectScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildSetingsScreen(BuildContext context, PlanSelectLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: onTapBack(context),
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Планы",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Планы",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildPlanList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildPlanList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -174,10 +171,6 @@ class PlanSelectScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,16 @@ import 'bloc/plan_show_bloc.dart';
|
||||
import 'models/plan_show_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class PlanScreen extends StatelessWidget {
|
||||
const PlanScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final planID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<PlanBloc>(
|
||||
create: (context) => PlanBloc(
|
||||
PlanState(planModelObj: PlanModel(planID: planID.toString())))
|
||||
..add(PlanInitialEvent()),
|
||||
child: PlanScreen());
|
||||
create: (context) => PlanBloc(PlanState(planModelObj: PlanModel(planID: planID.toString())))..add(PlanInitialEvent()), child: PlanScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -42,91 +39,76 @@ class PlanScreen extends StatelessWidget {
|
||||
_buildPlan(BuildContext context, PlanLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.plan?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.plan?['name'], style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.plan?['details'],
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Действие для редактирования
|
||||
},
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.plan?['name'],
|
||||
style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.plan?['details'],
|
||||
ElevatedButton(
|
||||
onPressed: () => context.read<PlanBloc>().add(DeleteEntry(state.plan?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Действие для редактирования
|
||||
},
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => context
|
||||
.read<PlanBloc>()
|
||||
.add(DeleteEntry(state.plan?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
)
|
||||
]),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
case BottomBarEnum.tf:
|
||||
return AppRoutes.planScreen;
|
||||
default:
|
||||
return "/";
|
||||
}
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling page based on route
|
||||
@@ -142,10 +124,6 @@ class PlanScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
|
||||
import 'bloc/my_profile_bloc.dart';
|
||||
import 'models/my_profile_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@@ -19,10 +20,13 @@ import 'dart:convert';
|
||||
class MyProfileScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<MyProfileBloc>(
|
||||
create: (context) =>
|
||||
MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))
|
||||
..add(MyProfileInitialEvent()),
|
||||
child: MyProfileScreen());
|
||||
create: (context) => MyProfileBloc(
|
||||
MyProfileState(
|
||||
myProfileModelObj: MyProfileModel(),
|
||||
),
|
||||
)..add(MyProfileInitialEvent()),
|
||||
child: MyProfileScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -50,92 +54,91 @@ class MyProfileScreen extends StatelessWidget {
|
||||
|
||||
_buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: 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,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildInfo(context, state)),
|
||||
SizedBox(height: 15.v),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildCarousel(context, state)),
|
||||
SizedBox(height: 15.v),
|
||||
if (!state.plans!.isEmpty)
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildPlans(
|
||||
context,
|
||||
state.plans
|
||||
?.map((plan) => plan['name'])
|
||||
.toList(),
|
||||
state.plans
|
||||
?.map((plan) => plan['image'])
|
||||
.toList(),
|
||||
state.plans
|
||||
?.map((plan) => plan['state'])
|
||||
.toList(),
|
||||
)),
|
||||
SizedBox(height: 5.v),
|
||||
])))),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
height: 0,
|
||||
),
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: 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,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildInfo(context, state),
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildCarousel(context, state)),
|
||||
SizedBox(height: 15.v),
|
||||
if (!state.plans!.isEmpty)
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _buildPlans(
|
||||
context,
|
||||
state.plans?.map((plan) => plan['name']).toList(),
|
||||
state.plans?.map((plan) => plan['image']).toList(),
|
||||
state.plans?.map((plan) => plan['state']).toList(),
|
||||
)),
|
||||
SizedBox(height: 5.v),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
@@ -145,8 +148,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
GestureDetector(
|
||||
onTap: () => addImage(context),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.user?['profile_photo_path'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.user?['profile_photo_path'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 60,
|
||||
@@ -184,10 +186,6 @@ class MyProfileScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
_buildCarousel(BuildContext contex, MyProfileLoadedState state) {
|
||||
return CarouselSlider(
|
||||
options: CarouselOptions(height: 320.0),
|
||||
@@ -208,12 +206,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
SizedBox(height: 50.v),
|
||||
_buildChart(
|
||||
context,
|
||||
state.chartPoints?.values
|
||||
.map<int>((e) => e['weight'])
|
||||
.toList()
|
||||
.map((i) => i.toDouble())
|
||||
.toList() ??
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
state.chartPoints?.values.map<int>((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0],
|
||||
state.chartDates,
|
||||
)
|
||||
]));
|
||||
@@ -228,13 +221,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
SizedBox(height: 50.v),
|
||||
_buildChart(
|
||||
context,
|
||||
_bodyMassIndex(
|
||||
state.chartPoints?.values
|
||||
.map<int>((e) => e['weight'])
|
||||
.toList()
|
||||
.map((i) => i.toDouble())
|
||||
.toList() ??
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
_bodyMassIndex(state.chartPoints?.values.map<int>((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0],
|
||||
state.userDetails?['height'].toInt() ?? 160),
|
||||
state.chartDates),
|
||||
]);
|
||||
@@ -249,8 +236,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30.v),
|
||||
_buildCircumferenceChart(
|
||||
context, state.circumferences, state.chartDates),
|
||||
_buildCircumferenceChart(context, state.circumferences, state.chartDates),
|
||||
_buildChartLegend()
|
||||
]));
|
||||
default:
|
||||
@@ -294,8 +280,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildChart(
|
||||
BuildContext context, List<double> chartPoints, List<String>? dates) {
|
||||
_buildChart(BuildContext context, List<double> chartPoints, List<String>? dates) {
|
||||
List<FlSpot> spots = [];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
spots.add(
|
||||
@@ -303,8 +288,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget bottomTitleWidgets(
|
||||
double value, TitleMeta meta, double chartWidth, List<String>? dates) {
|
||||
Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List<String>? dates) {
|
||||
if (value % 1 != 0) {
|
||||
return Container();
|
||||
}
|
||||
@@ -316,8 +300,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
int index = value.toInt();
|
||||
if (index >= 0 && index < dates!.length) {
|
||||
// Проверка на допустимый индекс в массиве dates
|
||||
String formattedDate =
|
||||
DateFormat('dd.MM').format(DateTime.parse(dates[index]));
|
||||
String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index]));
|
||||
return SideTitleWidget(
|
||||
axisSide: meta.axisSide,
|
||||
space: 16,
|
||||
@@ -374,18 +357,15 @@ class MyProfileScreen extends StatelessWidget {
|
||||
dotData: const FlDotData(show: false),
|
||||
),
|
||||
],
|
||||
minY: chartPoints.reduce(
|
||||
(value, element) => value < element ? value : element),
|
||||
maxY: chartPoints.reduce(
|
||||
(value, element) => value > element ? value : element),
|
||||
minY: chartPoints.reduce((value, element) => value < element ? value : element),
|
||||
maxY: chartPoints.reduce((value, element) => value > element ? value : element),
|
||||
minX: 1,
|
||||
maxX: 4,
|
||||
titlesData: FlTitlesData(
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTitlesWidget: (value, meta) =>
|
||||
leftTitleWidgets(value, meta, constraints.maxWidth),
|
||||
getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth),
|
||||
reservedSize: 56,
|
||||
),
|
||||
drawBelowEverything: true,
|
||||
@@ -396,8 +376,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTitlesWidget: (value, meta) => bottomTitleWidgets(
|
||||
value, meta, constraints.maxWidth, dates),
|
||||
getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates),
|
||||
reservedSize: 36,
|
||||
interval: 1,
|
||||
),
|
||||
@@ -457,11 +436,9 @@ class MyProfileScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildCircumferenceChart(
|
||||
BuildContext context, chartPoints, List<String>? dates) {
|
||||
_buildCircumferenceChart(BuildContext context, chartPoints, List<String>? dates) {
|
||||
// Определение осей графика
|
||||
final chestCircumferences =
|
||||
chartPoints.values.map((e) => e['chest_circumference']).toList();
|
||||
final chestCircumferences = chartPoints.values.map((e) => e['chest_circumference']).toList();
|
||||
List<FlSpot> spotsChest = [];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
chestCircumferences[i] = chestCircumferences[i] * 10 / 10;
|
||||
@@ -469,8 +446,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
FlSpot((i * 10 / 10) + 1, chestCircumferences[i] * 10 / 10),
|
||||
);
|
||||
}
|
||||
final waistCircumferences =
|
||||
chartPoints.values.map((e) => e['waist_circumference']).toList();
|
||||
final waistCircumferences = chartPoints.values.map((e) => e['waist_circumference']).toList();
|
||||
List<FlSpot> spotsWaist = [];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
waistCircumferences[i] = waistCircumferences[i] * 10 / 10;
|
||||
@@ -478,8 +454,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
FlSpot((i * 10 / 10) + 1, waistCircumferences[i] * 10 / 10),
|
||||
);
|
||||
}
|
||||
final hipCircumferences =
|
||||
chartPoints.values.map((e) => e['hip_circumference']).toList();
|
||||
final hipCircumferences = chartPoints.values.map((e) => e['hip_circumference']).toList();
|
||||
List<FlSpot> spotsHip = [];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
hipCircumferences[i] = hipCircumferences[i] * 10 / 10;
|
||||
@@ -488,14 +463,9 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
final allCircumferences = [
|
||||
...chestCircumferences,
|
||||
...hipCircumferences,
|
||||
...waistCircumferences
|
||||
];
|
||||
final allCircumferences = [...chestCircumferences, ...hipCircumferences, ...waistCircumferences];
|
||||
|
||||
Widget bottomTitleWidgets(
|
||||
double value, TitleMeta meta, double chartWidth, List<String>? dates) {
|
||||
Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List<String>? dates) {
|
||||
if (value % 1 != 0) {
|
||||
return Container();
|
||||
}
|
||||
@@ -507,8 +477,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
int index = value.toInt();
|
||||
if (index >= 0 && index < dates!.length) {
|
||||
// Проверка на допустимый индекс в массиве dates
|
||||
String formattedDate =
|
||||
DateFormat('dd.MM').format(DateTime.parse(dates[index]));
|
||||
String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index]));
|
||||
return SideTitleWidget(
|
||||
axisSide: meta.axisSide,
|
||||
space: 16,
|
||||
@@ -587,18 +556,15 @@ class MyProfileScreen extends StatelessWidget {
|
||||
dotData: const FlDotData(show: false),
|
||||
),
|
||||
],
|
||||
minY: allCircumferences.reduce(
|
||||
(value, element) => value < element ? value : element),
|
||||
maxY: allCircumferences.reduce(
|
||||
(value, element) => value > element ? value : element),
|
||||
minY: allCircumferences.reduce((value, element) => value < element ? value : element),
|
||||
maxY: allCircumferences.reduce((value, element) => value > element ? value : element),
|
||||
minX: 1,
|
||||
maxX: 4,
|
||||
titlesData: FlTitlesData(
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTitlesWidget: (value, meta) =>
|
||||
leftTitleWidgets(value, meta, constraints.maxWidth),
|
||||
getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth),
|
||||
reservedSize: 56,
|
||||
),
|
||||
drawBelowEverything: true,
|
||||
@@ -609,8 +575,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTitlesWidget: (value, meta) => bottomTitleWidgets(
|
||||
value, meta, constraints.maxWidth, dates),
|
||||
getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates),
|
||||
reservedSize: 36,
|
||||
interval: 1,
|
||||
),
|
||||
@@ -665,125 +630,80 @@ class MyProfileScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildPlans(BuildContext context, List<dynamic>? plans,
|
||||
List<dynamic>? imagePaths, List<dynamic>? states) {
|
||||
_buildPlans(BuildContext context, List<dynamic>? plans, List<dynamic>? imagePaths, List<dynamic>? states) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 7.h),
|
||||
child: Column(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 15.h),
|
||||
child: Text("plans_complete".tr,
|
||||
style: CustomTextStyles.titleMediumBlack
|
||||
.copyWith(color: appTheme.black900))),
|
||||
child: Text("plans_complete".tr, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900))),
|
||||
SizedBox(height: 5.v),
|
||||
Container(
|
||||
decoration: AppDecoration.outlineBlueGray
|
||||
.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 105.v,
|
||||
width: 343.h,
|
||||
child:
|
||||
Stack(alignment: Alignment.bottomCenter, children: [
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ListView.builder(
|
||||
itemCount: plans?.length ?? 0,
|
||||
itemBuilder: (context, i) {
|
||||
String state = states?[i];
|
||||
var boxColor = appTheme.greenA700;
|
||||
switch (states?[i]) {
|
||||
case 'active':
|
||||
boxColor = appTheme.greenA700;
|
||||
break;
|
||||
case 'archived': // График ИМТ
|
||||
boxColor = appTheme.gray400;
|
||||
break;
|
||||
case 'draft':
|
||||
boxColor = appTheme.deepOrange900;
|
||||
break;
|
||||
case 'in_progress': //График обхватов
|
||||
boxColor = appTheme.lightGreen300;
|
||||
break;
|
||||
}
|
||||
return SizedBox(
|
||||
height: 40.v,
|
||||
width: 343.h,
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
Align(
|
||||
alignment:
|
||||
Alignment.topCenter,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
bottom: 11.v),
|
||||
padding:
|
||||
EdgeInsets.symmetric(
|
||||
horizontal: 6.h,
|
||||
vertical: 4.v),
|
||||
decoration: AppDecoration
|
||||
.fillGray
|
||||
.copyWith(
|
||||
borderRadius:
|
||||
BorderRadiusStyle
|
||||
.roundedBorder5),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets
|
||||
.only(
|
||||
bottom: 1
|
||||
.v),
|
||||
child: Text(
|
||||
plans![i],
|
||||
style: CustomTextStyles
|
||||
.titleSmallBluegray800Bold)),
|
||||
Container(
|
||||
height: 19.v,
|
||||
width: 100.h,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
boxColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
5.h)))
|
||||
]))),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
bottom: 12.h),
|
||||
child: Image.network(
|
||||
dotenv.env[
|
||||
'STORAGE_URL']! +
|
||||
imagePaths?[i],
|
||||
height: 25.adaptSize,
|
||||
width: 25.adaptSize,
|
||||
))),
|
||||
Align(
|
||||
alignment:
|
||||
Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 70.h,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: 14.h,
|
||||
right: 22.h),
|
||||
child: Text("$state".tr,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow
|
||||
.ellipsis,
|
||||
style: theme.textTheme
|
||||
.titleSmall)))
|
||||
]));
|
||||
})),
|
||||
]))
|
||||
]))
|
||||
decoration: AppDecoration.outlineBlueGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
SizedBox(
|
||||
height: 105.v,
|
||||
width: 343.h,
|
||||
child: Stack(alignment: Alignment.bottomCenter, children: [
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ListView.builder(
|
||||
itemCount: plans?.length ?? 0,
|
||||
itemBuilder: (context, i) {
|
||||
String state = states?[i];
|
||||
var boxColor = appTheme.greenA700;
|
||||
switch (states?[i]) {
|
||||
case 'active':
|
||||
boxColor = appTheme.greenA700;
|
||||
break;
|
||||
case 'archived': // График ИМТ
|
||||
boxColor = appTheme.gray400;
|
||||
break;
|
||||
case 'draft':
|
||||
boxColor = appTheme.deepOrange900;
|
||||
break;
|
||||
case 'in_progress': //График обхватов
|
||||
boxColor = appTheme.lightGreen300;
|
||||
break;
|
||||
}
|
||||
return SizedBox(
|
||||
height: 40.v,
|
||||
width: 343.h,
|
||||
child: Stack(alignment: Alignment.bottomRight, children: [
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(bottom: 11.v),
|
||||
padding: EdgeInsets.symmetric(horizontal: 6.h, vertical: 4.v),
|
||||
decoration: AppDecoration.fillGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 1.v),
|
||||
child: Text(plans![i], style: CustomTextStyles.titleSmallBluegray800Bold)),
|
||||
Container(
|
||||
height: 19.v,
|
||||
width: 100.h,
|
||||
decoration: BoxDecoration(color: boxColor, borderRadius: BorderRadius.circular(5.h)))
|
||||
]))),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(bottom: 12.h),
|
||||
child: Image.network(
|
||||
dotenv.env['STORAGE_URL']! + imagePaths?[i],
|
||||
height: 25.adaptSize,
|
||||
width: 25.adaptSize,
|
||||
))),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 70.h,
|
||||
margin: EdgeInsets.only(bottom: 14.h, right: 22.h),
|
||||
child: Text("$state".tr, maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall)))
|
||||
]));
|
||||
})),
|
||||
]))
|
||||
]))
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -811,44 +731,38 @@ class MyProfileScreen extends StatelessWidget {
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 5.v),
|
||||
child: Text("chest_circumference".tr,
|
||||
style: theme.textTheme.bodyLarge),
|
||||
child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge),
|
||||
),
|
||||
SizedBox(height: 5.v),
|
||||
CustomTextFormField(
|
||||
controller: state.chestCircumferenceController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly, // Ограничение ввода только цифрами
|
||||
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.v),
|
||||
child: Text("waist_circumference".tr,
|
||||
style: theme.textTheme.bodyLarge),
|
||||
child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge),
|
||||
),
|
||||
SizedBox(height: 5.v),
|
||||
CustomTextFormField(
|
||||
controller: state.waistCircumferenceController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly, // Ограничение ввода только цифрами
|
||||
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.v),
|
||||
child: Text("hip_circumference".tr,
|
||||
style: theme.textTheme.bodyLarge),
|
||||
child: Text("hip_circumference".tr, style: theme.textTheme.bodyLarge),
|
||||
),
|
||||
SizedBox(height: 5.v),
|
||||
CustomTextFormField(
|
||||
controller: state.hipCircumferenceController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly, // Ограничение ввода только цифрами
|
||||
FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -867,8 +781,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
backgroundColor: Colors.white,
|
||||
titlePadding: EdgeInsets.all(
|
||||
20.0), // Можете настроить отступы по вашему желанию
|
||||
titlePadding: EdgeInsets.all(20.0), // Можете настроить отступы по вашему желанию
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -904,8 +817,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
// Ошибка от сервера
|
||||
print(
|
||||
"Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
// Обработка ошибок при отправке запроса
|
||||
@@ -997,8 +909,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
// Ошибка от сервера
|
||||
print(
|
||||
"Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
// Обработка ошибок при отправке запроса
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/my_profile_bloc.dart';
|
||||
import 'models/my_profile_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_about_list.dart';
|
||||
import 'package:eatvio_app/widgets/custom_expandable_list.dart';
|
||||
import 'package:eatvio_app/widgets/custom_notification_screen.dart';
|
||||
@@ -15,10 +16,7 @@ import 'package:flutter/material.dart';
|
||||
class MySettingsScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<MyProfileBloc>(
|
||||
create: (context) =>
|
||||
MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))
|
||||
..add(MyProfileInitialEvent()),
|
||||
child: MySettingsScreen());
|
||||
create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent()), child: MySettingsScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -42,136 +40,125 @@ class MySettingsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildSetingsScreen(BuildContext context, MyProfileLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 30),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 30),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: onTapBack(context)),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(children: [
|
||||
AppbarSubtitle(
|
||||
text: state.user?['name'],
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v))
|
||||
])),
|
||||
)),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Язык'),
|
||||
LanguageDropdown(),
|
||||
],
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v))])),
|
||||
)),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Уведомления'),
|
||||
NotificationSwitch('Уведомление об обновлениях'),
|
||||
NotificationSwitch('Напоминания о заполнении'),
|
||||
],
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Дополнительная информация'),
|
||||
ExpandableList('Персональные данные'),
|
||||
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Язык'),
|
||||
LanguageDropdown(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Уведомления'),
|
||||
NotificationSwitch('Уведомление об обновлениях'),
|
||||
NotificationSwitch('Напоминания о заполнении'),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionTitle('Дополнительная информация'),
|
||||
ExpandableList('Персональные данные'),
|
||||
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -182,10 +169,6 @@ class MySettingsScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
@@ -5,18 +5,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
|
||||
class RecipeCreateScreen extends StatelessWidget {
|
||||
const RecipeCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final recipeID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<RecipeCreateBloc>(
|
||||
create: (context) => RecipeCreateBloc(RecipeCreateState(
|
||||
recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))
|
||||
..add(RecipeCreateInitialEvent()),
|
||||
create: (context) =>
|
||||
RecipeCreateBloc(RecipeCreateState(recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))..add(RecipeCreateInitialEvent()),
|
||||
child: RecipeCreateScreen());
|
||||
}
|
||||
|
||||
@@ -52,25 +51,28 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: ListView(children: [
|
||||
_buldAppBar(context),
|
||||
SizedBox(height: 20.v),
|
||||
_buildRecipeInfo(state, context),
|
||||
SizedBox(height: 20.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildAdditional(context, state)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: ListView(
|
||||
children: [
|
||||
_buldAppBar(context),
|
||||
SizedBox(height: 20.v),
|
||||
_buildRecipeInfo(state, context),
|
||||
SizedBox(height: 20.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildAdditional(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buldAppBar(BuildContext context) {
|
||||
@@ -337,9 +339,7 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text("Ссылка на видео (необязательно)")),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
hintText: "YouTube",
|
||||
@@ -361,10 +361,6 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) {
|
||||
);
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
|
||||
@@ -2,18 +2,16 @@ import 'bloc/recipe_edit_bloc.dart';
|
||||
import 'models/recipe_edit_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.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<RecipeEditBloc>(
|
||||
create: (context) => RecipeEditBloc(RecipeEditState(
|
||||
recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))
|
||||
..add(RecipeEditInitialEvent()),
|
||||
create: (context) => RecipeEditBloc(RecipeEditState(recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))..add(RecipeEditInitialEvent()),
|
||||
child: RecipeEditScreen());
|
||||
}
|
||||
|
||||
@@ -42,42 +40,43 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
_buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.recipe?['image'] ?? ''),
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
@@ -102,18 +101,16 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<RecipeEditBloc>().add(EditRecipe()),
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(EditRecipe()),
|
||||
child: Text('Сохранить'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/recipe_select_bloc.dart';
|
||||
import 'models/recipe_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -39,75 +40,71 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildRecipeScreen(BuildContext context, RecipeSelectLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: onTapBack(context),
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Рецепты",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CustomAppBar(
|
||||
height: 54.v,
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Рецепты",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeCreateScreen,
|
||||
),
|
||||
child: Icon(Icons.create_outlined)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildRecipeList(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
_buildRecipeList(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -174,10 +171,6 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
@@ -2,18 +2,16 @@ import 'bloc/recipe_show_bloc.dart';
|
||||
import 'models/recipe_show_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class RecipeScreen extends StatelessWidget {
|
||||
const RecipeScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final recipeID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<RecipeBloc>(
|
||||
create: (context) => RecipeBloc(RecipeState(
|
||||
recipeModelObj: RecipeModel(recipeID: recipeID.toString())))
|
||||
..add(RecipeInitialEvent()),
|
||||
create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()),
|
||||
child: RecipeScreen());
|
||||
}
|
||||
|
||||
@@ -42,90 +40,74 @@ class RecipeScreen extends StatelessWidget {
|
||||
_buildRecipe(BuildContext context, RecipeLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.recipe?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.recipe?['title'], style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.recipe?['description'],
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pushNamed(context, AppRoutes.recipeEditScreen, arguments: state.recipe?['id'].toString()),
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.recipe?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.recipe?['description'],
|
||||
ElevatedButton(
|
||||
onPressed: () => context.read<RecipeBloc>().add(DeleteEntry(state.recipe?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context, AppRoutes.recipeEditScreen,
|
||||
arguments: state.recipe?['id'].toString()),
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => context
|
||||
.read<RecipeBloc>()
|
||||
.add(DeleteEntry(state.recipe?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
)
|
||||
]),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
case BottomBarEnum.tf:
|
||||
return AppRoutes.recipeScreen;
|
||||
default:
|
||||
return "/";
|
||||
}
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling page based on route
|
||||
@@ -141,10 +123,6 @@ class RecipeScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
|
||||
@@ -9,97 +9,104 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class LanguageSelectScreen extends StatelessWidget {
|
||||
const LanguageSelectScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<LanguageSelectBloc>(
|
||||
create: (context) => LanguageSelectBloc(
|
||||
LanguageSelectState(languageSelectModelObj: LanguageSelectModel()))
|
||||
..add(LanguageSelectInitialEvent()),
|
||||
child: LanguageSelectScreen());
|
||||
create: (context) => LanguageSelectBloc(
|
||||
LanguageSelectState(
|
||||
languageSelectModelObj: LanguageSelectModel(),
|
||||
),
|
||||
)..add(LanguageSelectInitialEvent()),
|
||||
child: LanguageSelectScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v),
|
||||
child: Column(children: [
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgLogoEatvio,
|
||||
height: 50.adaptSize,
|
||||
width: 50.adaptSize),
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
width: 343.h,
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v),
|
||||
child: Column(
|
||||
children: [
|
||||
CustomImageView(imagePath: ImageConstant.imgLogoEatvio, height: 50.adaptSize, width: 50.adaptSize),
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
width: 343.h,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary,
|
||||
width: 1.h,
|
||||
),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
width: 262.h,
|
||||
margin: EdgeInsets.only(left: 41.h, right: 39.h),
|
||||
child: Text(
|
||||
"preferred_language".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
Spacer(flex: 36),
|
||||
BlocSelector<LanguageSelectBloc, LanguageSelectState, LanguageSelectModel?>(
|
||||
selector: (state) => state.languageSelectModelObj,
|
||||
builder: (
|
||||
context,
|
||||
languageSelectModelObj,
|
||||
) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary, width: 1.h)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
appTheme.blueA400)))),
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
width: 262.h,
|
||||
margin: EdgeInsets.only(left: 41.h, right: 39.h),
|
||||
child: Text("preferred_language".tr,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.headlineSmall)),
|
||||
Spacer(flex: 36),
|
||||
BlocSelector<LanguageSelectBloc, LanguageSelectState,
|
||||
LanguageSelectModel?>(
|
||||
selector: (state) => state.languageSelectModelObj,
|
||||
builder: (
|
||||
context,
|
||||
languageSelectModelObj,
|
||||
) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(1.h),
|
||||
),
|
||||
child: CustomImageView(
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize,
|
||||
),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: languageSelectModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) =>
|
||||
_onDropDownChanged(context, value),
|
||||
);
|
||||
}),
|
||||
Spacer(flex: 63),
|
||||
])),
|
||||
bottomNavigationBar:
|
||||
BlocBuilder<LanguageSelectBloc, LanguageSelectState>(
|
||||
builder: (context, state) {
|
||||
return NextStepButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
margin:
|
||||
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: _saveAndPush(state, context));
|
||||
})));
|
||||
borderRadius: BorderRadius.circular(1.h),
|
||||
),
|
||||
child: CustomImageView(
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize,
|
||||
),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: languageSelectModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) => _onDropDownChanged(context, value),
|
||||
);
|
||||
}),
|
||||
Spacer(flex: 63),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: BlocBuilder<LanguageSelectBloc, LanguageSelectState>(
|
||||
builder: (context, state) {
|
||||
return NextStepButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: _saveAndPush(state, context),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void Function()? _saveAndPush(
|
||||
LanguageSelectState state, BuildContext context) {
|
||||
void Function()? _saveAndPush(LanguageSelectState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.languageSelectModelObj!.userRegistrationSheet;
|
||||
UserRegistrationSheet sheet = state.languageSelectModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.credentialsScreen,
|
||||
|
||||
@@ -35,7 +35,6 @@ import 'package:eatvio_app/presentation/plans/plan_show_screen/plan_show_screen.
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_show_screen/recipe_show_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_create_screen/recipe_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart';
|
||||
@@ -198,8 +197,8 @@ class AppRoutes {
|
||||
planCreateScreen: (context) =>
|
||||
_buildFadeRoute(context, PlanCreateScreen.builder),
|
||||
feedScreen: (context) => _buildFadeRoute(context, FeedScreen.builder),
|
||||
blogPostScreen: (context) =>
|
||||
_buildFadeRoute(context, BlogPostScreen.builder),
|
||||
// blogPostScreen: (context) =>
|
||||
// _buildFadeRoute(context, BlogPostScreen.builder),
|
||||
blogPostEditScreen: (context) =>
|
||||
_buildFadeRoute(context, BlogPostEditScreen.builder),
|
||||
blogPostCreateScreen: (context) =>
|
||||
|
||||
@@ -16,7 +16,7 @@ class CustomButtonStyles {
|
||||
);
|
||||
// text button style
|
||||
static ButtonStyle get none => ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all<Color>(Colors.transparent),
|
||||
elevation: MaterialStateProperty.all<double>(0),
|
||||
backgroundColor: WidgetStateProperty.all<Color>(Colors.transparent),
|
||||
elevation: WidgetStateProperty.all<double>(0),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@@ -30,7 +31,10 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
elevation: 0,
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarBrightness: Brightness.light,
|
||||
),
|
||||
toolbarHeight: height ?? 56.v,
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
||||
134
lib/widgets/bottom_navigation_bar_widget.dart
Normal file
134
lib/widgets/bottom_navigation_bar_widget.dart
Normal file
@@ -0,0 +1,134 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
int currentBottomNavBarIndex = 0;
|
||||
|
||||
class BottomNavigationBarWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const BottomNavigationBarWidget({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BottomNavigationBarWidget> createState() => _BottomNavigationBarWidgetState();
|
||||
}
|
||||
|
||||
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
void _onItemTapped(int index) {
|
||||
if (currentBottomNavBarIndex != index) {
|
||||
setState(() {
|
||||
currentBottomNavBarIndex = index;
|
||||
});
|
||||
}
|
||||
switch (currentBottomNavBarIndex) {
|
||||
case 0:
|
||||
GoRouter.of(context).replace('/my-profile-screen');
|
||||
break;
|
||||
case 1:
|
||||
GoRouter.of(context).replace('/feed-screen');
|
||||
break;
|
||||
case 2:
|
||||
GoRouter.of(context).replace('/diary-screen');
|
||||
break;
|
||||
case 3:
|
||||
GoRouter.of(context).replace('/chat-select-screen');
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final size = overlay.size;
|
||||
showMenu(
|
||||
context: context,
|
||||
color: Colors.white,
|
||||
shadowColor: Colors.white,
|
||||
surfaceTintColor: Colors.white,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
child: CustomNavigationMenu(),
|
||||
)
|
||||
],
|
||||
position: RelativeRect.fromLTRB(size.width, size.height, 0, 0),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: widget.child,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: _onItemTapped,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
selectedItemColor: appTheme.blueA400,
|
||||
currentIndex: currentBottomNavBarIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgLogo),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Лента',
|
||||
icon: SvgPicture.asset(ImageConstant.imgFeed),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgFeed,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "diary".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgDiary),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgChat),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgBell),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: Image.asset(
|
||||
ImageConstant.imgEllipse1,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_title_circleimage.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomBottomBar extends StatefulWidget {
|
||||
CustomBottomBar({this.onChanged});
|
||||
|
||||
Function(BottomBarEnum)? onChanged;
|
||||
|
||||
@override
|
||||
CustomBottomBarState createState() => CustomBottomBarState();
|
||||
}
|
||||
|
||||
class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
int selectedIndex = 2;
|
||||
|
||||
List<BottomMenuModel> bottomMenuList = [
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgLogo,
|
||||
activeIcon: ImageConstant.imgLogo,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgFeed,
|
||||
activeIcon: ImageConstant.imgFeed,
|
||||
title: "Лента",
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgDiary,
|
||||
activeIcon: ImageConstant.imgDiary,
|
||||
title: "diary".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgChat,
|
||||
activeIcon: ImageConstant.imgChat,
|
||||
title: "chat".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgBell,
|
||||
activeIcon: ImageConstant.imgBell,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgEllipse1,
|
||||
activeIcon: ImageConstant.imgEllipse1,
|
||||
type: BottomBarEnum.tf,
|
||||
image: true,
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 83.v,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: appTheme.whiteA700,
|
||||
width: 1.h,
|
||||
),
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
showSelectedLabels: false,
|
||||
showUnselectedLabels: false,
|
||||
selectedFontSize: 0,
|
||||
elevation: 0,
|
||||
currentIndex: selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: List.generate(bottomMenuList.length, bottomMenu),
|
||||
onTap: changeMeny,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void changeMeny(index) {
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.pushNamed(context, AppRoutes.myProfile);
|
||||
break;
|
||||
case 1:
|
||||
Navigator.pushNamed(context, AppRoutes.feedScreen);
|
||||
break;
|
||||
case 2:
|
||||
Navigator.pushNamed(context, AppRoutes.diaryEdit);
|
||||
break;
|
||||
case 3:
|
||||
Navigator.pushNamed(context, AppRoutes.chatSelectScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BottomNavigationBarItem bottomMenu(index) {
|
||||
bool isSelected = selectedIndex == index;
|
||||
|
||||
double iconHeight;
|
||||
double iconWidth;
|
||||
|
||||
if (index == 0) {
|
||||
// Для логотипа-
|
||||
iconHeight = 52.v; // Увеличиваем высоту
|
||||
iconWidth = 48.h; // Меняем ширину, чтобы сохранить пропорции
|
||||
} else if (index == bottomMenuList.length - 2) {
|
||||
// Для колокольчика
|
||||
iconHeight = 20.v; // Уменьшаем высоту
|
||||
iconWidth = 20.h; // Меняем ширину, чтобы сохранить пропорции
|
||||
} else if (index == bottomMenuList.length - 1) {
|
||||
// Для колокольчика
|
||||
iconHeight = 40.v; // Уменьшаем высоту
|
||||
iconWidth = 40.h; // Меняем ширину, чтобы сохранить пропорции
|
||||
} else {
|
||||
// Для остальных иконок
|
||||
iconHeight = 24.v; // Стандартная высота
|
||||
iconWidth = 19.h; // Стандартная ширина
|
||||
}
|
||||
|
||||
return BottomNavigationBarItem(
|
||||
icon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
if (!bottomMenuList[index].image)
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].icon,
|
||||
height: iconHeight,
|
||||
width: iconWidth,
|
||||
color:
|
||||
isSelected ? theme.colorScheme.primary : appTheme.blueGray400,
|
||||
),
|
||||
if (bottomMenuList[index].image)
|
||||
GestureDetector(
|
||||
onTap: () => showMenu(
|
||||
context: context,
|
||||
color: Colors.white,
|
||||
shadowColor: Colors.white,
|
||||
surfaceTintColor: Colors.white,
|
||||
position: RelativeRect.fromLTRB(
|
||||
// Указываем позицию справа по центру
|
||||
MediaQuery.of(context).size.width -
|
||||
50, // Расположение от правого края
|
||||
kToolbarHeight + 340, // Расположение от верхнего края
|
||||
0, // Не смещаем по горизонтали
|
||||
0, // Не смещаем по вертикали
|
||||
),
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
child:
|
||||
CustomNavigationMenu(), // Используйте ваше меню здесь
|
||||
)
|
||||
],
|
||||
),
|
||||
child: AppbarTitleCircleimage(
|
||||
imagePath: ImageConstant.imgEllipse1,
|
||||
),
|
||||
),
|
||||
if (bottomMenuList[index].title !=
|
||||
null) // Проверяем, существует ли title
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title!,
|
||||
style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: appTheme.blueGray800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
activeIcon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].activeIcon,
|
||||
height: iconHeight, // Используем тот же размер для активной иконки
|
||||
width: iconWidth, // Используем тот же размер для активной иконки
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 9.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title ?? "",
|
||||
style: CustomTextStyles.bodySmallMulishPrimary.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
label: '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum BottomBarEnum {
|
||||
tf,
|
||||
}
|
||||
|
||||
class BottomMenuModel {
|
||||
BottomMenuModel({
|
||||
required this.icon,
|
||||
required this.activeIcon,
|
||||
this.title,
|
||||
required this.type,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
String icon;
|
||||
|
||||
String activeIcon;
|
||||
|
||||
String? title;
|
||||
|
||||
BottomBarEnum type;
|
||||
|
||||
bool image;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -16,33 +17,30 @@ class CustomNavigationMenu extends StatelessWidget {
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgSettings,
|
||||
text: 'Настройки профиля',
|
||||
onTap: () => Navigator.pushNamed(context, AppRoutes.mySettings),
|
||||
onTap: () => GoRouter.of(context).push('/my-settings-screen'),
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgRecipes,
|
||||
text: 'Мои рецепты',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.recipeSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgDiets,
|
||||
text: 'Мои диеты',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.dietSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/diet-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgPlans,
|
||||
text: 'Мои планы',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.planSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/plan-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgFinance,
|
||||
text: 'Глоссарий',
|
||||
onTap: () => Navigator.pushNamed(context, AppRoutes.glossaryScreen),
|
||||
onTap: () => GoRouter.of(context).push('/glossary-screen'),
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgSupport,
|
||||
@@ -77,10 +75,7 @@ _onTapLogout(BuildContext context) {
|
||||
if (response.statusCode == 204) {
|
||||
print(response.statusCode);
|
||||
box.delete('token'); // Удаляем токен из Hive
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
GoRouter.of(context).go('/auth-screen');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
name: eatvio_app
|
||||
description: A new Flutter project.
|
||||
version: 0.0.0+1
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
environment:
|
||||
sdk: '>=3.3.4 <4.0.0'
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
@@ -27,6 +27,8 @@ dependencies:
|
||||
image_picker: ^1.0.7
|
||||
flutter_typeahead: ^5.2.0
|
||||
bloc_test: ^9.1.6
|
||||
# navigation
|
||||
go_router: ^14.1.4
|
||||
|
||||
dev_dependencies:
|
||||
dart_code_metrics: ^5.7.6
|
||||
|
||||
@@ -16,10 +16,8 @@ void main() {
|
||||
);
|
||||
});*/
|
||||
|
||||
testWidgets('renders _buildDiaryEditScreen when in loaded state',
|
||||
(WidgetTester tester) async {
|
||||
final diaryEditBloc =
|
||||
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()));
|
||||
testWidgets('renders _buildDiaryEditScreen when in loaded state', (WidgetTester tester) async {
|
||||
final diaryEditBloc = DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()));
|
||||
final loadedState = DiaryEditLoadedState(
|
||||
diaryId: 1,
|
||||
selectedSatiety: 4,
|
||||
@@ -36,9 +34,7 @@ void main() {
|
||||
MaterialApp(
|
||||
home: BlocProvider<DiaryEditBloc>.value(
|
||||
value: diaryEditBloc,
|
||||
child: DiaryEditScreen(
|
||||
onInitialize: () {},
|
||||
),
|
||||
child: DiaryEditScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user