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 createState() => _SubscribeButtonWidgetState(); } class _SubscribeButtonWidgetState extends State { 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().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, ), ), ), ), ); } }