// ignore_for_file: deprecated_member_use

import 'package:didvan/views/authentication/widgets/authentication_app_bar.dart';
import 'package:didvan/views/widgets/logos/didvan_horizontal_logo.dart';
import 'package:flutter/material.dart';

class AuthenticationLayout extends StatelessWidget {
  final List<Widget> children;
  final String? appBarTitle;

  const AuthenticationLayout(
      {Key? key, required this.children, this.appBarTitle})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: [
        if (appBarTitle != null)
          SliverAppBar(
            automaticallyImplyLeading: false,
            pinned: true,
            toolbarHeight: 56,
            backgroundColor: Theme.of(context).colorScheme.background,
            flexibleSpace: Padding(
              padding: const EdgeInsets.only(
                left: 16,
                right: 16,
                top: 7,
              ),
              child: AuthenticationAppBar(
                title: appBarTitle,
              ),
            ),
          ),
        SliverPadding(
          padding: EdgeInsets.only(
            top: appBarTitle == null ? 100 : 44,
            left: 100,
            right: 100,
            bottom: 40,
          ),
          sliver: const SliverToBoxAdapter(
            child: DidvanVerticalLogo(
              height: 145,
            ),
          ),
        ),
        SliverPadding(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          sliver: SliverFillRemaining(
            hasScrollBody: true,
            fillOverscroll: true,
            child: Column(
              children: [
                for (var i = 0; i < children.length; i++) children[i],
              ],
            ),
          ),
        ),
      ],
    );
  }
}
