forked from eatvio/eatvio_app
58 lines
1.6 KiB
Dart
58 lines
1.6 KiB
Dart
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: const 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: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8),
|
|
color: appTheme.gray200,
|
|
),
|
|
child: const Text(
|
|
'Подписаться',
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|