go router full

This commit is contained in:
mso7nueh
2024-06-06 16:02:39 +03:00
parent 7b55204659
commit 647e9e9133
42 changed files with 483 additions and 1018 deletions

View File

@@ -13,10 +13,7 @@ import 'package:flutter/material.dart';
class PlanSelectScreen extends StatelessWidget {
static Widget builder(BuildContext context) {
return BlocProvider<PlanSelectBloc>(
create: (context) => PlanSelectBloc(
PlanSelectState(myProfileModelObj: PlanSelectModel()))
..add(PlanSelectInitialEvent()),
child: PlanSelectScreen());
create: (context) => PlanSelectBloc(PlanSelectState(myProfileModelObj: PlanSelectModel()))..add(PlanSelectInitialEvent()), child: PlanSelectScreen());
}
Widget build(BuildContext context) {
@@ -80,8 +77,7 @@ class PlanSelectScreen extends StatelessWidget {
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
title: Padding(
@@ -90,18 +86,15 @@ class PlanSelectScreen extends StatelessWidget {
children: [
AppbarSubtitle(
text: "Планы",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
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)),
onTap: () => GoRouter.of(context).goNamed('planCreateScreen'),
child: Icon(Icons.create_outlined),
),
)
],
),
@@ -125,51 +118,51 @@ class PlanSelectScreen extends StatelessWidget {
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),
),
],
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,
),
),
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: () => GoRouter.of(context).goNamed(
'planScreen',
extra: post?['id'].toString(),
),
trailing: GestureDetector(
onTap: () => GoRouter.of(context).goNamed(
'planEditScreen',
extra: post?['id'].toString(),
),
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)),
));
child: Icon(Icons.edit),
),
),
);
},
);
}