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 child;
  11. }
  12. static Future<void> show(
  13. BuildContext context, {
  14. required Widget child,
  15. required Size size,
  16. }) async {
  17. final window = await getWindowInfo();
  18. FlowyOverlay.of(context).insertWithRect(
  19. widget: SizedBox.fromSize(
  20. size: size,
  21. child: FlowyPoppuWindow(child: child),
  22. ),
  23. identifier: 'FlowyPoppuWindow',
  24. anchorPosition: Offset(-size.width / 2.0, -size.height / 2.0),
  25. anchorSize: window.frame.size,
  26. anchorDirection: AnchorDirection.center,
  27. style: FlowyOverlayStyle(blur: true),
  28. );
  29. }
  30. }
  31. class PopupTextField extends StatelessWidget {
  32. final void Function(String) textDidChange;
  33. const PopupTextField({
  34. Key? key,
  35. required this.textDidChange,
  36. }) : super(key: key);
  37. @override
  38. Widget build(BuildContext context) {
  39. return Material(
  40. child: RoundedInputField(
  41. style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
  42. hintText: '',
  43. normalBorderColor: const Color(0xffbdbdbd),
  44. onChanged: textDidChange,
  45. ),
  46. type: MaterialType.transparency,
  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. }