import 'package:flutter/material.dart';
//import 'package:learn_project/utils/class.dart';
//import 'package:learn_project/utils/widgets.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
//import 'dart:async';

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

  

  @override
  Widget build(BuildContext context) {
    final future2 = Supabase.instance.client
    .from('events')
    .select();
 // 1. Daten anahdn von Filter einstellungen abrufen
 // 2. Frontend asynchron diesbezüglich aufbauen
 // 3. testen ob durchs scrollen daten nachgeladen werden können?

    return Scaffold(
      body: FutureBuilder(
        future: future2,
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return const Center(child: CircularProgressIndicator());
          } else if (snapshot.hasError) {
            return Center(child: Text('Error: ${snapshot.error}'));
          } else if (!snapshot.hasData) {
            return const Center(child: Text('No data found'));
          }
          final events = snapshot.data!;
          return ListView.builder(
            itemCount: events.length,
            itemBuilder: ((context, index) {
              final event = events[index];
              return ListTile(
                title: Text(event['name']),
                subtitle: Text(event['description']),
              );
            }),
          );
        },
      ),
    );
  }
}

