Eluza133 commited on
Commit
aee0933
·
verified ·
1 Parent(s): 5e402b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -35
app.py CHANGED
@@ -403,9 +403,6 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
403
  {% with messages = get_flashed_messages(with_categories=true) %}{% if messages %}
404
  {% for category, message in messages %}<div class="flash {{ category }}">{{ message }}</div>{% endfor %}
405
  {% endif %}{% endwith %}
406
- <div id="install-banner" class="flash" style="cursor: pointer; background: var(--accent); color: white; display: none; align-items: center; justify-content: center; gap: 10px;">
407
- <i class="fa-solid fa-download"></i><span>Установить приложение</span>
408
- </div>
409
  <div class="breadcrumbs">
410
  {% for crumb in breadcrumbs %}
411
  {% if crumb.is_link %}<a href="{{ url_for('tma_dashboard', folder_id=crumb.id) }}">{{ crumb.name if crumb.id != 'root' else 'Главная' }}</a>
@@ -518,22 +515,13 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
518
  </div>
519
  </div></div>
520
 
521
- <div class="fab-container"><button id="fab" class="fab"><i class="fa-solid fa-plus"></i></button></div>
 
 
 
 
522
 
523
- <div class="modal" id="install-instructions-modal"><div class="modal-content" style="padding: 20px; max-width: 400px; text-align: center;">
524
- <h4>Как добавить на главный экран</h4>
525
- <p style="text-align: left; margin: 15px 0;">
526
- <strong>На Android:</strong><br>
527
- 1. Нажмите на три точки (⋮) в правом верхнем углу.<br>
528
- 2. Выберите "Добавить ярлык".
529
- </p>
530
- <p style="text-align: left; margin: 15px 0;">
531
- <strong>На iOS:</strong><br>
532
- 1. Нажмите на имя бота вверху.<br>
533
- 2. Выберите "Добавить на главный экран".
534
- </p>
535
- <button class="btn" style="background: var(--accent); width: 100%; margin-top: 20px;" onclick="dismissInstallBanner()">Понятно</button>
536
- </div></div>
537
 
538
  <script>
539
  window.Telegram.WebApp.ready();
@@ -773,12 +761,6 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
773
  }
774
  });
775
  }
776
- function dismissInstallBanner() {
777
- haptic.impactOccurred('light');
778
- document.getElementById('install-instructions-modal').style.display = 'none';
779
- localStorage.setItem('appShortcutAdded', 'true');
780
- document.getElementById('install-banner').style.display = 'none';
781
- }
782
  document.getElementById('reminders-btn').addEventListener('click', openRemindersModal);
783
  const gridViewBtn = document.getElementById('grid-view-btn');
784
  const listViewBtn = document.getElementById('list-view-btn');
@@ -806,19 +788,15 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
806
  backButton.show();
807
  backButton.onClick(() => { haptic.impactOccurred('light'); window.location.href = `{{ url_for('tma_dashboard') }}?folder_id=${parentFolderId}`; });
808
  } else { window.Telegram.WebApp.BackButton.hide(); }
809
- const installBanner = document.getElementById('install-banner');
810
- if (!localStorage.getItem('appShortcutAdded') && (window.Telegram.WebApp.platform !== 'tdesktop')) {
811
- installBanner.style.display = 'flex';
812
- installBanner.addEventListener('click', () => {
813
- haptic.impactOccurred('light');
814
- document.getElementById('install-instructions-modal').style.display = 'flex';
 
815
  });
816
  }
817
- document.getElementById('install-instructions-modal').addEventListener('click', e => {
818
- if (e.target.id === 'install-instructions-modal') {
819
- dismissInstallBanner();
820
- }
821
- });
822
  });
823
  </script></body></html>
824
  '''
 
403
  {% with messages = get_flashed_messages(with_categories=true) %}{% if messages %}
404
  {% for category, message in messages %}<div class="flash {{ category }}">{{ message }}</div>{% endfor %}
405
  {% endif %}{% endwith %}
 
 
 
406
  <div class="breadcrumbs">
407
  {% for crumb in breadcrumbs %}
408
  {% if crumb.is_link %}<a href="{{ url_for('tma_dashboard', folder_id=crumb.id) }}">{{ crumb.name if crumb.id != 'root' else 'Главная' }}</a>
 
515
  </div>
516
  </div></div>
517
 
518
+ <div id="install-container" style="position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 1040; display: none;">
519
+ <button id="install-app-btn" class="btn" style="background: var(--secondary); box-shadow: var(--shadow);">
520
+ <i class="fa-solid fa-download"></i> Установить приложение
521
+ </button>
522
+ </div>
523
 
524
+ <div class="fab-container"><button id="fab" class="fab"><i class="fa-solid fa-plus"></i></button></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
525
 
526
  <script>
527
  window.Telegram.WebApp.ready();
 
761
  }
762
  });
763
  }
 
 
 
 
 
 
764
  document.getElementById('reminders-btn').addEventListener('click', openRemindersModal);
765
  const gridViewBtn = document.getElementById('grid-view-btn');
766
  const listViewBtn = document.getElementById('list-view-btn');
 
788
  backButton.show();
789
  backButton.onClick(() => { haptic.impactOccurred('light'); window.location.href = `{{ url_for('tma_dashboard') }}?folder_id=${parentFolderId}`; });
790
  } else { window.Telegram.WebApp.BackButton.hide(); }
791
+
792
+ const installContainer = document.getElementById('install-container');
793
+ const installBtn = document.getElementById('install-app-btn');
794
+ if (window.Telegram.WebApp.isVersionAtLeast('6.9') && !window.Telegram.WebApp.isAddedToHomeScreen) {
795
+ installContainer.style.display = 'block';
796
+ installBtn.addEventListener('click', () => {
797
+ window.Telegram.WebApp.showAddToHomeScreen();
798
  });
799
  }
 
 
 
 
 
800
  });
801
  </script></body></html>
802
  '''