import 'package:flextras/flextras.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gutter/flutter_gutter.dart';
import 'package:go_router/go_router.dart';

import '../../services/router/routes_list.dart';

class BaseAuthPage extends StatelessWidget {
  final List<Widget> children;
  final String? title;
  final bool? showSettings;

  const BaseAuthPage({
    super.key,
    required this.children,
    this.title,
    this.showSettings,
  });

  @override
  Widget build(BuildContext context) {
    void onSettingsPressed() => context.push(settingsPage);

    return Scaffold(
      appBar: AppBar(
        title: Text(title ?? 'MoneyMgr'),
        actions: [
          // Settings button
          showSettings != false
              ? IconButton(
                  onPressed: onSettingsPressed,
                  icon: const Icon(Icons.settings),
                )
              : Container(),
        ],
      ),
      body: SingleChildScrollView(
        child: IntrinsicHeight(
          child: SeparatedColumn(
            padding: EdgeInsets.all(context.gutter),
            separatorBuilder: () => const Gutter(),
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: children,
          ),
        ),
      ),
    );
  }
}
