Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

feat: add hint for mobile swipe action (#608)

Miguel Ribeiro49666f867cdb
diff --git a/endpoints/admin/adduser.php b/endpoints/admin/adduser.php
index 44bf243..82074a2 100644
--- a/endpoints/admin/adduser.php
+++ b/endpoints/admin/adduser.php
@@ -235,8 +235,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$stmt->execute();
// Add settings for that user
- $query = "INSERT INTO settings (dark_theme, monthly_price, convert_currency, remove_background, color_theme, hide_disabled, user_id)
- VALUES (2, 0, 0, 0, 'blue', 0, :user_id)";
+ $query = "INSERT INTO settings (dark_theme, monthly_price, convert_currency, remove_background, color_theme, hide_disabled, user_id, disabled_to_bottom, show_original_price, mobile_nav)
+ VALUES (2, 0, 0, 0, 'blue', 0, :user_id, 0, 0, 0)";
$stmt = $db->prepare($query);
$stmt->bindValue(':user_id', $newUserId, SQLITE3_INTEGER);
$stmt->execute();
diff --git a/images/siteimages/mobilenav.png b/images/siteimages/mobilenav.png
new file mode 100644
index 0000000..cb4e0f6
Binary files /dev/null and b/images/siteimages/mobilenav.png differ
diff --git a/images/siteimages/mobilenavdark.png b/images/siteimages/mobilenavdark.png
new file mode 100644
index 0000000..2ef2032
Binary files /dev/null and b/images/siteimages/mobilenavdark.png differ
diff --git a/includes/header.php b/includes/header.php
index 77537f7..194bc9d 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -72,12 +72,11 @@ function hex2rgb($hex)
return "$r, $g, $b";
}
-$mobileNavigation = $settings['mobile_nav'] ? "mobile-navivagtion" : "";
+$mobileNavigation = $settings['mobile_nav'] ? "mobile-navigation" : "";
?>
<!DOCTYPE html>
<html dir="<?= $languages[$lang]['dir'] ?>">
-
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
@@ -106,7 +105,7 @@ $mobileNavigation = $settings['mobile_nav'] ? "mobile-navivagtion" : "";
window.update_theme_settings = "<?= $updateThemeSettings ?>";
window.lang = "<?= $lang ?>";
window.colorTheme = "<?= $colorTheme ?>";
- window.mobileNavigation = "<?= $mobileNavigation !== "" ?>";
+ window.mobileNavigation = "<?= $settings['mobileNavigation'] == "true" ?>";
</script>
<style>
<?= htmlspecialchars($customCss, ENT_QUOTES, 'UTF-8') ?>
diff --git a/registration.php b/registration.php
index 7e08e5c..2488096 100644
--- a/registration.php
+++ b/registration.php
@@ -268,8 +268,8 @@ if (isset($_POST['username'])) {
$stmt->execute();
// Add settings for that user
- $query = "INSERT INTO settings (dark_theme, monthly_price, convert_currency, remove_background, color_theme, hide_disabled, user_id)
- VALUES (2, 0, 0, 0, 'blue', 0, :user_id)";
+ $query = "INSERT INTO settings (dark_theme, monthly_price, convert_currency, remove_background, color_theme, hide_disabled, user_id, disabled_to_bottom, show_original_price, mobile_nav)
+ VALUES (2, 0, 0, 0, 'blue', 0, :user_id, 0, 0, 0)";
$stmt = $db->prepare($query);
$stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);
$stmt->execute();
diff --git a/scripts/common.js b/scripts/common.js
index 35a0b5c..f884a7f 100644
--- a/scripts/common.js
+++ b/scripts/common.js
@@ -78,7 +78,11 @@ document.addEventListener('DOMContentLoaded', function () {
const themePreference = prefersDarkMode ? 'dark' : 'light';
const darkThemeCss = document.querySelector("#dark-theme");
darkThemeCss.disabled = themePreference === 'light';
- document.body.className = themePreference;
+
+ // Preserve existing classes on the body tag
+ const existingClasses = document.body.className.split(' ').filter(cls => cls !== 'dark' && cls !== 'light');
+ document.body.className = [...existingClasses, themePreference].join(' ');
+
document.cookie = `inUseTheme=${themePreference}; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict`;
const themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
themeColorMetaTag.setAttribute('content', themePreference === 'dark' ? '#222222' : '#FFFFFF');
@@ -97,4 +101,15 @@ document.addEventListener('DOMContentLoaded', function () {
document.querySelector('.dropdown-content').addEventListener('focus', function () {
isDropdownOpen = true;
});
-});
\ No newline at end of file
+});
+
+function getCookie(name) {
+ const cookies = document.cookie.split(';');
+ for (let cookie of cookies) {
+ cookie = cookie.trim();
+ if (cookie.startsWith(`${name}=`)) {
+ return cookie.substring(name.length + 1);
+ }
+ }
+ return null;
+}
\ No newline at end of file
diff --git a/scripts/dashboard.js b/scripts/dashboard.js
index 80d4304..ec54d98 100644
--- a/scripts/dashboard.js
+++ b/scripts/dashboard.js
@@ -194,7 +194,7 @@ function deleteSubscription(event, id) {
.then(response => {
if (response.ok) {
showSuccessMessage(translate('subscription_deleted'));
- fetchSubscriptions();
+ fetchSubscriptions(null, null, "delete");
closeAddSubscription();
} else {
showErrorMessage(translate('error_deleting_subscription'));
@@ -222,7 +222,7 @@ function cloneSubscription(event, id) {
.then(data => {
if (data.success) {
const id = data.id;
- fetchSubscriptions(id, event);
+ fetchSubscriptions(id, event, "clone");
showSuccessMessage(decodeURI(data.message));
} else {
showErrorMessage(data.message || translate('error'));
@@ -303,7 +303,7 @@ function closeLogoSearch() {
logoResults.innerHTML = "";
}
-function fetchSubscriptions(id, event) {
+function fetchSubscriptions(id, event, initiator) {
const subscriptionsContainer = document.querySelector("#subscriptions");
let getSubscriptions = "endpoints/subscriptions/get.php";
@@ -333,11 +333,18 @@ function fetchSubscriptions(id, event) {
}
}
- if (id && event) {
+ if (initiator == "clone" && id && event) {
openEditSubscription(event, id);
}
setSwipeElements();
+ if (initiator === "add") {
+ if (document.getElementsByClassName('subscription').length === 1) {
+ setTimeout(() => {
+ swipeHintAnimation();
+ }, 1000);
+ }
+ }
})
.catch(error => {
console.error(translate('error_reloading_subscription'), error);
@@ -359,7 +366,7 @@ function setSortOption(sortOption) {
expirationDate.setDate(expirationDate.getDate() + daysToExpire);
const cookieValue = encodeURIComponent(sortOption) + '; expires=' + expirationDate.toUTCString();
document.cookie = 'sortOrder=' + cookieValue + '; SameSite=Strict';
- fetchSubscriptions();
+ fetchSubscriptions(null, null, "sort");
toggleSortOptions();
}
@@ -407,8 +414,9 @@ function submitFormData(formData, submitButton, endpoint) {
.then((data) => {
if (data.status === "Success") {
showSuccessMessage(data.message);
- fetchSubscriptions();
+ fetchSubscriptions(null, null, "add");
closeAddSubscription();
+
}
})
.catch((error) => {
@@ -653,7 +661,7 @@ document.querySelectorAll('.filter-item').forEach(function (item) {
document.querySelector('#clear-filters').classList.add('hide');
}
- fetchSubscriptions();
+ fetchSubscriptions(null, null, "filter");
});
});
@@ -667,7 +675,7 @@ function clearFilters() {
item.classList.remove('selected');
});
document.querySelector('#clear-filters').classList.add('hide');
- fetchSubscriptions();
+ fetchSubscriptions(null, null, "clearfilters");
}
let currentActions = null;
@@ -704,4 +712,33 @@ function expandActions(event, subscriptionId) {
} else {
currentActions = null;
}
-}
\ No newline at end of file
+}
+
+function swipeHintAnimation() {
+ if (window.mobileNavigation) {
+ const maxAnimations = 3;
+ const cookieName = 'swipeHintCount';
+
+ let count = parseInt(getCookie(cookieName)) || 0;
+ if (count < maxAnimations) {
+ const firstElement = document.querySelector('.subscription');
+ if (firstElement) {
+ firstElement.style.transition = 'transform 0.3s ease';
+ firstElement.style.transform = 'translateX(-80px)';
+
+ setTimeout(() => {
+ firstElement.style.transform = 'translateX(0px)';
+ }, 600);
+ }
+
+ count++;
+ document.cookie = `${cookieName}=${count}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; SameSite=Strict`;
+ }
+ }
+}
+
+window.addEventListener('load', () => {
+ if (document.querySelector('.subscription')) {
+ swipeHintAnimation();
+ }
+});
diff --git a/service-worker.js b/service-worker.js
index 3bd9c24..6696fa2 100644
--- a/service-worker.js
+++ b/service-worker.js
@@ -71,6 +71,8 @@ self.addEventListener('install', function (event) {
'images/siteicons/wallos.png',
'images/siteicons/walloswhite.png',
'images/siteimages/empty.png',
+ 'images/siteimages/mobilenav.png',
+ 'images/siteimages/mobilenavdark.png',
'images/avatars/1.svg',
'images/avatars/2.svg',
'images/avatars/3.svg',
diff --git a/settings.php b/settings.php
index 46fe7e0..a37119b 100644
--- a/settings.php
+++ b/settings.php
@@ -1205,6 +1205,8 @@ $userData['currency_symbol'] = "€";
echo 'checked'; ?>>
<label for="mobilenavigation"><?= translate('use_mobile_navigation_bar', $i18n) ?></label>
</div>
+ <div class="mobile-nav-image">
+ </div>
</div>
</div>
<div class="settings-notes">
diff --git a/styles/dark-theme.css b/styles/dark-theme.css
index 72f6aee..2a6bb92 100644
--- a/styles/dark-theme.css
+++ b/styles/dark-theme.css
@@ -258,6 +258,10 @@ input {
border: 2px dashed #444;
}
+.mobile-nav-image {
+ background-image: url("../images/siteimages/mobilenavdark.png");
+}
+
@media (max-width: 768px) {
.mobile-nav {
background-color: #222;
diff --git a/styles/styles.css b/styles/styles.css
index bf8290f..8277d2f 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -11,7 +11,7 @@ body.no-scroll {
}
@media (max-width: 768px) {
- .mobile-navivagtion main {
+ .mobile-navigation main {
margin-bottom: 70px;
}
}
@@ -128,7 +128,7 @@ header .logo .logo-image svg {
}
@media (max-width: 768px) {
- .mobile-navivagtion .dropbtn:after {
+ .mobile-navigation .dropbtn:after {
content: "";
display: none;
}
@@ -346,7 +346,7 @@ button:hover svg .main-color {
background-color: #FFFFFF;
}
-.subscription-container > .mobile-actions {
+.subscription-container>.mobile-actions {
display: flex;
flex-direction: row;
position: absolute;
@@ -358,7 +358,7 @@ button:hover svg .main-color {
border-bottom-right-radius: 16px;
}
-.subscription-container > .mobile-actions > button {
+.subscription-container>.mobile-actions>button {
display: flex;
flex-direction: column;
align-items: center;
@@ -372,7 +372,8 @@ button:hover svg .main-color {
}
button.mobile-action-edit {
- background-color: #ffbf15; /* #f3e22d; */
+ background-color: #ffbf15;
+ /* #f3e22d; */
}
button.mobile-action-delete {
@@ -383,7 +384,7 @@ button.mobile-action-clone {
background-color: #2da7f3
}
-.subscription-container > .mobile-actions > button > svg {
+.subscription-container>.mobile-actions>button>svg {
width: 25px;
height: 25px;
min-height: 25px;
@@ -1752,7 +1753,7 @@ button.dark-theme-button i {
width: 100%;
}
- .mobile-navivagtion .toast {
+ .mobile-navigation .toast {
bottom: 70px;
}
}
@@ -2652,6 +2653,17 @@ input[type="radio"]:checked+label::after {
display: none;
}
+.mobile-nav-image {
+ width: 100%;
+ max-width: 440px;
+ margin-top: 15px;
+ background-image: url("../images/siteimages/mobilenav.png");
+ background-size: contain;
+ background-position: center;
+ background-repeat: no-repeat;
+ aspect-ratio: 16/9;
+}
+
@media (max-width: 768px) {
.mobile-nav {
position: fixed;
@@ -2693,7 +2705,7 @@ input[type="radio"]:checked+label::after {
color: #202020;
}
- .mobile-navivagtion .mobileNavigationHideOnMobile {
+ .mobile-navigation .mobileNavigationHideOnMobile {
display: none !important;
}
}
\ No newline at end of file