File size: 6,885 Bytes
621f304
 
 
 
 
 
 
 
 
 
 
 
 
3aa83be
3ceecc5
621f304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6aa82f
621f304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4da3aca
621f304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c70eb3
0da5dab
621f304
 
 
0da5dab
944b438
621f304
 
 
 
944b438
621f304
 
 
 
 
 
 
 
 
 
 
944b438
621f304
 
 
 
 
944b438
621f304
 
 
 
 
 
944b438
621f304
 
 
 
 
944b438
621f304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import streamlit as st
from streamlit_option_menu import option_menu
from utils.functions import (
    get_phone_info,
    simple_checks,
    analyze_message,
    init_stats_file,
    update_stats,
    add_to_history,
    is_fake_number,
    init_fake_numbers_file,
    init_history_file
)
import os

# 1. Konfiguracja strony - musi by膰 pierwszym poleceniem Streamlit
st.set_page_config(
    page_title="馃摫 Detektor Fa艂szywych Wiadomo艣ci SMS",
    page_icon="馃摫",
    layout="wide"
)

# 2. Inicjalizacja plik贸w
init_stats_file()
init_fake_numbers_file()
init_history_file()

# 3. Ukrycie bocznego menu Streamlit za pomoc膮 CSS
hide_sidebar_style = """
    <style>
    /* Ukryj boczne menu */
    [data-testid="stSidebar"] {
        display: none;
    }
    </style>
    """
st.markdown(hide_sidebar_style, unsafe_allow_html=True)

# 4. Definiowanie t艂umacze艅
translations = {
    'Polish': {
        'menu_analysis_sms': 'Analiza wiadomo艣ci',
        'menu_about': 'O Projekcie',
        'menu_education': 'Edukacja',
        'menu_statistics': 'Statystyki',
        'menu_contact': 'Kontakt',
        'language_select': 'Wybierz j臋zyk / Sprache ausw盲hlen / Select language',
        'separator': '---',
        'language_selected': 'Wybrany j臋zyk: '
    },
    'German': {
        'menu_analysis_sms': 'SMS-Analyse',
        'menu_about': '脺ber das Projekt',
        'menu_education': 'Bildung',
        'menu_statistics': 'Statistiken',
        'menu_contact': 'Kontakt',
        'language_select': 'Wybierz j臋zyk / Sprache ausw盲hlen / Select language',
        'separator': '---',
        'language_selected': 'Ausgew盲hlte Sprache: '
    },
    'English': {
        'menu_analysis_sms': 'SMS Analysis',
        'menu_about': 'About the Project',
        'menu_education': 'Education',
        'menu_statistics': 'Statistics',
        'menu_contact': 'Contact',
        'language_select': 'Wybierz j臋zyk / Sprache ausw盲hlen / Select language',
        'separator': '---',
        'language_selected': 'Selected Language: '
    }
}

# 5. Wyb贸r j臋zyka z flagami w jednym wierszu
if 'language' not in st.session_state:
    st.session_state.language = 'Polish'

# Nowy spos贸b na wyb贸r j臋zyka bez u偶ycia przycisk贸w "POST"
selected_language = st.selectbox(
    translations[st.session_state.language]['language_select'],
    options=['Polish', 'German', 'English'],
    index=['Polish', 'German', 'English'].index(st.session_state.language)
)

# Zapis wybranego j臋zyka w sesji
st.session_state.language = selected_language

st.markdown(f"**{translations[selected_language]['language_selected']} {selected_language}**")

# Dodanie separatora pod wyborem j臋zyka
st.markdown("---")

# 6. Pobranie przet艂umaczonych opcji menu
menu_keys = ['menu_analysis_sms', 'menu_about', 'menu_education', 'menu_statistics', 'menu_contact']
menu_options = [translations[selected_language][key] for key in menu_keys]

# 7. Dodanie niestandardowego CSS do wzmocnienia styl贸w menu
custom_css = """
<style>
    /* Stylizacja kontenera menu */
    .streamlit-option-menu {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 10px 0;
        margin-bottom: 10px;
    }

    /* Stylizacja przycisk贸w w jasnym motywie */
    html[data-theme="light"] .streamlit-option-menu {
        background-color: #f0f0f0;
    }

    /* Stylizacja przycisk贸w w ciemnym motywie */
    html[data-theme="dark"] .streamlit-option-menu {
        background-color: #333;
    }

    /* Stylizacja przycisk贸w */
    .streamlit-option-menu .nav-link {
        font-size: 16px;
        padding: 10px 20px;
        margin: 0 5px;
        background-color: transparent;
        color: inherit;
        border-radius: 5px;
        transition: background-color 0.3s ease, color 0.3s ease;
        cursor: pointer;
    }

    /* Efekt hover */
    .streamlit-option-menu .nav-link:hover {
        background-color: #02ab21;
        color: #ffffff !important;
    }

    /* Stylizacja wybranego elementu */
    .streamlit-option-menu .nav-link-selected {
        background-color: #02ab21;
        color: #ffffff !important;
        border-radius: 5px;
    }

    /* Stylizacja ikonek */
    .streamlit-option-menu .icon {
        font-size: 18px;
        color: inherit !important;
    }

    /* Responsywno艣膰 */
    @media (max-width: 768px) {
        .streamlit-option-menu {
            flex-direction: column;
        }
        .streamlit-option-menu .nav-link {
            margin: 5px 0;
            width: 100%;
        }
    }
</style>
"""
st.markdown(custom_css, unsafe_allow_html=True)

# 8. Tworzenie poziomego menu w kontenerze
with st.container():
    selected = option_menu(
        menu_title=None,  # Brak tytu艂u menu
        options=menu_options,
        icons=["shield-check", "info-circle", "book", "bar-chart", "envelope"],
        menu_icon=None,  # Usuni臋cie ikony menu
        default_index=0,
        orientation="horizontal",
        styles={
            "container": {"padding": "0!important", "background-color": "transparent"},
            "icon": {"color": "inherit", "font-size": "18px"},
            "nav-link": {
                "font-size": "16px",
                "text-align": "center",
                "margin": "0px",
                "padding": "10px 20px",
                "border-radius": "5px",
                "background-color": "transparent",
                "color": "inherit",
                "transition": "background-color 0.3s ease, color 0.3s ease"
            },
            "nav-link-selected": {
                "background-color": "#02ab21",
                "color": "#ffffff",
                "border-radius": "5px",
                "padding": "10px 20px"
            },
        }
    )

# 9. Dodanie separatora
st.markdown("---")  # Dodaje poziom膮 lini臋

# 10. Importowanie i wywo艂ywanie modu艂贸w dla ka偶dej zak艂adki
try:
    if selected == translations[selected_language]['menu_analysis_sms']:
        from pages.Analysis import show_analysis
        show_analysis(selected_language)
    elif selected == translations[selected_language]['menu_about']:
        from pages.About import main as show_about
        show_about(selected_language)
    elif selected == translations[selected_language]['menu_education']:
        from pages.Education import main as show_education
        show_education(selected_language)
    elif selected == translations[selected_language]['menu_statistics']:
        from pages.Statistics import main as show_statistics
        show_statistics(selected_language)
    elif selected == translations[selected_language]['menu_contact']:
        from pages.Contact import main as show_contact
        show_contact(selected_language)
except ImportError as e:
    st.error(f"B艂膮d importu: {e}")
except TypeError as e:
    st.error(f"B艂膮d wywo艂ania funkcji: {e}")