forked from eatvio/eatvio_app
refactor(app): Native analysys and warning refactoring
This commit is contained in:
@@ -3,8 +3,6 @@ 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';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class DietCreateScreen extends StatelessWidget {
|
||||
const DietCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -101,64 +101,7 @@ class DietSelectScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['name'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['details'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
),
|
||||
_buildDietList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -169,6 +112,62 @@ class DietSelectScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildDietList(BuildContext context, DietSelectLoadedState state) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['name'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['details'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.dietEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
|
||||
@@ -2,10 +2,6 @@ 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/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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -124,48 +120,6 @@ class DietScreen extends StatelessWidget {
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAppbar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 26.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
top: 18.v,
|
||||
bottom: 25.v,
|
||||
),
|
||||
onTap: () => onTapArrowleftone(context),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 12.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarTitleImage(
|
||||
imagePath: ImageConstant.imgIconMoreHorizontal,
|
||||
margin: EdgeInsets.only(bottom: 3.v),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Валерий Леонтьев",
|
||||
),
|
||||
SizedBox(height: 3.v),
|
||||
Text("Был в сети вчера", style: theme.textTheme.bodySmall!)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
|
||||
@@ -3,8 +3,6 @@ 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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class BlogPostCreateScreen extends StatelessWidget {
|
||||
const BlogPostCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -2,11 +2,6 @@ import 'bloc/blog_post_bloc.dart';
|
||||
import 'models/blog_post_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -126,48 +121,6 @@ class BlogPostScreen extends StatelessWidget {
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAppbar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 26.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
top: 18.v,
|
||||
bottom: 25.v,
|
||||
),
|
||||
onTap: () => onTapArrowleftone(context),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 12.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarTitleImage(
|
||||
imagePath: ImageConstant.imgIconMoreHorizontal,
|
||||
margin: EdgeInsets.only(bottom: 3.v),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Валерий Леонтьев",
|
||||
),
|
||||
SizedBox(height: 3.v),
|
||||
Text("Был в сети вчера", style: theme.textTheme.bodySmall!)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
|
||||
@@ -100,64 +100,7 @@ class FeedScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
),
|
||||
_buildBlogPostList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -168,6 +111,62 @@ class FeedScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildBlogPostList(BuildContext context, FeedLoadedState state) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
|
||||
@@ -3,8 +3,6 @@ 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';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class PlanCreateScreen extends StatelessWidget {
|
||||
const PlanCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -101,64 +101,7 @@ class PlanSelectScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['name'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['details'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
),
|
||||
_buildPlanList(context, state)
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -169,6 +112,62 @@ class PlanSelectScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildPlanList(BuildContext context, PlanSelectLoadedState state) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['name'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['details'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.planEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
|
||||
@@ -2,10 +2,6 @@ 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/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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -122,47 +118,6 @@ class PlanScreen extends StatelessWidget {
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAppbar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 26.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
top: 18.v,
|
||||
bottom: 25.v,
|
||||
),
|
||||
onTap: () => onTapArrowleftone(context),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 12.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarTitleImage(
|
||||
imagePath: ImageConstant.imgIconMoreHorizontal,
|
||||
margin: EdgeInsets.only(bottom: 3.v),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Валерий Леонтьев",
|
||||
),
|
||||
SizedBox(height: 3.v),
|
||||
Text("Был в сети вчера", style: theme.textTheme.bodySmall!)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
|
||||
@@ -3,8 +3,6 @@ import 'models/recipe_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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class RecipeCreateScreen extends StatelessWidget {
|
||||
const RecipeCreateScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -101,64 +101,7 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
),
|
||||
_buildRecipeList(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -169,6 +112,62 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildRecipeList(BuildContext context, RecipeSelectLoadedState state) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true, // Add this line
|
||||
itemCount: state.posts?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.recipeEditScreen,
|
||||
arguments: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit)),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Function onTapBack(BuildContext context) {
|
||||
return () {
|
||||
onTapArrowLeft(context);
|
||||
|
||||
@@ -2,10 +2,6 @@ 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/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:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -122,48 +118,6 @@ class RecipeScreen extends StatelessWidget {
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAppbar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 26.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
top: 18.v,
|
||||
bottom: 25.v,
|
||||
),
|
||||
onTap: () => onTapArrowleftone(context),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 12.h),
|
||||
child: Row(
|
||||
children: [
|
||||
AppbarTitleImage(
|
||||
imagePath: ImageConstant.imgIconMoreHorizontal,
|
||||
margin: EdgeInsets.only(bottom: 3.v),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Валерий Леонтьев",
|
||||
),
|
||||
SizedBox(height: 3.v),
|
||||
Text("Был в сети вчера", style: theme.textTheme.bodySmall!)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///Handling route based on bottom click actions
|
||||
String getCurrentRoute(BottomBarEnum type) {
|
||||
switch (type) {
|
||||
|
||||
Reference in New Issue
Block a user