♻️ Convert the activity calandar screen to sheet
This commit is contained in:
@@ -171,8 +171,8 @@
|
|||||||
"checkInResultLevel3": "Good Luck",
|
"checkInResultLevel3": "Good Luck",
|
||||||
"checkInResultLevel4": "Best Luck",
|
"checkInResultLevel4": "Best Luck",
|
||||||
"checkInActivityTitle": "{} checked in on {} and got a {}",
|
"checkInActivityTitle": "{} checked in on {} and got a {}",
|
||||||
"eventCalander": "Event Calander",
|
"eventCalendar": "Event Calendar",
|
||||||
"eventCalanderEmpty": "No events on that day.",
|
"eventCalendarEmpty": "No events on that day.",
|
||||||
"fortuneGraph": "Fortune Trend",
|
"fortuneGraph": "Fortune Trend",
|
||||||
"noFortuneData": "No fortune data available for this month.",
|
"noFortuneData": "No fortune data available for this month.",
|
||||||
"creatorHub": "Creator Hub",
|
"creatorHub": "Creator Hub",
|
||||||
|
@@ -58,7 +58,6 @@ import 'package:island/screens/settings.dart';
|
|||||||
import 'package:island/screens/realm/realms.dart';
|
import 'package:island/screens/realm/realms.dart';
|
||||||
import 'package:island/screens/realm/realm_form.dart';
|
import 'package:island/screens/realm/realm_form.dart';
|
||||||
import 'package:island/screens/realm/realm_detail.dart';
|
import 'package:island/screens/realm/realm_detail.dart';
|
||||||
import 'package:island/screens/account/event_calendar.dart';
|
|
||||||
import 'package:island/screens/discovery/realms.dart';
|
import 'package:island/screens/discovery/realms.dart';
|
||||||
import 'package:island/screens/reports/report_detail.dart';
|
import 'package:island/screens/reports/report_detail.dart';
|
||||||
import 'package:island/screens/reports/report_list.dart';
|
import 'package:island/screens/reports/report_list.dart';
|
||||||
@@ -138,14 +137,6 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
path: '/logs',
|
path: '/logs',
|
||||||
builder: (context, state) => TalkerScreen(talker: talker),
|
builder: (context, state) => TalkerScreen(talker: talker),
|
||||||
),
|
),
|
||||||
GoRoute(
|
|
||||||
name: 'accountCalendar',
|
|
||||||
path: '/account/:name/calendar',
|
|
||||||
builder: (context, state) {
|
|
||||||
final name = state.pathParameters['name']!;
|
|
||||||
return EventCalanderScreen(name: name);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
// Web articles
|
// Web articles
|
||||||
GoRoute(
|
GoRoute(
|
||||||
|
@@ -97,9 +97,7 @@ class _AccountBasicInfo extends StatelessWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
SharePlus.instance.share(
|
SharePlus.instance.share(
|
||||||
ShareParams(
|
ShareParams(uri: Uri.parse('https://solian.app/@${data.name}')),
|
||||||
uri: Uri.parse('https://solian.app/@${data.name}'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(Symbols.share),
|
icon: const Icon(Symbols.share),
|
||||||
@@ -879,7 +877,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
child: Card(
|
child: Card(
|
||||||
child: FortuneGraphWidget(
|
child: FortuneGraphWidget(
|
||||||
events: accountEvents,
|
events: accountEvents,
|
||||||
eventCalanderUser: data.name,
|
eventCalandarUser: data.name,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1004,7 +1002,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
child: Card(
|
child: Card(
|
||||||
child: FortuneGraphWidget(
|
child: FortuneGraphWidget(
|
||||||
events: accountEvents,
|
events: accountEvents,
|
||||||
eventCalanderUser: data.name,
|
eventCalandarUser: data.name,
|
||||||
),
|
),
|
||||||
).padding(horizontal: 4),
|
).padding(horizontal: 4),
|
||||||
),
|
),
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
@@ -6,14 +5,24 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:island/pods/event_calendar.dart';
|
import 'package:island/pods/event_calendar.dart';
|
||||||
import 'package:island/screens/account/profile.dart';
|
import 'package:island/screens/account/profile.dart';
|
||||||
import 'package:island/widgets/account/account_nameplate.dart';
|
import 'package:island/widgets/account/account_nameplate.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
|
||||||
import 'package:island/widgets/account/event_calendar.dart';
|
import 'package:island/widgets/account/event_calendar.dart';
|
||||||
import 'package:island/widgets/account/fortune_graph.dart';
|
import 'package:island/widgets/account/fortune_graph.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
class EventCalanderScreen extends HookConsumerWidget {
|
/// A reusable content widget for event calendar that can be used in screens or sheets
|
||||||
|
/// This widget manages the calendar state and displays the calendar and fortune graph
|
||||||
|
class EventCalendarContent extends HookConsumerWidget {
|
||||||
|
/// Username to fetch calendar for, null means current user ('me')
|
||||||
final String name;
|
final String name;
|
||||||
const EventCalanderScreen({super.key, required this.name});
|
|
||||||
|
/// Whether this is being displayed in a sheet (affects layout)
|
||||||
|
final bool isSheet;
|
||||||
|
|
||||||
|
const EventCalendarContent({
|
||||||
|
super.key,
|
||||||
|
required this.name,
|
||||||
|
this.isSheet = false,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -45,13 +54,37 @@ class EventCalanderScreen extends HookConsumerWidget {
|
|||||||
selectedDay.value = day;
|
selectedDay.value = day;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AppScaffold(
|
if (isSheet) {
|
||||||
isNoBackground: false,
|
// Sheet layout - simplified, no app bar, scrollable content
|
||||||
appBar: AppBar(
|
return SingleChildScrollView(
|
||||||
leading: const PageBackButton(),
|
child: Column(
|
||||||
title: Text('eventCalander').tr(),
|
children: [
|
||||||
),
|
// Use the reusable EventCalendarWidget
|
||||||
body: SingleChildScrollView(
|
EventCalendarWidget(
|
||||||
|
events: events,
|
||||||
|
initialDate: now,
|
||||||
|
showEventDetails: true,
|
||||||
|
onMonthChanged: onMonthChanged,
|
||||||
|
onDaySelected: onDaySelected,
|
||||||
|
),
|
||||||
|
|
||||||
|
// Add the fortune graph widget
|
||||||
|
const Divider(height: 1),
|
||||||
|
FortuneGraphWidget(
|
||||||
|
events: events,
|
||||||
|
onPointSelected: onDaySelected,
|
||||||
|
).padding(horizontal: 8, vertical: 4),
|
||||||
|
|
||||||
|
// Show user profile if viewing someone else's calendar
|
||||||
|
if (name != 'me' && user.value != null)
|
||||||
|
AccountNameplate(name: name),
|
||||||
|
Gap(MediaQuery.of(context).padding.bottom + 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Screen layout - with responsive design
|
||||||
|
return SingleChildScrollView(
|
||||||
child:
|
child:
|
||||||
MediaQuery.of(context).size.width > 480
|
MediaQuery.of(context).size.width > 480
|
||||||
? ConstrainedBox(
|
? ConstrainedBox(
|
||||||
@@ -111,7 +144,7 @@ class EventCalanderScreen extends HookConsumerWidget {
|
|||||||
Gap(MediaQuery.of(context).padding.bottom + 16),
|
Gap(MediaQuery.of(context).padding.bottom + 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -76,10 +76,17 @@ class EventDetailsWidget extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if ((getActivityTitle(status.label, status.meta) ?? status.label).isNotEmpty)
|
if ((getActivityTitle(status.label, status.meta) ??
|
||||||
Text(getActivityTitle(status.label, status.meta) ?? status.label),
|
status.label)
|
||||||
|
.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
getActivityTitle(status.label, status.meta) ??
|
||||||
|
status.label,
|
||||||
|
),
|
||||||
if (getActivitySubtitle(status.meta) != null)
|
if (getActivitySubtitle(status.meta) != null)
|
||||||
Text(getActivitySubtitle(status.meta)!).fontSize(11).opacity(0.8),
|
Text(
|
||||||
|
getActivitySubtitle(status.meta)!,
|
||||||
|
).fontSize(11).opacity(0.8),
|
||||||
Text(
|
Text(
|
||||||
'${status.createdAt.formatSystem()} - ${status.clearedAt?.formatSystem() ?? 'present'.tr()}',
|
'${status.createdAt.formatSystem()} - ${status.clearedAt?.formatSystem() ?? 'present'.tr()}',
|
||||||
).fontSize(11).opacity(0.8),
|
).fontSize(11).opacity(0.8),
|
||||||
@@ -92,7 +99,7 @@ class EventDetailsWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (event?.checkInResult == null && (event?.statuses.isEmpty ?? true))
|
if (event?.checkInResult == null && (event?.statuses.isEmpty ?? true))
|
||||||
Text('eventCalanderEmpty').tr(),
|
Text('eventCalandarEmpty').tr(),
|
||||||
],
|
],
|
||||||
).padding(vertical: 24, horizontal: 24);
|
).padding(vertical: 24, horizontal: 24);
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/activity.dart';
|
import 'package:island/models/activity.dart';
|
||||||
|
import 'package:island/widgets/account/event_calendar_content.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
/// A widget that displays a graph of fortune levels over time
|
/// A widget that displays a graph of fortune levels over time
|
||||||
@@ -24,7 +25,7 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
|||||||
/// Callback when a point is selected
|
/// Callback when a point is selected
|
||||||
final void Function(DateTime)? onPointSelected;
|
final void Function(DateTime)? onPointSelected;
|
||||||
|
|
||||||
final String? eventCalanderUser;
|
final String? eventCalandarUser;
|
||||||
|
|
||||||
final EdgeInsets? margin;
|
final EdgeInsets? margin;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
|||||||
this.maxWidth = double.infinity,
|
this.maxWidth = double.infinity,
|
||||||
this.height = 180,
|
this.height = 180,
|
||||||
this.onPointSelected,
|
this.onPointSelected,
|
||||||
this.eventCalanderUser,
|
this.eventCalandarUser,
|
||||||
this.margin,
|
this.margin,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text('fortuneGraph').tr().fontSize(18).bold(),
|
Text('fortuneGraph').tr().fontSize(18).bold(),
|
||||||
if (eventCalanderUser != null)
|
if (eventCalandarUser != null)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.calendar_month, size: 20),
|
icon: const Icon(Icons.calendar_month, size: 20),
|
||||||
visualDensity: const VisualDensity(
|
visualDensity: const VisualDensity(
|
||||||
@@ -69,9 +70,17 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
|||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
constraints: const BoxConstraints(),
|
constraints: const BoxConstraints(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.pushNamed(
|
showModalBottomSheet(
|
||||||
'accountCalendar',
|
context: context,
|
||||||
pathParameters: {'name': eventCalanderUser!},
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => SheetScaffold(
|
||||||
|
titleText: 'eventCalendar'.tr(),
|
||||||
|
child: EventCalendarContent(
|
||||||
|
name: eventCalandarUser!,
|
||||||
|
isSheet: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@@ -5,7 +5,6 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/activity.dart';
|
import 'package:island/models/activity.dart';
|
||||||
@@ -14,6 +13,8 @@ import 'package:island/pods/userinfo.dart';
|
|||||||
import 'package:island/screens/auth/captcha.dart';
|
import 'package:island/screens/auth/captcha.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:island/widgets/account/event_calendar_content.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:slide_countdown/slide_countdown.dart';
|
import 'package:slide_countdown/slide_countdown.dart';
|
||||||
@@ -256,9 +257,17 @@ class CheckInWidget extends HookConsumerWidget {
|
|||||||
if (todayResult.valueOrNull == null) {
|
if (todayResult.valueOrNull == null) {
|
||||||
checkIn();
|
checkIn();
|
||||||
} else {
|
} else {
|
||||||
context.pushNamed(
|
showModalBottomSheet(
|
||||||
'accountCalendar',
|
context: context,
|
||||||
pathParameters: {'name': 'me'},
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => SheetScaffold(
|
||||||
|
titleText: 'eventCalendar'.tr(),
|
||||||
|
child: EventCalendarContent(
|
||||||
|
name: 'me',
|
||||||
|
isSheet: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user