GSMEthesis commited on
Commit
f4949e9
·
verified ·
1 Parent(s): 038539e

Update app.py

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