67 lines
2.5 KiB
Dart
67 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
class AdminEventScreen extends StatefulWidget {
|
|
const AdminEventScreen({super.key});
|
|
@override
|
|
State<AdminEventScreen> createState() => _AdminEventScreenState();
|
|
}
|
|
|
|
class _AdminEventScreenState extends State<AdminEventScreen> {
|
|
final _title = TextEditingController();
|
|
final _venue = TextEditingController();
|
|
final _city = TextEditingController();
|
|
final _date = TextEditingController();
|
|
final _link = TextEditingController();
|
|
int _minTier = 1;
|
|
|
|
Future<void> _save() async {
|
|
await FirebaseFirestore.instance.collection('events').add({
|
|
'title': _title.text,
|
|
'venue': _venue.text,
|
|
'city': _city.text,
|
|
'date_string': _date.text,
|
|
'link': _link.text,
|
|
'minTier': _minTier,
|
|
'date': FieldValue.serverTimestamp(), // For sorting
|
|
});
|
|
Navigator.pop(context);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text("REGISTER_SESSION")),
|
|
body: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
children: [
|
|
TextField(controller: _title, decoration: const InputDecoration(labelText: "EVENT_NAME")),
|
|
const SizedBox(height: 10),
|
|
TextField(controller: _venue, decoration: const InputDecoration(labelText: "VENUE_NAME")),
|
|
const SizedBox(height: 10),
|
|
TextField(controller: _city, decoration: const InputDecoration(labelText: "CITY_SECTOR")),
|
|
const SizedBox(height: 10),
|
|
TextField(controller: _date, decoration: const InputDecoration(labelText: "DATE (EX: OCT 24)")),
|
|
const SizedBox(height: 10),
|
|
TextField(controller: _link, decoration: const InputDecoration(labelText: "TICKET_GATEWAY_URL")),
|
|
const SizedBox(height: 20),
|
|
DropdownButton<int>(
|
|
value: _minTier,
|
|
isExpanded: true,
|
|
dropdownColor: Colors.black,
|
|
items: const [
|
|
DropdownMenuItem(value: 1, child: Text("LVL_01: PUBLIC")),
|
|
DropdownMenuItem(value: 2, child: Text("LVL_02: COLLECTORS")),
|
|
DropdownMenuItem(value: 3, child: Text("LVL_03: INVESTORS")),
|
|
],
|
|
onChanged: (v) => setState(() => _minTier = v!),
|
|
),
|
|
const SizedBox(height: 40),
|
|
ElevatedButton(onPressed: _save, child: const Text("[ INITIALIZE_SESSION ]")),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |