import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:kasy_kit/components/kasy_app_bar.dart';
import 'package:kasy_kit/core/theme/theme.dart';
import 'package:kasy_kit/core/widgets/kasy_scroll_behavior.dart';
import 'package:kasy_kit/features/settings/ui/components/admin/admin_routes.dart';
import 'package:kasy_kit/features/settings/ui/widgets/settings_tile.dart';
import 'package:kasy_kit/features/subscription/ui/component/premium_page_factory.dart';
import 'package:kasy_kit/i18n/translations.g.dart';

class AdminPaywalls extends ConsumerWidget {
  const AdminPaywalls({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return ScrollConfiguration(
      behavior: const KasyKitScrollBehavior(),
      child: KasyOverlayScaffold(
        title: t.settings.admin.paywalls_title,
        onBack: () => context.pop(),
        slivers: [
          SliverToBoxAdapter(
            child: Container(
              padding: const EdgeInsets.symmetric(
                vertical: KasySpacing.smd,
                horizontal: KasySpacing.md,
              ),
              decoration: BoxDecoration(
                borderRadius: KasyRadius.smBorderRadius,
                color: context.colors.surface,
              ),
              child: Wrap(
                children: [
                  for (final paywall in PaywallFactory.values) ...[
                    SettingsTile(
                      icon: KasyIcons.payment,
                      title: paywall.name,
                      onTap: () => context.push(
                        adminRoutePremiumPreview(paywall.name),
                      ),
                    ),
                    const SettingsDivider(),
                  ],
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
