feat(feed): add diets api and create blog post screen, fix status bar

This commit is contained in:
mso7nueh
2024-08-08 10:39:53 +03:00
parent 21e03d956c
commit f4c6aebdff
67 changed files with 4253 additions and 1617 deletions

View File

@@ -1,7 +1,6 @@
import 'dart:io';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
@@ -51,68 +50,58 @@ class _BlogPostCreateScreenState extends State<BlogPostCreateScreen> {
_buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
appBar: AppBar(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: SizedBox(
width: MediaQuery.of(context).size.width - 32,
child: FloatingActionButton.extended(
heroTag: 'nextButtonRegistration',
highlightElevation: 0,
elevation: 0,
focusElevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
backgroundColor: appTheme.blueA400,
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtubeURL!.text),
label: Text(
'Создать',
style: theme.textTheme.titleSmall,
),
),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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,
),
SizedBox(height: 8.0),
Text("Ссылка на YouTube", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.youtubeURL,
validator: _validateYouTubeLink,
),
SizedBox(height: 8.0),
Text("Описание", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.description,
validator: _validateDescription,
maxLines: 6,
),
SizedBox(height: 16.0),
_buildAddPhoto(context, state),
SizedBox(height: 16.0),
// Add widget for image upload here
CustomOutlinedButton(
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtubeURL!.text),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
text: 'Создать',
),
],
),
],
),
Text('Заголовок'),
SizedBox(height: 8),
CustomTextFormField(
controller: state.title,
validator: _validateTitle,
),
SizedBox(height: 16),
Text('Описание'),
SizedBox(height: 8),
CustomTextFormField(
controller: state.description,
validator: _validateDescription,
maxLines: 6,
minLines: 1,
),
SizedBox(height: 16),
Text('Ссылка на видео'),
SizedBox(height: 8),
CustomTextFormField(
controller: state.youtubeURL,
validator: _validateYouTubeLink,
),
SizedBox(height: 16),
Text('Изображение поста'),
SizedBox(height: 8),
_buildAddPhoto(context, state),
SizedBox(height: 80),
],
),
),
@@ -145,47 +134,34 @@ _buildAddPhoto(BuildContext context, BlogPostCreateLoadedState state) {
children: [
if (state.image == null)
Container(
margin: EdgeInsets.symmetric(horizontal: 10.h),
padding: EdgeInsets.symmetric(
horizontal: 40.h,
vertical: 80.v,
),
height: 128,
decoration: AppDecoration.fillGray.copyWith(
borderRadius: BorderRadiusStyle.roundedBorder5,
borderRadius: BorderRadius.circular(16),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(
left: 7.h,
top: 5.v,
),
child: Text(
"Добавить фото",
selectionColor: appTheme.blueA400,
),
),
Spacer(),
Icon(
Icons.photo_library,
color: appTheme.blueGray300,
),
SizedBox(width: 8),
Text(
"Добавить фото",
selectionColor: appTheme.blueA400,
),
],
),
),
if (state.image != null)
Container(
margin: EdgeInsets.symmetric(horizontal: 10.h),
padding: EdgeInsets.symmetric(
horizontal: 40.h,
vertical: 80.v,
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image(
image: FileImage(
File(state.image!.path),
),
),
decoration: AppDecoration.fillGray.copyWith(
borderRadius: BorderRadiusStyle.roundedBorder5,
),
child: Image(image: FileImage(File(state.image!.path))),
)
],
),