pop_up_window.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:flowy_infra_ui/flowy_infra_ui.dart';
  2. import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:window_size/window_size.dart';
  5. class FlowyPoppuWindow extends StatelessWidget {
  6. final Widget child;
  7. const FlowyPoppuWindow({Key? key, required this.child}) : super(key: key);
  8. @override
  9. Widget build(BuildContext context) {
  10. return Material(
  11. child: child,
  12. type: MaterialType.transparency,
  13. );
  14. }
  15. static Future<void> show(
  16. BuildContext context, {
  17. required Widget child,
  18. required Size size,
  19. }) async {
  20. final window = await getWindowInfo();
  21. FlowyOverlay.of(context).insertWithRect(
  22. widget: SizedBox.fromSize(
  23. size: size,
  24. child: FlowyPoppuWindow(child: child),
  25. ),
  26. identifier: 'FlowyPoppuWindow',
  27. anchorPosition: Offset(-size.width / 2.0, -size.height / 2.0),
  28. anchorSize: window.frame.size,
  29. anchorDirection: AnchorDirection.center,
  30. style: FlowyOverlayStyle(blur: false),
  31. );
  32. }
  33. }
  34. class PopupTextField extends StatelessWidget {
  35. final void Function(String) textDidChange;
  36. const PopupTextField({
  37. Key? key,
  38. required this.textDidChange,
  39. }) : super(key: key);
  40. @override
  41. Widget build(BuildContext context) {
  42. return RoundedInputField(
  43. style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
  44. hintText: '',
  45. normalBorderColor: const Color(0xffbdbdbd),
  46. onChanged: textDidChange,
  47. );
  48. }
  49. static void show({required BuildContext context, required Size size, required void Function(String) textDidChange}) {
  50. FlowyPoppuWindow.show(
  51. context,
  52. size: size,
  53. child: PopupTextField(textDidChange: textDidChange),
  54. );
  55. }
  56. }