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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -16
app.py CHANGED
@@ -394,7 +394,6 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
394
  <div class="app-header">
395
  <div class="user-info">{{ display_name }}</div>
396
  <div class="view-toggle">
397
- <button id="install-app-btn" title="Установить приложение" style="display: none;"><i class="fa-solid fa-arrow-down-to-bracket"></i></button>
398
  <button id="reminders-btn" title="Напоминания"><i class="fa-solid fa-bell"></i></button>
399
  <button id="grid-view-btn" title="Сетка"><i class="fa fa-th-large"></i></button>
400
  <button id="list-view-btn" title="Список"><i class="fa fa-bars"></i></button>
@@ -404,6 +403,9 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
404
  {% with messages = get_flashed_messages(with_categories=true) %}{% if messages %}
405
  {% for category, message in messages %}<div class="flash {{ category }}">{{ message }}</div>{% endfor %}
406
  {% endif %}{% endwith %}
 
 
 
407
  <div class="breadcrumbs">
408
  {% for crumb in breadcrumbs %}
409
  {% if crumb.is_link %}<a href="{{ url_for('tma_dashboard', folder_id=crumb.id) }}">{{ crumb.name if crumb.id != 'root' else 'Главная' }}</a>
@@ -518,6 +520,21 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
518
 
519
  <div class="fab-container"><button id="fab" class="fab"><i class="fa-solid fa-plus"></i></button></div>
520
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  <script>
522
  window.Telegram.WebApp.ready();
523
  window.Telegram.WebApp.expand();
@@ -756,6 +773,12 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
756
  }
757
  });
758
  }
 
 
 
 
 
 
759
  document.getElementById('reminders-btn').addEventListener('click', openRemindersModal);
760
  const gridViewBtn = document.getElementById('grid-view-btn');
761
  const listViewBtn = document.getElementById('list-view-btn');
@@ -783,24 +806,19 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
783
  backButton.show();
784
  backButton.onClick(() => { haptic.impactOccurred('light'); window.location.href = `{{ url_for('tma_dashboard') }}?folder_id=${parentFolderId}`; });
785
  } else { window.Telegram.WebApp.BackButton.hide(); }
786
- const installBtn = document.getElementById('install-app-btn');
787
- if (installBtn) {
788
- const checkAndShowInstallButton = () => {
789
- if (Telegram.WebApp.isVersionAtLeast('6.9') && !Telegram.WebApp.isAddedToAttachmentMenu) {
790
- installBtn.style.display = 'inline-block';
791
- } else {
792
- installBtn.style.display = 'none';
793
- }
794
- };
795
- installBtn.addEventListener('click', () => {
796
  haptic.impactOccurred('light');
797
- Telegram.WebApp.addToAttachmentMenu();
798
- });
799
- Telegram.WebApp.onEvent('addedToAttachmentMenu', () => {
800
- installBtn.style.display = 'none';
801
  });
802
- checkAndShowInstallButton();
803
  }
 
 
 
 
 
804
  });
805
  </script></body></html>
806
  '''
 
394
  <div class="app-header">
395
  <div class="user-info">{{ display_name }}</div>
396
  <div class="view-toggle">
 
397
  <button id="reminders-btn" title="Напоминания"><i class="fa-solid fa-bell"></i></button>
398
  <button id="grid-view-btn" title="Сетка"><i class="fa fa-th-large"></i></button>
399
  <button id="list-view-btn" title="Список"><i class="fa fa-bars"></i></button>
 
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>
 
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();
540
  window.Telegram.WebApp.expand();
 
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
  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
  '''