forked from eatvio/eatvio_app
feat(profile): send message and subscribe button
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/sub_cubit/sub_cubit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
enum SubActionType { SendMessage, Subscribe }
|
||||
|
||||
class SubActionButtonWidget extends StatefulWidget {
|
||||
final SubActionType subActionType;
|
||||
final String slug;
|
||||
|
||||
const SubActionButtonWidget({
|
||||
super.key,
|
||||
required this.subActionType,
|
||||
required this.slug,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -16,11 +23,24 @@ class SubActionButtonWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SubActionButtonWidgetState extends State<SubActionButtonWidget> {
|
||||
late SubActionType subActionType;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
subActionType = widget.subActionType;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.subActionType == SubActionType.Subscribe) {
|
||||
if (subActionType == SubActionType.Subscribe) {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
context.read<SubCubit>().subscribe(widget.slug);
|
||||
setState(() {
|
||||
subActionType = SubActionType.SendMessage;
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
@@ -40,7 +60,12 @@ class _SubActionButtonWidgetState extends State<SubActionButtonWidget> {
|
||||
);
|
||||
} else {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
onTap: () async {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
extra: await sl<ProfileCubit>().getChatRoomIdBySlug(slug: widget.slug),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/sub_action_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class SubWidget extends StatefulWidget {
|
||||
final SubModel subModel;
|
||||
@@ -18,7 +20,15 @@ class _SubWidgetState extends State<SubWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'profileScreen',
|
||||
extra: Author(
|
||||
authorSlug: widget.subModel.slug,
|
||||
authorName: widget.subModel.name,
|
||||
authorProfileIcon: widget.subModel.profilePhotoUrl,
|
||||
authorIsMe: false,
|
||||
),
|
||||
),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: Row(
|
||||
@@ -56,6 +66,7 @@ class _SubWidgetState extends State<SubWidget> {
|
||||
const Spacer(),
|
||||
SubActionButtonWidget(
|
||||
subActionType: widget.subModel.isSubscribe ? SubActionType.SendMessage : SubActionType.Subscribe,
|
||||
slug: widget.subModel.slug,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user