You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
5 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:recook/constants/header.dart';
|
||
|
import 'package:recook/widgets/custom_image_button.dart';
|
||
|
|
||
|
class RecookLikeButton extends StatefulWidget {
|
||
|
final bool initValue;
|
||
|
final Function(bool oldState) onChange;
|
||
|
final double size;
|
||
|
RecookLikeButton({
|
||
|
Key key,
|
||
|
@required this.initValue,
|
||
|
@required this.onChange,
|
||
|
this.size = 14,
|
||
|
}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_RecookLikeButtonState createState() => _RecookLikeButtonState();
|
||
|
}
|
||
|
|
||
|
class _RecookLikeButtonState extends State<RecookLikeButton> {
|
||
|
bool _likeState = false;
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
_likeState = widget.initValue;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return CustomImageButton(
|
||
|
child: Image.asset(
|
||
|
_likeState ? R.ASSETS_LIVE_LIKE_ON_PNG : R.ASSETS_LIVE_LIKE_PNG,
|
||
|
height: rSize(widget.size),
|
||
|
width: rSize(widget.size),
|
||
|
),
|
||
|
onPressed: () {
|
||
|
setState(() {
|
||
|
widget.onChange(_likeState);
|
||
|
_likeState = !_likeState;
|
||
|
});
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|