import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../../../../application/printer/printer_bloc.dart';
import '../../../../../../common/theme/theme.dart';
import '../../../../../components/page/page_title.dart';
import 'setting_tile.dart';

class SettingLeftPanel extends StatelessWidget {
  final PrinterState state;
  const SettingLeftPanel({super.key, required this.state});

  @override
  Widget build(BuildContext context) {
    return Material(
      color: AppColor.white,
      child: Column(
        children: [
          const PageTitle(
            title: 'Pengaturan',
            subtitle: 'Kelola pengaturan aplikasi',
            isBack: false,
          ),
          Expanded(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  SettingTile(
                    index: 0,
                    currentIndex: state.index,
                    title: 'Printer',
                    subtitle: 'Kelola printer',
                    icon: Icons.print_outlined,
                    onTap: () => context.read<PrinterBloc>().add(
                      const PrinterEvent.indexChanged(0),
                    ),
                  ),
                  SettingTile(
                    index: 1,
                    currentIndex: state.index,
                    title: 'Sinkronisasi',
                    subtitle: 'Sinkronisasi data',
                    icon: Icons.sync_outlined,
                    onTap: () => context.read<PrinterBloc>().add(
                      const PrinterEvent.indexChanged(1),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
