import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';
import 'package:mapflow/app/theme/mapflow_theme.dart';
import 'package:mapflow/features/mapflow/domain/place_models.dart';
import 'package:mapflow/features/mapflow/presentation/widgets/place_photo_card.dart';
import 'package:mapflow/shared/auth/telegram_login_button.dart';
import 'package:widgetbook/widgetbook.dart';

void main() {
  runApp(const MapflowWidgetbook());
}

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

  @override
  Widget build(BuildContext context) {
    return Widgetbook.material(
      directories: [
        WidgetbookCategory(
          name: 'MapFlow',
          children: [
            WidgetbookComponent(
              name: 'PlacePhotoCard',
              useCases: [
                WidgetbookUseCase(
                  name: 'Empty photo',
                  builder: (_) => Center(
                    child: SizedBox(
                      height: 172,
                      child: PlacePhotoCard(
                        place: _samplePlace,
                        onTap: () {},
                        onFavoriteToggle: () {},
                      ),
                    ),
                  ),
                ),
              ],
            ),
            WidgetbookComponent(
              name: 'TelegramLoginButton',
              useCases: [
                WidgetbookUseCase(
                  name: 'Idle',
                  builder: (_) => Center(
                    child: TelegramLoginButton(
                      onPressed: () {},
                      loading: false,
                    ),
                  ),
                ),
                WidgetbookUseCase(
                  name: 'Loading',
                  builder: (_) => const Center(
                    child: TelegramLoginButton(onPressed: null, loading: true),
                  ),
                ),
              ],
            ),
          ],
        ),
      ],
      appBuilder: (context, child) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: MapflowTheme.light(),
          home: child,
        );
      },
    );
  }
}

const _samplePlace = PlaceRecommendation(
  id: 'sample-place',
  googlePlaceId: 'sample-google-place',
  name: 'Morning Coffee',
  area: '',
  photoUrls: [],
  coordinate: LatLng(10.7718, 106.6982),
  traits: {PlaceTrait.calm, PlaceTrait.clean},
  googlePrimaryType: 'cafe',
  googleTypes: ['cafe'],
  googleBusinessStatus: 'OPERATIONAL',
  googleRating: 4.8,
  googleUserRatingCount: 128,
  googleRegularOpeningHours: null,
  googleCurrentOpeningHours: null,
  isFavorite: true,
);
