mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: improve floating mobile toolbar animation for iOS (#5309)
This commit is contained in:
parent
39f8c47758
commit
38fa9f7942
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@ -100,14 +102,7 @@ class CustomMobileFloatingToolbar extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Animate(
|
return Animate(
|
||||||
autoPlay: true,
|
autoPlay: true,
|
||||||
effects: [
|
effects: _getEffects(context),
|
||||||
const FadeEffect(duration: SelectionOverlay.fadeDuration),
|
|
||||||
MoveEffect(
|
|
||||||
curve: Curves.easeOutCubic,
|
|
||||||
begin: const Offset(0, 16),
|
|
||||||
duration: 100.milliseconds,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: AdaptiveTextSelectionToolbar.buttonItems(
|
child: AdaptiveTextSelectionToolbar.buttonItems(
|
||||||
buttonItems: buildMobileFloatingToolbarItems(
|
buttonItems: buildMobileFloatingToolbarItems(
|
||||||
editorState,
|
editorState,
|
||||||
@ -120,4 +115,32 @@ class CustomMobileFloatingToolbar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Effect> _getEffects(BuildContext context) {
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
final Size(:width, :height) = MediaQuery.of(context).size;
|
||||||
|
final alignmentX = (anchor.dx - width / 2) / (width / 2);
|
||||||
|
final alignmentY = (anchor.dy - height / 2) / (height / 2);
|
||||||
|
return [
|
||||||
|
ScaleEffect(
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
alignment: Alignment(alignmentX, alignmentY),
|
||||||
|
duration: 250.milliseconds,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
} else if (Platform.isAndroid) {
|
||||||
|
return [
|
||||||
|
const FadeEffect(
|
||||||
|
duration: SelectionOverlay.fadeDuration,
|
||||||
|
),
|
||||||
|
MoveEffect(
|
||||||
|
curve: Curves.easeOutCubic,
|
||||||
|
begin: const Offset(0, 16),
|
||||||
|
duration: 100.milliseconds,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user