import 'package:flutter/cupertino.dart';
import 'package:flux_ui/flux_ui.dart';

import '../../modules/dynamic_layout/config/app_config.dart';
import 'appbar_item_widget.dart';

class AppBarItemsWidget extends StatelessWidget with MultiSiteMixin {
  const AppBarItemsWidget({
    super.key,
    this.items,
    this.showBottom = true,
    this.popButton,
    this.showSiteSelection = false,
  });

  final List<AppBarItemConfig>? items;
  final bool showBottom;
  final Widget? popButton;
  final bool showSiteSelection;

  @override
  Widget build(BuildContext context) {
    var widgets =
        items?.map<Widget>((AppBarItemConfig item) {
          return AppBarItemWidget(item: item, showBottom: showBottom);
        }).toList() ??
        <Widget>[];

    var popBtn = popButton != null && Navigator.canPop(context)
        ? popButton
        : null;
    if (popBtn != null) {
      widgets.add(popBtn);
    }

    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: widgets,
    );
  }
}
