import 'package:fis_ui/index.dart';
import 'package:fis_ui/utils/sizer/sizer.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';

/// 监听页面缩放的容器盒子
class FPageResizableBox extends FStatefulWidget {
  final FWidgetCallback builder;

  FPageResizableBox({required this.builder, super.key});

  @override
  FState<FStatefulWidget> createState() => _FPageResizableBoxState();
}

class _FPageResizableBoxState extends FState<FPageResizableBox> {
  @override
  void initState() {
    Sizer.ins.addListener(_onWindowResize);
    super.initState();
  }

  @override
  void dispose() {
    Sizer.ins.removeListener(_onWindowResize);
    super.dispose();
  }

  void _onWindowResize(e) {
    setState(() {});
  }

  @override
  FWidget build(BuildContext context) {
    return widget.builder();
  }
}
