Skip to content

Commit

Permalink
Merge branch 'main' into prod/festapp
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Nov 5, 2024
2 parents c74f981 + d2d51f8 commit deed739
Show file tree
Hide file tree
Showing 18 changed files with 383 additions and 145 deletions.
1 change: 1 addition & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,6 @@
"To create accommodation, fill in the title, unique code, and the reference of the place.": "To create accommodation, fill in the title, unique code, and the reference of the place.",
"Food": "Food",
"To create food, fill in the title, unique code, and the reference of the event.": "To create food, fill in the title, unique code, and the reference of the event.",
"Not specified": "Not specified",
"_":"_"
}
6 changes: 3 additions & 3 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app requires access to your location to display your current position on the map.</string>
<string>Your location is used to provide a customized map experience, showing relevant information and navigation based on your position.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app requires access to your location to display your current position on the map.</string>
<string>Your location is used to provide a customized map experience, showing relevant information and navigation based on your position.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires access to your location to display your current position on the map.</string>
<string>Your location is used to provide a customized map experience, showing relevant information and navigation based on your position.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app does not require access to the microphone.</string>
<key>NSPhotoLibraryUsageDescription</key>
Expand Down
6 changes: 3 additions & 3 deletions lib/AppRouter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ class AppRouter extends RootStackRouter {
AutoRoute(page: SettingsRoute.page, path: sl(SettingsPage.ROUTE)),
AutoRoute(page: InstallRoute.page, path: sl(InstallPage.ROUTE)),
AutoRoute(page: AdminDashboardRoute.page, path: sl(AdminDashboardPage.ROUTE)),
AutoRoute(page: UserRoute.page, path: "/:{$LINK}/${UserPage.ROUTE}"),
AutoRoute(page: CheckRoute.page, path: "/:{$LINK}/${CheckPage.ROUTE}/:id"),
AutoRoute(page: NewsFormRoute.page, path: "/:{$LINK}/${NewsFormPage.ROUTE}"),
AutoRoute(page: HtmlEditorRoute.page, path: "/:{$LINK}/${HtmlEditorPage.ROUTE}"),
AutoRoute(page: AdminRoute.page, path: "/:{$LINK}/${AdminPage.ROUTE}"),
AutoRoute(page: MyScheduleRoute.page, path: "/:{$LINK}/${MySchedulePage.ROUTE}"),
AutoRoute(page: ProgramViewRoute.page, path: "/:{$LINK}/${ProgramViewPage.ROUTE}"),
AutoRoute(page: HomeRoute.page, path: "/:{$LINK}", children: [
AutoRoute(page: ScheduleNavigationRoute.page, path: EventPage.ROUTE, children: [
AutoRoute(page: UserRoute.page, path: "${UserPage.ROUTE}"),
AutoRoute(page: ScheduleNavigationRoute.page, path: EventPage.ROUTE, children: [
AutoRoute(page: ScheduleRoute.page, path: "", initial: true),
AutoRoute(page: EventRoute.page, path: ":id")
]),
AutoRoute(page: NewsRoute.page, path: "${NewsPage.ROUTE}"),
AutoRoute(page: ProgramViewRoute.page, path: "${ProgramViewPage.ROUTE}"),
AutoRoute(page: SongRoute.page, path: "${SongPage.ROUTE}"),
AutoRoute(page: MapRoute.page, path: "${MapPage.ROUTE}", children: [
AutoRoute(path: ':id', page: MapRoute.page,),
Expand Down
2 changes: 1 addition & 1 deletion lib/RouterService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class RouterService {

static Future<bool> updateOccasionFromLink(String newLink) async {
bool canContinue = true;
var checkedObject = await SynchroService.getOccasionFromLink(newLink);
var checkedObject = await SynchroService.getAppConfig(newLink);
RightsService.currentUserOccasion = checkedObject.user;
RightsService.currentOccasion = checkedObject.occasionId;
RightsService.currentLink = checkedObject.link;
Expand Down
1 change: 1 addition & 0 deletions lib/appConfig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AppConfig {
static const String webLink = "https://live.festapp.net";
static const String appStoreLink = "https://apps.apple.com/us/app/festapp/id6474078383";
static const String playStoreLink = "";
static const String playStoreLaunchLink = "";
static const String desktopAppLink = "";
static bool isProLicense = true;

Expand Down
9 changes: 8 additions & 1 deletion lib/dataModels/UserInfoModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,15 @@ class UserInfoModel {
bool isSignedIn = false;


static String sexToLocale(String? sx) => sx == "male" ? "Male".tr() : "Female".tr();
static String sexToLocale(String? sx) {
if (sx == "female") {
return "Female".tr();
} else if (sx == "male") {
return "Male".tr();
}

return "Not specified".tr();
}
bool importedEquals(Map<String, dynamic> u) {
return
u[emailReadonlyColumn].toString().trim().toLowerCase() == email
Expand Down
28 changes: 23 additions & 5 deletions lib/dataServices/AppConfigService.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/foundation.dart' show kIsWeb, defaultTargetPlatform;
import 'package:fstapp/appConfig.dart';
import 'package:fstapp/services/PlatformHelper.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:fstapp/services/DialogHelper.dart';
import 'dart:html' as html;
import 'package:url_launcher/url_launcher.dart';

class AppConfigService {
static String? versionRecommended;
static bool alreadyChecked = false;
static bool isVersionChecking = false;

static Future<void> versionCheck(BuildContext context) async {
if (!kIsWeb || alreadyChecked || isVersionChecking) return;
if (alreadyChecked || isVersionChecking) return;

isVersionChecking = true;

Expand All @@ -24,11 +26,11 @@ class AppConfigService {
context,
"New Version Available".tr(),
"Update the app to the latest version to access all features.".tr(),
confirmButtonMessage: "Update".tr()
confirmButtonMessage: "Update".tr()
);

if (updateConfirmed) {
html.window.location.reload();
_redirectToUpdate();
} else {
alreadyChecked = true;
}
Expand All @@ -54,4 +56,20 @@ class AppConfigService {
}
return false;
}

static void _redirectToUpdate() {
if (PlatformHelper.isWeb) {
_launchURL(AppConfig.webLink);
} else if (PlatformHelper.isAndroid) {
_launchURL(AppConfig.playStoreLaunchLink);
} else if (PlatformHelper.isIOS) {
_launchURL(AppConfig.appStoreLink);
}
}

static Future<void> _launchURL(String url) async {
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
}
}
}
15 changes: 9 additions & 6 deletions lib/dataServices/SynchroService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:fstapp/dataServices/DbNews.dart';
import 'package:fstapp/dataServices/DbPlaces.dart';
import 'package:fstapp/dataServices/OfflineDataService.dart';
import 'package:fstapp/dataServices/RightsService.dart';
import 'package:fstapp/services/PlatformHelper.dart';
import 'package:pwa_install/pwa_install.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

Expand Down Expand Up @@ -60,7 +61,7 @@ class SynchroService {
var messages = await DbNews.getAllNewsMessages();
await OfflineDataService.saveAllMessages(messages);

if (isPwaInstalledOrNative() )
if (PlatformHelper.isPwaInstalledOrNative())
{
await DbEvents.updateEventDescriptions();
await DbInformation.updateInfoDescription();
Expand All @@ -69,11 +70,13 @@ class SynchroService {
await DbEvents.synchronizeMySchedule();
}

static bool isPwaInstalledOrNative() => !const bool.fromEnvironment('dart.library.js_util') || PWAInstall().launchMode!.installed;

static Future<OccasionLinkModel> getOccasionFromLink(String link) async {
var data = await _supabase.rpc("get_occasion_from_link",
params: {"link_txt": link, "org_id": AppConfig.organization});
static Future<OccasionLinkModel> getAppConfig(String link) async {
var data = await _supabase.rpc("get_app_config",
params: {"data_in": {
"link": link,
"organization": AppConfig.organization,
"platform": await PlatformHelper.getPlatform()
}});
return OccasionLinkModel.fromJson(data);
}

Expand Down
39 changes: 29 additions & 10 deletions lib/pages/HomePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import 'package:auto_route/auto_route.dart';
import 'package:badges/badges.dart' as badges;
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:fstapp/AppRouter.dart';
import 'package:fstapp/AppRouter.gr.dart';
import 'package:fstapp/RouterService.dart';
import 'package:fstapp/appConfig.dart';
import 'package:fstapp/dataServices/AppConfigService.dart';
import 'package:fstapp/dataServices/AuthService.dart';
import 'package:fstapp/dataServices/DbNews.dart';
import 'package:fstapp/dataServices/DbUsers.dart';
import 'package:fstapp/dataServices/OfflineDataService.dart';
import 'package:fstapp/pages/LoginPage.dart';
import 'package:fstapp/pages/UserPage.dart';
import 'package:fstapp/services/DialogHelper.dart';
import 'package:fstapp/services/NotificationHelper.dart';
import 'package:fstapp/services/StylesHelper.dart';
Expand All @@ -28,7 +33,7 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
String userName = "";
String? userName;
int _messageCount = 0;
int currentPageIndex = 0;

Expand Down Expand Up @@ -59,6 +64,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
}

Future<void> loadData() async {
await loadOfflineData();
await AppConfigService.versionCheck(context);
if (AuthService.isLoggedIn()) {
DbUsers.getCurrentUserInfo().then((value) => setState(() => userName = value.name!));
Expand All @@ -68,17 +74,26 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
await NotificationHelper.checkForNotificationPermission(context);
}

Future<void> loadOfflineData() async {
if (AuthService.isLoggedIn()) {
var userInfo = await OfflineDataService.getUserInfo();
setState(() {
userName = userInfo?.name;
});
}
}

String messageCountString() => _messageCount < 100 ? _messageCount.toString() : "99+";

@override
Widget build(BuildContext context) {
return AutoTabsRouter(
routes: [
ScheduleNavigationRoute(),
ProgramViewRoute(),
NewsRoute(),
MapRoute(),
InfoRoute(),
UserRoute(),
],
builder: (context, child) {
final tabsRouter = AutoTabsRouter.of(context);
Expand All @@ -90,21 +105,20 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
currentIndex: tabsRouter.activeIndex,
type: BottomNavigationBarType.fixed,
onTap: (int index) {
setState(() {
tabsRouter.setActiveIndex(index);
});
if(!AuthService.isLoggedIn() && index == 4){
RouterService.navigate(context, LoginPage.ROUTE);
} else{
setState(() {
tabsRouter.setActiveIndex(index);
});
}
},
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined),
activeIcon: Icon(Icons.home),
label: "Home".tr(),
),
BottomNavigationBarItem(
icon: Icon(Icons.calendar_month_outlined),
activeIcon: Icon(Icons.calendar_month),
label: "Schedule".tr(),
),
BottomNavigationBarItem(
icon: badges.Badge(
showBadge: _messageCount > 0,
Expand Down Expand Up @@ -134,6 +148,11 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
activeIcon: Icon(Icons.info),
label: "Info".tr(),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle_outlined),
activeIcon: Icon(Icons.account_circle),
label: AuthService.currentUser?.name??userName??"Sign in".tr(),
),
],
),
body: child,
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/InstallPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:fstapp/RouterService.dart';
import 'package:fstapp/appConfig.dart';
import 'package:fstapp/dataServices/SynchroService.dart';
import 'package:fstapp/services/PlatformHelper.dart';
import 'package:fstapp/themeConfig.dart';
import 'package:fstapp/widgets/ButtonsHelper.dart';
import 'package:fstapp/styles/Styles.dart';
Expand Down Expand Up @@ -37,7 +37,7 @@ class _InstallPageState extends State<InstallPage> {
}

Future<void> loadSettings() async {
bool isAppInstalled = SynchroService.isPwaInstalledOrNative();
bool isAppInstalled = PlatformHelper.isPwaInstalledOrNative();

setState(() {
_isAppInstalled = isAppInstalled;
Expand Down
49 changes: 15 additions & 34 deletions lib/pages/SchedulePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import 'package:fstapp/dataServices/OfflineDataService.dart';
import 'package:fstapp/dataServices/RightsService.dart';
import 'package:fstapp/pages/EventPage.dart';
import 'package:fstapp/pages/LoginPage.dart';
import 'package:fstapp/pages/MySchedulePage.dart';
import 'package:fstapp/pages/TimetablePage.dart';
import 'package:fstapp/pages/UserPage.dart';
import 'package:fstapp/services/TimeHelper.dart';
import 'package:fstapp/services/ToastHelper.dart';
Expand Down Expand Up @@ -118,12 +120,8 @@ class _SchedulePageState extends State<SchedulePage> with WidgetsBindingObserver
}
}

void _loginPressed() {
RouterService.navigate(context, LoginPage.ROUTE).then((value) => loadData());
}

void _profileButtonPressed() {
RouterService.navigateOccasion(context, UserPage.ROUTE).then((value) => loadData());
void _schedulePressed() {
RouterService.navigateOccasion(context, ProgramViewPage.ROUTE).then((value) => loadData());
}

void _eventPressed(int id) {
Expand Down Expand Up @@ -165,35 +163,18 @@ class _SchedulePageState extends State<SchedulePage> with WidgetsBindingObserver
),
),
const Spacer(),
Visibility(
visible: !AuthService.isLoggedIn(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CircularButton(
onPressed: _loginPressed,
backgroundColor: ThemeConfig.profileButtonColor(context),
child: Icon(Icons.login, color: ThemeConfig.profileButtonTextColor(context)),
),
Text("Sign in".tr()),
],
),
),
Visibility(
visible: AuthService.isLoggedIn(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CircularButton(
onPressed: _profileButtonPressed,
backgroundColor: ThemeConfig.profileButtonColor(context),
child: Icon(Icons.account_circle_rounded, color: ThemeConfig.profileButtonTextColor(context),),
),
Text(AuthService.currentUser?.name??userName??""),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CircularButton(
onPressed: _schedulePressed,
backgroundColor: ThemeConfig.profileButtonColor(context),
child: Icon(Icons.calendar_month, color: ThemeConfig.profileButtonTextColor(context)),
),
Text("My schedule".tr()),
]
),
],
]
),
),
Expanded(
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/SettingsPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:fstapp/dataServices/SynchroService.dart';
import 'package:fstapp/services/DialogHelper.dart';
import 'package:fstapp/services/NotificationHelper.dart';
import 'package:fstapp/appConfig.dart';
import 'package:fstapp/services/PlatformHelper.dart';
import 'package:fstapp/styles/Styles.dart';
import 'package:fstapp/themeConfig.dart';
import 'package:fstapp/widgets/ButtonsHelper.dart';
Expand Down Expand Up @@ -42,7 +43,7 @@ class _SettingsPageState extends State<SettingsPage> {
bool isEnabled = await NotificationHelper.isNotificationOnOff();
Locale currentLocale = context.locale;
LanguageModel? currentLanguage = AppConfig.availableLanguages.firstWhere((language) => language.locale.languageCode == currentLocale.languageCode);
bool isAppInstalled = SynchroService.isPwaInstalledOrNative();
bool isAppInstalled = PlatformHelper.isPwaInstalledOrNative();
var themeMode = await AdaptiveTheme.getThemeMode();
setState(() {
_themeMode = themeMode;
Expand Down
Loading

0 comments on commit deed739

Please sign in to comment.