55 lines
2.1 KiB
Dart
55 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lgcc/models/conferences_model.dart';
|
|
import 'package:lgcc/providers/directus_service.dart';
|
|
|
|
class ConferencesPage extends StatelessWidget {
|
|
const ConferencesPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Conferencias', style: TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
|
|
centerTitle: true,
|
|
shadowColor: Colors.transparent,
|
|
backgroundColor: Colors.blue,
|
|
|
|
),
|
|
body: _buildConferenceListView(),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget _buildConferenceListView() {
|
|
final DirectusService _directusService = DirectusService();
|
|
return FutureBuilder(
|
|
future: Future.wait([
|
|
_directusService.getConferences(),
|
|
]),
|
|
builder: (BuildContext context, AsyncSnapshot<List<dynamic>> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else if (snapshot.hasError) {
|
|
print('Error: ${snapshot.error}');
|
|
return Center(child: Text('Error: ${snapshot.error}'));
|
|
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
|
return const Center(child: Text('No conferences found.'));
|
|
} else {
|
|
List<ConferencesModel> conferences = List<ConferencesModel>.from(snapshot.data![0]);
|
|
return ListView.builder(
|
|
itemCount: conferences.length,
|
|
itemBuilder: (context, index) {
|
|
final conference = conferences[index];
|
|
return ListTile(
|
|
title: Text(conference.title, style: const TextStyle(fontSize: 18)),
|
|
subtitle: Text(
|
|
'${conference.date.toLocal().toString().split(' ')[0]} - ${conference.place}, ${conference.city}, ${conference.state}, ${conference.country}, ${conference.activity}',
|
|
style: const TextStyle(fontSize: 16),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
);
|
|
} |