👽 Update API to microservices
♻️ Refactor router pushes
This commit is contained in:
@@ -105,7 +105,7 @@ class AccountProfileCard extends HookConsumerWidget {
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/account/${data.name}');
|
||||
context.pushNamed('accountProfile', pathParameters: {'name': data.name});
|
||||
},
|
||||
icon: const Icon(Symbols.launch),
|
||||
label: Text('accountProfileView').tr(),
|
||||
|
@@ -18,7 +18,7 @@ Future<List<SnAccount>> searchAccounts(Ref ref, {required String query}) async {
|
||||
|
||||
final apiClient = ref.watch(apiClientProvider);
|
||||
final response = await apiClient.get(
|
||||
'/accounts/search',
|
||||
'/id/accounts/search',
|
||||
queryParameters: {'query': query},
|
||||
);
|
||||
|
||||
|
@@ -16,7 +16,9 @@ part 'account_session_sheet.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<List<SnAuthDevice>> authDevices(Ref ref) async {
|
||||
final resp = await ref.watch(apiClientProvider).get('/accounts/me/devices');
|
||||
final resp = await ref
|
||||
.watch(apiClientProvider)
|
||||
.get('/id/accounts/me/devices');
|
||||
final sessionId = resp.headers.value('x-auth-session');
|
||||
final data =
|
||||
resp.data.map<SnAuthDevice>((e) {
|
||||
@@ -122,7 +124,7 @@ class AccountSessionSheet extends HookConsumerWidget {
|
||||
if (!confirm || !context.mounted) return;
|
||||
try {
|
||||
final apiClient = ref.watch(apiClientProvider);
|
||||
await apiClient.delete('/accounts/me/sessions/$sessionId');
|
||||
await apiClient.delete('/id/accounts/me/sessions/$sessionId');
|
||||
ref.invalidate(authDevicesProvider);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -6,7 +6,7 @@ part of 'account_session_sheet.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$authDevicesHash() => r'19807110962206a9637075d03cd372233cae2f49';
|
||||
String _$authDevicesHash() => r'8bc41a1ffc37df8e757c977b4ddae11db8faaeb5';
|
||||
|
||||
/// See also [authDevices].
|
||||
@ProviderFor(authDevices)
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/models/activity.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:island/widgets/account/event_details_widget.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
/// A reusable widget for displaying an event calendar with event details
|
||||
@@ -123,57 +122,10 @@ class EventCalendarWidget extends HookConsumerWidget {
|
||||
events.value
|
||||
?.where((e) => isSameDay(e.date, selectedDay.value))
|
||||
.firstOrNull;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(DateFormat.EEEE().format(selectedDay.value))
|
||||
.fontSize(16)
|
||||
.bold()
|
||||
.textColor(
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
Text(DateFormat.yMd().format(selectedDay.value))
|
||||
.fontSize(12)
|
||||
.textColor(
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
const Gap(16),
|
||||
if (event?.checkInResult != null)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'checkInResultLevel${event!.checkInResult!.level}',
|
||||
).tr().fontSize(16).bold(),
|
||||
for (final tip in event.checkInResult!.tips)
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(
|
||||
Symbols.circle,
|
||||
size: 12,
|
||||
fill: 1,
|
||||
).padding(top: 4, right: 4),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(tip.title).bold(),
|
||||
Text(tip.content),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
).padding(top: 8),
|
||||
],
|
||||
),
|
||||
if (event?.checkInResult == null &&
|
||||
(event?.statuses.isEmpty ?? true))
|
||||
Text('eventCalanderEmpty').tr(),
|
||||
],
|
||||
).padding(vertical: 24, horizontal: 24);
|
||||
return EventDetailsWidget(
|
||||
selectedDay: selectedDay.value,
|
||||
event: event,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
63
lib/widgets/account/event_details_widget.dart
Normal file
63
lib/widgets/account/event_details_widget.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:island/models/activity.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class EventDetailsWidget extends StatelessWidget {
|
||||
final DateTime selectedDay;
|
||||
final SnEventCalendarEntry? event;
|
||||
|
||||
const EventDetailsWidget({
|
||||
super.key,
|
||||
required this.selectedDay,
|
||||
required this.event,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(DateFormat.EEEE().format(selectedDay))
|
||||
.fontSize(16)
|
||||
.bold()
|
||||
.textColor(Theme.of(context).colorScheme.onSecondaryContainer),
|
||||
Text(DateFormat.yMd().format(selectedDay))
|
||||
.fontSize(12)
|
||||
.textColor(Theme.of(context).colorScheme.onSecondaryContainer),
|
||||
const Gap(16),
|
||||
if (event?.checkInResult != null)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'checkInResultLevel${event!.checkInResult!.level}',
|
||||
).tr().fontSize(16).bold(),
|
||||
for (final tip in event!.checkInResult!.tips)
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(
|
||||
Symbols.circle,
|
||||
size: 12,
|
||||
fill: 1,
|
||||
).padding(top: 4, right: 4),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [Text(tip.title).bold(), Text(tip.content)],
|
||||
),
|
||||
),
|
||||
],
|
||||
).padding(top: 8),
|
||||
],
|
||||
),
|
||||
if (event?.checkInResult == null && (event?.statuses.isEmpty ?? true))
|
||||
Text('eventCalanderEmpty').tr(),
|
||||
],
|
||||
).padding(vertical: 24, horizontal: 24);
|
||||
}
|
||||
}
|
@@ -17,7 +17,7 @@ part 'status.g.dart';
|
||||
Future<SnAccountStatus?> accountStatus(Ref ref, String uname) async {
|
||||
final apiClient = ref.watch(apiClientProvider);
|
||||
try {
|
||||
final resp = await apiClient.get('/accounts/$uname/statuses');
|
||||
final resp = await apiClient.get('/id/accounts/$uname/statuses');
|
||||
return SnAccountStatus.fromJson(resp.data);
|
||||
} catch (err) {
|
||||
if (err is DioException) {
|
||||
|
@@ -6,7 +6,7 @@ part of 'status.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$accountStatusHash() => r'8c3ba5242da1d1e75e3cbf1f2934ff7d5683d0d6';
|
||||
String _$accountStatusHash() => r'c861a0565d6229fd35666bba7cb2f5c6b7298e46';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
@@ -32,7 +32,7 @@ class AccountStatusCreationSheet extends HookConsumerWidget {
|
||||
submitting.value = true;
|
||||
final user = ref.watch(userInfoProvider);
|
||||
final apiClient = ref.read(apiClientProvider);
|
||||
await apiClient.delete('/accounts/me/statuses');
|
||||
await apiClient.delete('/id/accounts/me/statuses');
|
||||
if (!context.mounted) return;
|
||||
ref.invalidate(accountStatusProvider(user.value!.name));
|
||||
Navigator.pop(context);
|
||||
|
Reference in New Issue
Block a user