remove store from being a property. also better animation
This commit is contained in:
parent
e3b561835b
commit
b2ef0883e3
|
@ -42,26 +42,36 @@ enum HeaderLevel {
|
||||||
class EditorToolbar extends HookWidget {
|
class EditorToolbar extends HookWidget {
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final String instanceHost;
|
final String instanceHost;
|
||||||
final EditorToolbarStore store;
|
|
||||||
final FocusNode editorFocusNode;
|
final FocusNode editorFocusNode;
|
||||||
static const _height = 50.0;
|
static const _height = 50.0;
|
||||||
|
|
||||||
EditorToolbar({
|
const EditorToolbar({
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.instanceHost,
|
required this.instanceHost,
|
||||||
required this.editorFocusNode,
|
required this.editorFocusNode,
|
||||||
}) : store = EditorToolbarStore(instanceHost);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final visible = useListenable(editorFocusNode).hasFocus;
|
final visible = useListenable(editorFocusNode).hasFocus;
|
||||||
|
|
||||||
return MobxProvider(
|
return MobxProvider(
|
||||||
create: (context) => store,
|
create: (context) => EditorToolbarStore(instanceHost),
|
||||||
child: AsyncStoreListener(
|
child: ObserverBuilder<EditorToolbarStore>(builder: (context, store) {
|
||||||
|
return AsyncStoreListener(
|
||||||
asyncStore: store.imageUploadState,
|
asyncStore: store.imageUploadState,
|
||||||
child: AnimatedSwitcher(
|
child: AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: kThemeAnimationDuration,
|
||||||
|
transitionBuilder: (child, animation) {
|
||||||
|
final offsetAnimation =
|
||||||
|
Tween<Offset>(begin: const Offset(0, 1.5), end: Offset.zero)
|
||||||
|
.animate(animation);
|
||||||
|
|
||||||
|
return SlideTransition(
|
||||||
|
position: offsetAnimation,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
child: visible
|
child: visible
|
||||||
? Container(
|
? Container(
|
||||||
height: _height,
|
height: _height,
|
||||||
|
@ -77,7 +87,8 @@ class EditorToolbar extends HookWidget {
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue