import 'package:flutter/material.dart';
import 'package:gymlink_module_web/pages/main.dart';
import 'package:gymlink_module_web/tools/routes.dart';

class GymLinkHeader extends StatelessWidget {
  final String title;
  final bool toMain;
  const GymLinkHeader({super.key, required this.title, this.toMain = false});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Column(
        children: [
          Row(
            children: [
              IconButton(
                  onPressed: () => toMain
                      ? Navigator.pushAndRemoveUntil(
                          context,
                          CustomPageRoute(
                              builder: (context) => const MainPage()),
                          (route) => route.isFirst)
                      : Navigator.pop(context),
                  icon: const Icon(Icons.arrow_back)),
              Text(title, style: Theme.of(context).textTheme.titleLarge),
            ],
          ),
          const Divider(thickness: 1, height: 0),
        ],
      ),
    );
  }
}
