Skip to content
Merged

Dev #24

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,18 @@ class _EventDetailScreenState extends ConsumerState<EventDetailScreen> {
child: Center(child: SignUpButton(event: event)),
),
if (userAsync.hasValue && !isEditing)
isPast
? AttendanceList(
eventId: widget.id,
isAdmin: userAsync.value?.role.canEditEvent == true,
onAddAttendee: () =>
context.push(AddAttendeeScreen.getPath(widget.id)),
)
: (userAsync.value?.role.canEditEvent == true
? SliverToBoxAdapter(child: SignUpList(eventId: widget.id))
: const SliverToBoxAdapter(child: SizedBox.shrink())),
if (userAsync.hasValue && userAsync.value == null)
if (userAsync.value?.role.canEditEvent == true)
isPast
? AttendanceList(
eventId: widget.id,
isAdmin: true,
onAddAttendee: () =>
context.push(AddAttendeeScreen.getPath(widget.id)),
)
: SliverToBoxAdapter(child: SignUpList(eventId: widget.id))
else
const SliverToBoxAdapter(child: SizedBox.shrink()),
if (!isPast && userAsync.hasValue && userAsync.value == null)
SliverToBoxAdapter(
child: Padding(
padding: .only(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class _EventFeedScreenState extends ConsumerState<EventFeedScreen> {
_welcomeChecked = true;

final prefs = await ref.read(appPreferencesProvider.future);
if (prefs.getWelcomeMessageSeen()) return;

final remoteConfig = await ref.read(remoteConfigProvider.future);
final message = remoteConfig.welcomeMessage;
if (message.isEmpty) return;
if (prefs.getWelcomeMessageContent() == message) return;
if (!mounted) return;

await prefs.setWelcomeMessageSeen();
await prefs.setWelcomeMessageContent(message);
if (!mounted) return;
context.showModal(
_WelcomeMessageModal(
Expand Down Expand Up @@ -177,6 +177,15 @@ class _EventFeedScreenState extends ConsumerState<EventFeedScreen> {
}
}

if (!isAuthenticated) {
slivers.add(
SliverToBoxAdapter(
child: DashboardSectionHeader(title: loc.dashboardCalendar),
),
);
slivers.add(const SliverToBoxAdapter(child: DashboardCalendarCard()));
}

slivers.add(
SliverToBoxAdapter(
child: DashboardSectionHeader(title: loc.dashboardUpcomingEvents),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:anystep/core/features/onboarding/presentation/onboarding/welcome_screen_controller.dart';
import 'package:go_router/go_router.dart';
import 'package:anystep/l10n/generated/app_localizations.dart';
import 'package:anystep/core/features/settings/presentation/locale_setting.dart';
import 'package:anystep/core/features/settings/presentation/widgets/locale_setting.dart';

/// Multi-page onboarding / welcome flow.
/// Shows 4 pages in a PageView with a dot indicator. The final page displays
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:anystep/core/config/locale/locale_controller.dart';
import 'package:anystep/core/features/settings/presentation/locale_setting.dart';
import 'package:anystep/core/features/settings/presentation/widgets/locale_setting.dart';
import 'package:anystep/l10n/generated/app_localizations.dart';
import 'package:anystep/core/common/widgets/any_step_modal.dart';
import 'package:flutter/material.dart';
Expand Down
6 changes: 4 additions & 2 deletions lib/core/features/settings/presentation/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import 'package:anystep/core/common/constants/spacing.dart';
import 'package:anystep/core/common/widgets/widgets.dart';
import 'package:anystep/core/features/auth/data/auth_repository.dart';
import 'package:anystep/core/features/screens.dart';
import 'package:anystep/core/features/settings/presentation/theme_mode_setting.dart';
import 'package:anystep/core/features/settings/presentation/locale_setting.dart';
import 'package:anystep/core/features/settings/presentation/widgets/donate_tile.dart';
import 'package:anystep/core/features/settings/presentation/widgets/theme_mode_setting.dart';
import 'package:anystep/core/features/settings/presentation/widgets/locale_setting.dart';
import 'package:anystep/l10n/generated/app_localizations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -37,6 +38,7 @@ class SettingsScreen extends ConsumerWidget {
trailing: const Icon(Icons.chevron_right),
onTap: () => context.push(AboutScreen.path),
),
const DonateTile(),
const ThemeModeSetting(),
const LocaleSetting(),
ListTile(
Expand Down
35 changes: 35 additions & 0 deletions lib/core/features/settings/presentation/widgets/donate_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:anystep/core/common/utils/log_utils.dart';
import 'package:anystep/l10n/generated/app_localizations.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class DonateTile extends StatelessWidget {
const DonateTile({super.key});

static const _donateUrl =
'https://www.zeffy.com/en-US/donation-form/high-five-for-seniors-step-up-give-back-move-forward';

Future<void> _openLink(String url) async {
final uri = Uri.tryParse(url);
if (uri == null) return;
try {
final launched = await launchUrl(uri, mode: LaunchMode.externalApplication);
if (!launched) {
Log.e('Failed to open external link: $uri');
}
} catch (e) {
Log.e('Error opening external link', e);
}
}

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return ListTile(
leading: const Icon(Icons.volunteer_activism),
title: Text(loc.donate),
trailing: const Icon(Icons.open_in_new),
onTap: () => _openLink(_donateUrl),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class LocaleSetting extends ConsumerWidget {
return ListTile(
leading: const Icon(Icons.language),
title: Text(loc.languageLabel),
subtitle: Text(_labelForLocale(current, loc)),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
11 changes: 6 additions & 5 deletions lib/core/shared_prefs/shared_prefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppPreferences {
static const String themeModeKey = 'theme_mode';
static const String localeCodeKey = 'locale_code';
static const String eventNotificationsKey = 'event_notifications';
static const String welcomeMessageSeenKey = 'welcome_message_seen';
static const String welcomeMessageContentKey = 'welcome_message_content';

String? getAuthStateJson() => _prefs.getString(authStateKey);
Future<void> setAuthStateJson(String token) async => await _prefs.setString(authStateKey, token);
Expand Down Expand Up @@ -44,10 +44,11 @@ class AppPreferences {
Future<void> clearEventNotificationsEnabled() async =>
await _prefs.remove(eventNotificationsKey);

bool getWelcomeMessageSeen() => _prefs.getBool(welcomeMessageSeenKey) ?? false;
Future<void> setWelcomeMessageSeen({bool seen = true}) async =>
await _prefs.setBool(welcomeMessageSeenKey, seen);
Future<void> clearWelcomeMessageSeen() async => await _prefs.remove(welcomeMessageSeenKey);
String? getWelcomeMessageContent() => _prefs.getString(welcomeMessageContentKey);
Future<void> setWelcomeMessageContent(String message) async =>
await _prefs.setString(welcomeMessageContentKey, message);
Future<void> clearWelcomeMessageContent() async =>
await _prefs.remove(welcomeMessageContentKey);
}

@Riverpod(keepAlive: true)
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
,
"settingsTitle": "Settings",
"@settingsTitle": {"description": "Title for the Settings screen app bar"},
"donate": "Donate",
"@donate": {"description": "Label for the donate link in settings"},
"themeLabel": "Theme",
"@themeLabel": {"description": "Settings tile label for theme selection"},
"themeAuto": "Auto",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
,
"settingsTitle": "Configuración",
"@settingsTitle": {"description": "Título de la pantalla de configuración"},
"donate": "Donar",
"@donate": {"description": "Etiqueta del enlace de donación en configuración"},
"themeLabel": "Tema",
"@themeLabel": {"description": "Etiqueta para selección de tema"},
"themeAuto": "Automático",
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/generated/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ abstract class AppLocalizations {
/// **'Settings'**
String get settingsTitle;

/// Label for the donate link in settings
///
/// In en, this message translates to:
/// **'Donate'**
String get donate;

/// Settings tile label for theme selection
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/generated/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get settingsTitle => 'Settings';

@override
String get donate => 'Donate';

@override
String get themeLabel => 'Theme';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/generated/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get settingsTitle => 'Configuración';

@override
String get donate => 'Donar';

@override
String get themeLabel => 'Tema';

Expand Down