GSMEthesis commited on
Commit
ff6c10a
·
verified ·
1 Parent(s): bc32215

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -158
app.py CHANGED
@@ -32,22 +32,37 @@ st.markdown("""
32
  --input-bg: #ffffff;
33
  --secondary-bg: #f8f9fa;
34
  --green: #f0ff0;
35
- --dgreen: #006400
 
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  * {
39
  font-family: 'B Nazanin', 'B Nazanin Bold', sans-serif !important;
40
  text-align: right !important;
41
  direction: rtl !important;
42
  }
43
 
44
- /* تنظیمات اصلی */
45
  body, .stApp, [data-testid="stAppViewContainer"] {
46
  background-color: var(--background) !important;
47
  color: var(--text) !important;
48
  }
49
 
50
- /* هدر راهیار */
51
  .rahyar-title {
52
  color: var(--primary) !important;
53
  margin: 0 !important;
@@ -59,7 +74,6 @@ st.markdown("""
59
  font-size: 14px !important;
60
  }
61
 
62
- /* توضیحات */
63
  .explanation-title {
64
  color: var(--primary) !important;
65
  font-weight: bold !important;
@@ -75,8 +89,7 @@ st.markdown("""
75
  border-right: 3px solid var(--primary) !important;
76
  }
77
 
78
- /* ========== استایل‌های ورودی یکپارچه ========== */
79
- /* استایل پایه برای تمام عناصر ورودی */
80
  .stTextInput input,
81
  .stNumberInput input,
82
  .stSelectbox select,
@@ -92,9 +105,10 @@ st.markdown("""
92
  border-radius: 6px !important;
93
  min-height: 40px !important;
94
  transition: all 0.2s ease !important;
 
 
95
  }
96
 
97
- /* استایل برای حالت hover و focus */
98
  .stTextInput input:hover,
99
  .stNumberInput input:hover,
100
  .stSelectbox select:hover,
@@ -113,7 +127,6 @@ st.markdown("""
113
  outline: none !important;
114
  }
115
 
116
- /* استایل لیبل‌ها */
117
  .stTextInput > label,
118
  .stNumberInput > label,
119
  .stSelectbox > label,
@@ -125,13 +138,12 @@ st.markdown("""
125
  font-size: 14px !important;
126
  }
127
 
128
- /* استایل placeholder */
129
  ::placeholder {
130
  color: var(--text) !important;
131
  opacity: 0.5 !important;
132
  }
133
 
134
- /* ========== استایل‌های خاص Selectbox ========== */
135
  div[data-baseweb="select"] > div:first-child {
136
  -webkit-appearance: none !important;
137
  -moz-appearance: none !important;
@@ -139,7 +151,6 @@ st.markdown("""
139
  background-image: none !important;
140
  }
141
 
142
- /* برای اینترنت اکسپلورر */
143
  div[data-baseweb="select"] > div:first-child::-ms-expand {
144
  display: none !important;
145
  }
@@ -155,28 +166,23 @@ st.markdown("""
155
  top: 50%;
156
  transform: translateY(-50%);
157
  color: var(--primary);
158
- background-color: white !important; /* پسزمینه سفید برای پوشاندن فلش پیشفرض */
159
  font-size: 14px;
160
  pointer-events: none;
161
  }
162
-
163
-
164
- /* ===== راه حل تضمینی برای استایل dropdown ===== */
165
 
166
- /* آیتم‌های لیست */
167
  div[data-baseweb="popover"] [role="option"] {
168
  color: var(--text) !important;
169
  background-color: white !important;
170
  border: 1px var(--primary) !important;
171
  }
172
 
173
- /* آیتم انتخاب شده */
174
  div[data-baseweb="popover"] [role="option"][aria-selected="true"] {
175
  background-color: #f0e6ff !important;
176
  color: black !important;
177
  }
178
 
179
- /* ========== استایل‌های Number Input ========== */
180
  .stNumberInput button {
181
  color: var(--primary) !important;
182
  background-color: transparent !important;
@@ -189,8 +195,7 @@ st.markdown("""
189
  background-color: #f0e6ff !important;
190
  }
191
 
192
-
193
- /* کامپوننت‌های سفارشی */
194
  .rahyar-header {
195
  background-color: var(--primary) !important;
196
  color: white !important;
@@ -206,9 +211,10 @@ st.markdown("""
206
  padding: 15px !important;
207
  margin: 15px 0 !important;
208
  border-right: 5px solid var(--primary) !important;
 
209
  }
210
 
211
- /* دکمه اصلی (بنفش با متن سفید) */
212
  .stButton>button,
213
  [data-testid="baseButton-primary"],
214
  .accept-btn,
@@ -219,20 +225,20 @@ st.markdown("""
219
  border-radius: 8px !important;
220
  padding: 10px 20px !important;
221
  font-weight: bold !important;
222
- transition: all 0.3s ease !important; /* افزودن transition برای انیمیشن نرم */
 
 
223
  }
224
 
225
- /* افکت hover برای دکمه اصلی */
226
  .stButton>button:hover,
227
  [data-testid="baseButton-primary"]:hover,
228
  .accept-btn:hover,
229
  div[data-testid="stVerticalBlock"] > div[data-testid="stHorizontalBlock"] > div > div > button:hover {
230
- background-color: #5a0a96 !important; /* بنفش تیره‌تر */
231
- transform: translateY(-1px) !important; /* حرکت جزئی به بالا */
232
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important; /* سایه بیشتر */
233
  }
234
 
235
- /* دکمه ثانویه (سفید با حاشیه بنفش) */
236
  .stFormSubmitButton>button,
237
  [data-testid="baseButton-secondary"],
238
  .reject-btn {
@@ -242,19 +248,19 @@ st.markdown("""
242
  border-radius: 8px !important;
243
  padding: 10px 20px !important;
244
  font-weight: bold !important;
245
- transition: all 0.3s ease !important; /* افزودن transition برای انیمیشن نرم */
 
246
  }
247
 
248
- /* افکت hover برای دکمه ثانویه */
249
  .stFormSubmitButton>button:hover,
250
  [data-testid="baseButton-secondary"]:hover,
251
  .reject-btn:hover {
252
- background-color: #5a0a96 !important; /* بنفش تیره‌تر */
253
- transform: translateY(-1px) !important; /* حرکت جزئی به بالا */
254
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important; /* سایه بیشتر */
255
  }
256
 
257
- /* استایل تضمینی برای رادیو باتن‌ها - نسخه نهایی */
258
  .stRadio > div > div > div > div > div > label,
259
  .stRadio > div > div > div > div > label,
260
  .stRadio > div > div > div > label,
@@ -262,7 +268,7 @@ st.markdown("""
262
  .stRadio > div > label,
263
  .stRadio > label {
264
  color: #000000 !important;
265
- -webkit-text-fill-color: #000000 !important; /* برای مرورگرهای وبکیت */
266
  }
267
 
268
  .stRadio span {
@@ -270,7 +276,6 @@ st.markdown("""
270
  -webkit-text-fill-color: #000000 !important;
271
  }
272
 
273
- /* اگر باز هم مشکل داشت این را اضافه کنید */
274
  .stRadio > div > div > div > div > div > label > div:first-child,
275
  .stRadio > div > div > div > div > label > div:first-child,
276
  .stRadio > div > div > div > label > div:first-child,
@@ -281,7 +286,7 @@ st.markdown("""
281
  -webkit-text-fill-color: #000000 !important;
282
  }
283
 
284
- /* استایل پایه برای هشدارها */
285
  .stAlert .st-ae {
286
  border-right: 4px solid #ffc107 !important;
287
  background-color: #fff3cd !important;
@@ -290,13 +295,11 @@ st.markdown("""
290
  color: #856404 !important;
291
  }
292
 
293
- /* آیکون هشدار */
294
  .stAlert .st-af {
295
  color: #ffc107 !important;
296
  font-size: 20px !important;
297
  }
298
 
299
- /* متن هشدار */
300
  .stAlert .st-ag {
301
  color: #856404 !important;
302
  font-family: 'B Nazanin' !important;
@@ -304,152 +307,96 @@ st.markdown("""
304
  margin-right: 8px !important;
305
  }
306
 
307
- /* حالت hover برای هشدار */
308
  .stAlert .st-ae:hover {
309
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2) !important;
310
  transform: translateX(2px);
311
  transition: all 0.3s ease;
312
  }
313
 
314
- /* استایل برای دکمه بستن هشدار */
315
  .stAlert .st-ah {
316
  color: #856404 !important;
317
  }
318
-
319
- /* استایل مخصوص موبایل */
320
- @media (max-width: 768px) {
321
- .stAlert .st-ae {
322
- padding: 12px !important;
323
- font-size: 13px !important;
324
- }
325
- }
326
-
327
 
328
- /* متن گزینه‌ها */
329
- .stRadio span {
330
- color: #000000 !important; /* مشکی خالص */
331
- font-size: 14px !important;
332
- padding-right: 5px !important;
333
- }
334
-
335
- /* حالت hover */
336
- .stRadio label:hover span {
337
- color: #333333 !important; /* مشکی کمی روشن‌تر */
338
  }
339
-
340
- /* کانتینر اصلی */
341
- .stRadio > div {
342
- margin-bottom: 10px !important;
343
  }
344
 
 
 
 
 
 
345
 
346
- /* تنظیمات مخصوص موبایل */
347
- @media (max-width: 768px) {
348
- .folium-map {
349
- height: 300px !important;
350
- }
351
-
352
- /* فرم‌ها در موبایل */
353
- .stTextInput>label,
354
- .stNumberInput>label,
355
- .stSelectbox>label {
356
  font-size: 14px !important;
357
- padding: 4px 0 !important;
358
  }
359
-
360
- .stTextInput input,
361
- .stNumberInput input,
362
- .stSelectbox select {
363
- font-size: 16px !important;
364
- padding: 12px !important;
365
- height: auto !important;
366
  }
367
-
368
- .stButton>button {
369
- font-size: 14px !important;
370
- padding: 8px 16px !important;
371
  }
372
-
373
- .stMarkdown h3 {
374
- font-size: 16px !important;
375
  }
376
-
377
- .stMarkdown p {
378
- font-size: 13px !important;
379
- }
380
-
381
- .stSelectbox [role="listbox"] {
382
- font-size: 16px !important;
383
  }
384
  }
385
- /* اضافه کردن متا ویوپورت برای شبیه‌سازی موبایل */
386
- @viewport {
387
- width: device-width;
388
- initial-scale: 1.0;
389
- maximum-scale: 1.0;
390
- user-scalable: no;
391
- }
392
-
393
- /* اجبار به استفاده از عرض دستگاه */
394
- html, body, [data-testid="stAppViewContainer"] {
395
- width: 100% !important;
396
- max-width: 100% !important;
397
- min-width: 320px !important;
398
- }
399
-
400
- /* تنظیمات عمومی برای شبیه‌سازی موبایل */
401
- body {
402
- touch-action: pan-y pinch-zoom;
403
- -webkit-text-size-adjust: 100%;
404
- }
405
-
406
- /* تنظیمات مخصوص کامپوننت‌ها برای موبایل */
407
- .stApp {
408
- max-width: 414px !important; /* عرض معمول موبایل‌ها */
409
- margin: 0 auto !important;
410
- box-shadow: 0 0 20px rgba(0,0,0,0.1);
411
- min-height: 100vh;
412
- }
413
-
414
- /* تنظیمات نقشه برای موبایل */
415
- .folium-map {
416
- width: 100% !important;
417
- max-width: 100% !important;
418
- height: 300px !important;
419
- }
420
-
421
- /* مخفی کردن اسکرولبار در دسکتاپ */
422
- ::-webkit-scrollbar {
423
- display: none;
424
- }
425
-
426
- /* تنظیمات ریسپانسیو برای تمام عناصر */
427
- .stTextInput input,
428
- .stNumberInput input,
429
- .stSelectbox select,
430
- .stTextArea textarea,
431
- .stDateInput input,
432
- .stTimeInput input {
433
- width: 100% !important;
434
- box-sizing: border-box;
435
- }
436
-
437
- /* تنظیمات دکمه‌ها برای موبایل */
438
- .stButton > button {
439
- width: 100% !important;
440
- margin: 5px 0 !important;
441
- }
442
-
443
- /* تنظیمات کانتینر قیمت */
444
- .price-container {
445
- width: 100% !important;
446
- box-sizing: border-box;
447
- }
448
  </style>
449
 
450
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
451
  """, unsafe_allow_html=True)
452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  # ========== توابع اصلی ==========
454
  def create_ride_map():
455
  """ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
 
32
  --input-bg: #ffffff;
33
  --secondary-bg: #f8f9fa;
34
  --green: #f0ff0;
35
+ --dgreen: #006400;
36
+ --mobile-width: 414px;
37
  }
38
 
39
+ /* ======== تنظیمات اجباری موبایل ======== */
40
+ html, body {
41
+ width: 100% !important;
42
+ max-width: 100% !important;
43
+ overflow-x: hidden !important;
44
+ -webkit-text-size-adjust: 100%;
45
+ }
46
+
47
+ [data-testid="stAppViewContainer"] {
48
+ max-width: var(--mobile-width) !important;
49
+ margin: 0 auto !important;
50
+ padding: 10px !important;
51
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
52
+ }
53
+
54
+ /* ======== استایل‌های اصلی شما (بدون تغییر) ======== */
55
  * {
56
  font-family: 'B Nazanin', 'B Nazanin Bold', sans-serif !important;
57
  text-align: right !important;
58
  direction: rtl !important;
59
  }
60
 
 
61
  body, .stApp, [data-testid="stAppViewContainer"] {
62
  background-color: var(--background) !important;
63
  color: var(--text) !important;
64
  }
65
 
 
66
  .rahyar-title {
67
  color: var(--primary) !important;
68
  margin: 0 !important;
 
74
  font-size: 14px !important;
75
  }
76
 
 
77
  .explanation-title {
78
  color: var(--primary) !important;
79
  font-weight: bold !important;
 
89
  border-right: 3px solid var(--primary) !important;
90
  }
91
 
92
+ /* ========== استایل‌های ورودی ========== */
 
93
  .stTextInput input,
94
  .stNumberInput input,
95
  .stSelectbox select,
 
105
  border-radius: 6px !important;
106
  min-height: 40px !important;
107
  transition: all 0.2s ease !important;
108
+ width: 100% !important;
109
+ box-sizing: border-box !important;
110
  }
111
 
 
112
  .stTextInput input:hover,
113
  .stNumberInput input:hover,
114
  .stSelectbox select:hover,
 
127
  outline: none !important;
128
  }
129
 
 
130
  .stTextInput > label,
131
  .stNumberInput > label,
132
  .stSelectbox > label,
 
138
  font-size: 14px !important;
139
  }
140
 
 
141
  ::placeholder {
142
  color: var(--text) !important;
143
  opacity: 0.5 !important;
144
  }
145
 
146
+ /* ========== Selectbox ========== */
147
  div[data-baseweb="select"] > div:first-child {
148
  -webkit-appearance: none !important;
149
  -moz-appearance: none !important;
 
151
  background-image: none !important;
152
  }
153
 
 
154
  div[data-baseweb="select"] > div:first-child::-ms-expand {
155
  display: none !important;
156
  }
 
166
  top: 50%;
167
  transform: translateY(-50%);
168
  color: var(--primary);
169
+ background-color: white !important;
170
  font-size: 14px;
171
  pointer-events: none;
172
  }
 
 
 
173
 
 
174
  div[data-baseweb="popover"] [role="option"] {
175
  color: var(--text) !important;
176
  background-color: white !important;
177
  border: 1px var(--primary) !important;
178
  }
179
 
 
180
  div[data-baseweb="popover"] [role="option"][aria-selected="true"] {
181
  background-color: #f0e6ff !important;
182
  color: black !important;
183
  }
184
 
185
+ /* ========== Number Input ========== */
186
  .stNumberInput button {
187
  color: var(--primary) !important;
188
  background-color: transparent !important;
 
195
  background-color: #f0e6ff !important;
196
  }
197
 
198
+ /* ========== کامپوننت‌های سفارشی ========== */
 
199
  .rahyar-header {
200
  background-color: var(--primary) !important;
201
  color: white !important;
 
211
  padding: 15px !important;
212
  margin: 15px 0 !important;
213
  border-right: 5px solid var(--primary) !important;
214
+ width: 100% !important;
215
  }
216
 
217
+ /* ========== دکمه‌ها ========== */
218
  .stButton>button,
219
  [data-testid="baseButton-primary"],
220
  .accept-btn,
 
225
  border-radius: 8px !important;
226
  padding: 10px 20px !important;
227
  font-weight: bold !important;
228
+ transition: all 0.3s ease !important;
229
+ width: 100% !important;
230
+ margin: 5px 0 !important;
231
  }
232
 
 
233
  .stButton>button:hover,
234
  [data-testid="baseButton-primary"]:hover,
235
  .accept-btn:hover,
236
  div[data-testid="stVerticalBlock"] > div[data-testid="stHorizontalBlock"] > div > div > button:hover {
237
+ background-color: #5a0a96 !important;
238
+ transform: translateY(-1px) !important;
239
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
240
  }
241
 
 
242
  .stFormSubmitButton>button,
243
  [data-testid="baseButton-secondary"],
244
  .reject-btn {
 
248
  border-radius: 8px !important;
249
  padding: 10px 20px !important;
250
  font-weight: bold !important;
251
+ transition: all 0.3s ease !important;
252
+ width: 100% !important;
253
  }
254
 
 
255
  .stFormSubmitButton>button:hover,
256
  [data-testid="baseButton-secondary"]:hover,
257
  .reject-btn:hover {
258
+ background-color: #5a0a96 !important;
259
+ transform: translateY(-1px) !important;
260
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
261
  }
262
 
263
+ /* ========== رادیو باتن‌ها ========== */
264
  .stRadio > div > div > div > div > div > label,
265
  .stRadio > div > div > div > div > label,
266
  .stRadio > div > div > div > label,
 
268
  .stRadio > div > label,
269
  .stRadio > label {
270
  color: #000000 !important;
271
+ -webkit-text-fill-color: #000000 !important;
272
  }
273
 
274
  .stRadio span {
 
276
  -webkit-text-fill-color: #000000 !important;
277
  }
278
 
 
279
  .stRadio > div > div > div > div > div > label > div:first-child,
280
  .stRadio > div > div > div > div > label > div:first-child,
281
  .stRadio > div > div > div > label > div:first-child,
 
286
  -webkit-text-fill-color: #000000 !important;
287
  }
288
 
289
+ /* ========== هشدارها ========== */
290
  .stAlert .st-ae {
291
  border-right: 4px solid #ffc107 !important;
292
  background-color: #fff3cd !important;
 
295
  color: #856404 !important;
296
  }
297
 
 
298
  .stAlert .st-af {
299
  color: #ffc107 !important;
300
  font-size: 20px !important;
301
  }
302
 
 
303
  .stAlert .st-ag {
304
  color: #856404 !important;
305
  font-family: 'B Nazanin' !important;
 
307
  margin-right: 8px !important;
308
  }
309
 
 
310
  .stAlert .st-ae:hover {
311
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2) !important;
312
  transform: translateX(2px);
313
  transition: all 0.3s ease;
314
  }
315
 
 
316
  .stAlert .st-ah {
317
  color: #856404 !important;
318
  }
 
 
 
 
 
 
 
 
 
319
 
320
+ /* ========== نقشه ========== */
321
+ .folium-map {
322
+ width: 100% !important;
323
+ max-width: 100% !important;
324
+ height: 300px !important;
325
+ margin: 10px 0 !important;
 
 
 
 
326
  }
327
+
328
+ /* ========== تنظیمات عمومی ========== */
329
+ ::-webkit-scrollbar {
330
+ display: none !important;
331
  }
332
 
333
+ body {
334
+ touch-action: pan-y;
335
+ -webkit-user-scalable: no;
336
+ user-scalable: no;
337
+ }
338
 
339
+ /* ========== رسپانسیو ========== */
340
+ @media (max-width: 414px) {
341
+ * {
 
 
 
 
 
 
 
342
  font-size: 14px !important;
 
343
  }
344
+ h1 {
345
+ font-size: 22px !important;
 
 
 
 
 
346
  }
347
+ h2 {
348
+ font-size: 20px !important;
 
 
349
  }
350
+ h3 {
351
+ font-size: 18px !important;
 
352
  }
353
+ .stTextInput input,
354
+ .stNumberInput input,
355
+ .stSelectbox select {
356
+ font-size: 14px !important;
357
+ padding: 10px !important;
 
 
358
  }
359
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  </style>
361
 
362
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
363
  """, unsafe_allow_html=True)
364
 
365
+ # کد JavaScript برای اعمال نهایی
366
+ st.components.v1.html("""
367
+ <script>
368
+ // تنظیم viewport دینامیک
369
+ document.querySelector('meta[name="viewport"]').content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
370
+
371
+ // تنظیم عرض صفحه
372
+ const appContainer = document.querySelector('[data-testid="stAppViewContainer"]');
373
+ if (appContainer) {
374
+ appContainer.style.maxWidth = '414px';
375
+ appContainer.style.margin = '0 auto';
376
+ }
377
+
378
+ // غیرفعال کردن زوم
379
+ document.addEventListener('gesturestart', function(e) {
380
+ e.preventDefault();
381
+ });
382
+ document.addEventListener('dblclick', function(e) {
383
+ e.preventDefault();
384
+ }, { passive: false });
385
+
386
+ // تنظیم اندازه فونت
387
+ function adjustLayout() {
388
+ const container = document.querySelector('[data-testid="stAppViewContainer"]');
389
+ if (container) {
390
+ const width = container.offsetWidth;
391
+ const baseSize = width < 400 ? 14 : 16;
392
+ document.documentElement.style.fontSize = baseSize + 'px';
393
+ }
394
+ }
395
+ window.addEventListener('resize', adjustLayout);
396
+ adjustLayout();
397
+ </script>
398
+ """, height=0)
399
+
400
  # ========== توابع اصلی ==========
401
  def create_ride_map():
402
  """ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""