Skip to content

Commit

Permalink
competitions screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïs Poujade committed Jul 8, 2022
1 parent bfd8f33 commit 1832770
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
5 changes: 4 additions & 1 deletion lib/data/competition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Competition extends AData {
@override
final int id;
final String name;
final String subtitle;
final String? competitor_list_pdf;
final String? start_list_pdf;
final DateTime updated_at;
Expand All @@ -13,6 +14,7 @@ class Competition extends AData {
Competition(
{required this.id,
required this.name,
required this.subtitle,
required this.competitor_list_pdf,
required this.start_list_pdf,
required this.updated_at,
Expand All @@ -24,6 +26,7 @@ class Competition extends AData {
return {
'id': id,
'name': name,
'subtitle': subtitle,
'updated_at': updated_at.millisecondsSinceEpoch,
'start_list_pdf': start_list_pdf,
'competitor_list_pdf': competitor_list_pdf
Expand All @@ -32,6 +35,6 @@ class Competition extends AData {

@override
String toString() {
return "Competition('$id', '$name', '$updated_at')";
return "Competition('$id', '$name', '$subtitle', '$updated_at')";
}
}
48 changes: 35 additions & 13 deletions lib/screen/competitions_infos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import '../services/results_list.dart';
class PDFDialog extends StatelessWidget {
final String pdf;
final String name;
const PDFDialog({Key? key, required this.pdf, required this.name})
final String subtitle;
const PDFDialog({Key? key, required this.pdf, required this.name, required this.subtitle})
: super(key: key);

@override
Expand All @@ -20,14 +21,14 @@ class PDFDialog extends StatelessWidget {
insetPadding: const EdgeInsets.all(1.0),
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Text(name),
Column(children: [Text(name), Text(subtitle)]),
ElevatedButton(
onPressed: () => launchUrl(Uri.parse(pdf),
mode: LaunchMode.externalApplication),
child: const Text('download'))
]),
Expanded(
child: const PDF(fitPolicy: FitPolicy.BOTH).cachedFromUrl(pdf,
child: const PDF(fitPolicy: FitPolicy.BOTH).fromUrl(pdf,
placeholder: (progress) => Center(
child: Column(children: [
Text('$progress %'),
Expand All @@ -54,7 +55,7 @@ class ResultsDialog extends StatelessWidget {
showDialog(
context: context,
builder: (context) =>
PDFDialog(name: res.name, pdf: res.pdf))
PDFDialog(name: res.name, subtitle: res.subtitle, pdf: res.pdf))
})));
}

Expand All @@ -74,16 +75,16 @@ class CompCard extends StatelessWidget {
List<Widget> buttons = [];

if (competitor_or_startlist != null && competitor_or_startlist != '')
buttons.add(IconButton(
buttons.add(Center(child: IconButton(
icon: const Icon(Icons.groups),
onPressed: () async {
showDialog(
context: context,
builder: (context) => PDFDialog(
name: competition.name, pdf: competitor_or_startlist));
}));
name: competition.name, subtitle: competition.subtitle, pdf: competitor_or_startlist));
})));
if (competition.results.list.isNotEmpty)
buttons.add(IconButton(
buttons.add(Center(child: IconButton(
icon: const Icon(Icons.format_list_numbered),
onPressed: () async {
if (competition.results.list.length > 1)
Expand All @@ -96,18 +97,38 @@ class CompCard extends StatelessWidget {
context: context,
builder: (context) => PDFDialog(
name: competition.name,
subtitle: competition.subtitle,
pdf: competition.results.list.first.pdf));
}));
})));
return Padding(
padding: const EdgeInsets.all(2),
child: ListTile(
child: GestureDetector(
onTap: () => {
if ((competitor_or_startlist == null ||
competitor_or_startlist == '') &&
competition.results.list.isEmpty)
Fluttertoast.showToast(
msg: "Data not yet available for this competition",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
fontSize: 16.0)
},
child: Card(child: Column(children: [
Text(competition.name), Text(competition.subtitle),
Row(children: buttons)

]))));
/*
child: Card(child: Column(children: [ListTile(
title: Text(competition.name),
subtitle: Text(competition.subtitle),
tileColor: Colors.white,
subtitle: Row(children: buttons),
shape: RoundedRectangleBorder(
side: const BorderSide(),
borderRadius: BorderRadius.circular(5)),
dense: true,
isThreeLine: true,
dense: false,
onTap: () => {
if ((competitor_or_startlist == null ||
competitor_or_startlist == '') &&
Expand All @@ -118,7 +139,8 @@ class CompCard extends StatelessWidget {
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
fontSize: 16.0)
}));
}), Row(children: buttons)])));
*/
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/services/competitions_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CompetitionsList extends ItemList<Competition> {
return Competition(
id: e['id'] as int,
name: e['name'].toString(),
subtitle: e['subtitle'].toString(),
updated_at:
DateTime.fromMillisecondsSinceEpoch(e['updated_at'] as int),
competitor_list_pdf: e['competitor_list_pdf'].toString(),
Expand Down Expand Up @@ -93,6 +94,7 @@ class CompetitionsList extends ItemList<Competition> {
new_comps.add(Competition(
id: comp_id,
name: comp['name'],
subtitle: comp['subtitle'],
competitor_list_pdf: comp['competitor_list_pdf'],
start_list_pdf: comp['start_list_pdf'],
updated_at: DateTime.parse(comp['updated_at']),
Expand Down
2 changes: 1 addition & 1 deletion lib/services/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const migrations = {
'create table places (address text, lat real, lon real, unique(address))'
],
3: [
'create table competitions (id integer primary key unique, name text, updated_at integer, competitor_list_pdf text, start_list_pdf text)',
'create table competitions (id integer primary key unique, name text, subtitle text, updated_at integer, competitor_list_pdf text, start_list_pdf text)',
'create table results (id integer primary key unique, name text, published_at integer, pdf text)',
'create table competitions_results (competition references competitions(id), result references results(id), unique(competition, result) on conflict ignore)'
]
Expand Down
1 change: 0 additions & 1 deletion lib/services/events_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class EventList extends ItemList<Event> {
invalids[ev.location] = [ev.title];
continue;
}
sleep(const Duration(seconds: 1));
ev.coords = coords;
notifyListeners();
locs[ev.location!] = coords;
Expand Down
Binary file modified unicon20_prerelease.apk
Binary file not shown.

0 comments on commit 1832770

Please sign in to comment.