43 lines
1021 B
Dart
43 lines
1021 B
Dart
import 'package:didvan/constants/app_icons.dart';
|
|
import 'package:didvan/widgets/didvan/icon_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class BookmarkButton extends StatefulWidget {
|
|
final bool value;
|
|
final VoidCallback onMark;
|
|
final VoidCallback onUnmark;
|
|
const BookmarkButton(
|
|
{Key? key,
|
|
required this.value,
|
|
required this.onMark,
|
|
required this.onUnmark})
|
|
: super(key: key);
|
|
|
|
@override
|
|
State<BookmarkButton> createState() => _BookmarkButtonState();
|
|
}
|
|
|
|
class _BookmarkButtonState extends State<BookmarkButton> {
|
|
bool _value = false;
|
|
|
|
@override
|
|
void initState() {
|
|
_value = widget.value;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DidvanIconButton(
|
|
gestureSize: 24,
|
|
icon: _value ? DidvanIcons.bookmark_solid : DidvanIcons.bookmark_regular,
|
|
onPressed: () {
|
|
setState(() {
|
|
_value = !_value;
|
|
});
|
|
_value ? widget.onMark() : widget.onUnmark();
|
|
},
|
|
);
|
|
}
|
|
}
|