|
@@ -61,6 +61,8 @@ class FontFamilyDropDown extends StatefulWidget {
|
|
|
this.child,
|
|
|
this.popoverController,
|
|
|
this.offset,
|
|
|
+ this.showResetButton = false,
|
|
|
+ this.onResetFont,
|
|
|
});
|
|
|
|
|
|
final String currentFontFamily;
|
|
@@ -70,6 +72,8 @@ class FontFamilyDropDown extends StatefulWidget {
|
|
|
final Widget? child;
|
|
|
final PopoverController? popoverController;
|
|
|
final Offset? offset;
|
|
|
+ final bool showResetButton;
|
|
|
+ final VoidCallback? onResetFont;
|
|
|
|
|
|
@override
|
|
|
State<FontFamilyDropDown> createState() => _FontFamilyDropDownState();
|
|
@@ -96,6 +100,13 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
|
|
|
return CustomScrollView(
|
|
|
shrinkWrap: true,
|
|
|
slivers: [
|
|
|
+ if (widget.showResetButton)
|
|
|
+ SliverPersistentHeader(
|
|
|
+ delegate: _ResetFontButton(
|
|
|
+ onPressed: widget.onResetFont,
|
|
|
+ ),
|
|
|
+ pinned: true,
|
|
|
+ ),
|
|
|
SliverPadding(
|
|
|
padding: const EdgeInsets.only(right: 8),
|
|
|
sliver: SliverToBoxAdapter(
|
|
@@ -191,3 +202,36 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+class _ResetFontButton extends SliverPersistentHeaderDelegate {
|
|
|
+ _ResetFontButton({
|
|
|
+ this.onPressed,
|
|
|
+ });
|
|
|
+
|
|
|
+ final VoidCallback? onPressed;
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(
|
|
|
+ BuildContext context,
|
|
|
+ double shrinkOffset,
|
|
|
+ bool overlapsContent,
|
|
|
+ ) {
|
|
|
+ return Padding(
|
|
|
+ padding: const EdgeInsets.only(right: 8, bottom: 8.0),
|
|
|
+ child: FlowyTextButton(
|
|
|
+ LocaleKeys.document_toolbar_resetToDefaultFont.tr(),
|
|
|
+ onPressed: onPressed,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ double get maxExtent => 35;
|
|
|
+
|
|
|
+ @override
|
|
|
+ double get minExtent => 35;
|
|
|
+
|
|
|
+ @override
|
|
|
+ bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
|
|
|
+ true;
|
|
|
+}
|