1
0

Mobile Improvements

Dieser Commit ist enthalten in:
Chaoscaot 2023-02-14 17:20:32 +01:00
Ursprung dd94230021
Commit d38c4bedbd
6 geänderte Dateien mit 98 neuen und 72 gelöschten Zeilen

Binäre Datei nicht angezeigt.

Nachher

Breite:  |  Höhe:  |  Größe: 2.8 KiB

Datei anzeigen

@ -62,6 +62,32 @@ class EventFightList extends HookConsumerWidget {
return Column( return Column(
children: [ children: [
const SizedBox(height: 8), const SizedBox(height: 8),
Row(
children: [
FilledButton.icon(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AddFightDialog(
eventData,
() => update(),
);
},
);
},
label: const Text("Add Fight"),
icon: const Icon(Icons.add),
),
const SizedBox(width: 8),
FilledButton.icon(
onPressed: () {
context.go("/event/${event.id}/generator");
},
label: const Text("Generate Fight"),
icon: const Icon(Icons.shuffle)),
],
),
Row( Row(
children: [ children: [
const SizedBox(width: 16), const SizedBox(width: 16),
@ -287,29 +313,6 @@ class EventFightList extends HookConsumerWidget {
], ],
), ),
const Spacer(), const Spacer(),
FilledButton.icon(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AddFightDialog(
eventData,
() => update(),
);
},
);
},
label: const Text("Add Fight"),
icon: const Icon(Icons.add),
),
const SizedBox(width: 8),
FilledButton.icon(
onPressed: () {
context.go("/event/${event.id}/generator");
},
label: const Text("Generate Fight"),
icon: const Icon(Icons.shuffle)),
const SizedBox(width: 8),
PopupMenuButton( PopupMenuButton(
itemBuilder: (context) { itemBuilder: (context) {
return const [ return const [

Datei anzeigen

@ -22,6 +22,7 @@ import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:steamwar_multitool/src/components/components.dart'; import 'package:steamwar_multitool/src/components/components.dart';
import 'package:steamwar_multitool/src/dialogs/dialogs.dart'; import 'package:steamwar_multitool/src/dialogs/dialogs.dart';
import 'package:steamwar_multitool/src/types/event.dart';
import 'package:steamwar_multitool/src/util/constants.dart'; import 'package:steamwar_multitool/src/util/constants.dart';
import '../../../provider/events.dart'; import '../../../provider/events.dart';
@ -59,11 +60,9 @@ class EventListComponent extends HookConsumerWidget {
ListTile( ListTile(
title: Text( title: Text(
data[currentEvent].name, data[currentEvent].name,
style: Theme.of(context).textTheme.headline6,
), ),
subtitle: Text( subtitle: const Text(
"Current Event", "Current Event",
style: Theme.of(context).textTheme.subtitle1,
), ),
leading: const Icon(Icons.priority_high), leading: const Icon(Icons.priority_high),
onTap: () { onTap: () {
@ -73,33 +72,17 @@ class EventListComponent extends HookConsumerWidget {
if (upcomingEvents.isNotEmpty) if (upcomingEvents.isNotEmpty)
Text( Text(
"Upcoming Events", "Upcoming Events",
style: Theme.of(context).textTheme.headline6!, style: Theme.of(context).textTheme.headlineSmall,
), ),
...upcomingEvents.map( ...upcomingEvents.map(
(e) => ListTile( (e) => EventTile(e),
title: Text(e.name),
subtitle: Text(
"${kDateFormat.format(e.start)} - ${kDateFormat.format(e.end)}"),
leading: const Icon(Icons.event),
onTap: () async {
context.go("/event/${e.id}");
},
),
), ),
if (pastEvents.isNotEmpty) if (pastEvents.isNotEmpty)
Text( Text(
"Past Events", "Past Events",
style: Theme.of(context).textTheme.headline6!, style: Theme.of(context).textTheme.headlineSmall,
), ),
...pastEvents.map((e) => ListTile( ...pastEvents.map((e) => EventTile(e)),
title: Text(e.name),
leading: const Icon(Icons.check),
subtitle: Text(
"${kDateFormat.format(e.start)} - ${kDateFormat.format(e.end)}"),
onTap: () async {
context.go("/event/${e.id}");
},
)),
], ],
); );
}, error: (err, stack) { }, error: (err, stack) {
@ -111,3 +94,27 @@ class EventListComponent extends HookConsumerWidget {
}); });
} }
} }
class EventTile extends StatelessWidget {
final ShortEvent e;
const EventTile(
this.e, {
super.key,
});
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(e.name),
subtitle: kOnlyDateFormat.format(e.start) == kOnlyDateFormat.format(e.end)
? Text(kOnlyDateFormat.format(e.start))
: Text(
"${kOnlyDateFormat.format(e.start)} - ${kOnlyDateFormat.format(e.end)}"),
leading: Icon(e.isUpcoming ? Icons.event : Icons.check),
onTap: () async {
context.go("/event/${e.id}");
},
);
}
}

Datei anzeigen

@ -55,6 +55,31 @@ class LoginScreenWidget extends HookConsumerWidget {
); );
} }
void login() async {
final dio = Dio(
BaseOptions(
baseUrl: ref.read(serverUrlProvider),
headers: {
'X-SW-Auth': keyController.text,
},
contentType: 'application/json',
),
);
try {
await dio.get('/data');
final prefs = await SharedPreferences.getInstance();
await prefs.setString("key", keyController.text);
ref.invalidate(userDataProvider);
context.go('/');
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Invalid Key'),
),
);
}
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Login'), title: const Text('Login'),
@ -77,37 +102,13 @@ class LoginScreenWidget extends HookConsumerWidget {
controller: keyController, controller: keyController,
obscureText: true, obscureText: true,
onChanged: (v) => updater.value++, onChanged: (v) => updater.value++,
onSubmitted: (v) => login(),
), ),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
FloatingActionButton.large( FloatingActionButton.large(
onPressed: keyController.text.isNotEmpty onPressed: keyController.text.isNotEmpty ? login : null,
? () async {
final dio = Dio(
BaseOptions(
baseUrl: ref.read(serverUrlProvider),
headers: {
'X-SW-Auth': keyController.text,
},
contentType: 'application/json',
),
);
try {
await dio.get('/data');
final prefs = await SharedPreferences.getInstance();
await prefs.setString("key", keyController.text);
ref.invalidate(userDataProvider);
context.go('/');
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Invalid Key'),
),
);
}
}
: null,
child: const Icon(Icons.forward), child: const Icon(Icons.forward),
) )
], ],

Datei anzeigen

@ -64,6 +64,19 @@ class SettingsScreen extends HookConsumerWidget {
: null, : null,
icon: const Icon(Icons.save), icon: const Icon(Icons.save),
), ),
IconButton(
onPressed: () {
showAboutDialog(
context: context,
applicationIcon: Image.asset(
"assets/images/Icon-maskable-192.png",
fit: BoxFit.contain),
applicationName: "SteamWar MultiTool",
applicationVersion: "1.0.0",
applicationLegalese: "© 2023 SteamWar.de-Serverteam",
);
},
icon: Icon(Icons.apps))
], ],
leading: IconButton( leading: IconButton(
onPressed: () => context.go("/"), onPressed: () => context.go("/"),

Datei anzeigen

@ -22,3 +22,5 @@ import 'package:intl/intl.dart';
final kDateFormat = DateFormat("dd.MM.yyyy HH:mm:ss"); final kDateFormat = DateFormat("dd.MM.yyyy HH:mm:ss");
final kTimeFormat = DateFormat('HH:mm'); final kTimeFormat = DateFormat('HH:mm');
final kOnlyDateFormat = DateFormat("dd.MM.yyyy");