forked from eatvio/eatvio_app
feat(feed): add subscribe button
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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/sub_cubit/sub_cubit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SubscribeButtonWidget extends StatefulWidget {
|
||||
final String slug;
|
||||
|
||||
const SubscribeButtonWidget({
|
||||
super.key,
|
||||
required this.slug,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SubscribeButtonWidget> createState() => _SubscribeButtonWidgetState();
|
||||
}
|
||||
|
||||
class _SubscribeButtonWidgetState extends State<SubscribeButtonWidget> {
|
||||
bool isSubscribe = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedOpacity(
|
||||
opacity: isSubscribe ? 0 : 1,
|
||||
duration: Duration(milliseconds: 250),
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
try {
|
||||
setState(() {
|
||||
isSubscribe = true;
|
||||
});
|
||||
await sl<SubCubit>().subscribe(widget.slug);
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isSubscribe = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: appTheme.gray200,
|
||||
),
|
||||
child: Text(
|
||||
'Подписаться',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user