// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

/// This file contains the concrete class [BottomNavigationBarLayout].
///
/// The [BottomNavigationBarLayout] class is a concrete implementation of the
/// [Layout] abstract class, which defines a layout structure with a bottom
/// navigation bar component.
///
/// [BottomNavigationBarLayout] includes an optional
/// [BottomNavigationBarLayout.custom]
/// function for customizing the bottom navigation bar component.
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';

/// A concrete implementation of the [Layout] abstract class for a layout with
/// a bottom navigation bar component.
class BottomNavigationBarLayout extends StructuralLayout {
  /// Creates a [BottomNavigationBarLayout] instance.
  ///
  /// [body] represents the main content of the layout.
  /// [custom] is an optional function that can be used to customize
  /// the bottom navigation bar component.
  const BottomNavigationBarLayout({
    required this.body,
    this.custom,
    super.key,
  });

  final Widget? body;
  final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)?
      custom;

  @override
  Widget build(BuildContext context) => Scaffold(
        body: body,
        bottomNavigationBar: custom?.call(
              context.components.bottomNavigationBar,
            ) ??
            context.components.bottomNavigationBar,
      );
}
