import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krezus/domains/account/account_bloc.dart';
import 'package:krezus/pages/common/titled_container.dart';

class ImportSettings extends StatelessWidget {
  const ImportSettings({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<AccountBloc, AccountState>(
      builder: (context, state) => TitledContainer(
        title: "Import",
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            FilledButton.icon(
              onPressed: () => context.read<AccountBloc>().add(const ClearData()),
              label: const Text('ClearData'),
              icon: const Icon(Icons.delete_forever),
            ),
            const SizedBox(height: 5),
            FilledButton.tonalIcon(
              onPressed: () => context.read<AccountBloc>().add(const AccountImportCSV()),
              label: const Text('Import CSV'),
              icon: const Icon(Icons.upload_file),
            ),
            const SizedBox(height: 5),
            FilledButton.tonalIcon(
              onPressed: () => context.read<AccountBloc>().add(const AccountImportJSON()),
              label: const Text('Import JSON'),
              icon: const Icon(Icons.upload_file),
            ),
            const SizedBox(height: 5),
            FilledButton.tonalIcon(
              onPressed: () => context.read<AccountBloc>().add(const AccountExportCSV()),
              label: const Text('Export CSV'),
              icon: const Icon(Icons.download),
            ),
            const SizedBox(height: 5),
            FilledButton.tonalIcon(
              onPressed: () => context.read<AccountBloc>().add(const AccountExportJSON()),
              label: const Text('Export JSON'),
              icon: const Icon(Icons.download),
            ),
          ],
        ),
      )
    );
  }
}