Maryam Ilka commited on
Commit
b503394
·
verified ·
1 Parent(s): dc57f18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -17
app.py CHANGED
@@ -41,6 +41,55 @@ st.markdown("""
41
  --background-color: #121212;
42
  }
43
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  * {
46
  font-family: 'Vazir', sans-serif !important;
@@ -448,10 +497,13 @@ def map_view():
448
  <h2 style="color: #6a0dad; margin: 0;">رهیار 🚖</h2>
449
  <p style="color: #6a0dad; margin: 0;">همراه سفرهای درون‌شهری شما، راهی مطمئن، راهی روشن، رهیار</p>
450
  """, unsafe_allow_html=True)
451
-
452
  st.markdown("### مسیر سفر شما")
453
- folium_static(create_ride_map(), width=800, height=400)
454
-
 
 
 
455
  st.markdown(f"""
456
  <div class="price-container">
457
  <div style="display: flex; justify-content: space-between; align-items: center;">
@@ -463,24 +515,28 @@ def map_view():
463
 
464
  show_explanation(st.session_state.scenario_type)
465
 
466
- # دکمه‌های جدید با استایل‌های سفارشی
467
- col1, col2 = st.columns(2)
468
- with col1:
469
- if st.button("درخواست راهیار", key="accept_btn",
470
- help="برای تایید قیمت و درخواست سفر کلیک کنید",
471
- use_container_width=True):
 
 
 
 
 
 
 
 
 
 
472
  st.session_state.price_accepted = 1
473
- st.session_state.current_page = "transparency_questions"
474
  st.rerun()
475
-
476
- with col2:
477
- if st.button("رد قیمت", key="reject_btn",
478
- help="برای رد قیمت و ادامه به سوالات کلیک کنید",
479
- use_container_width=True):
480
  st.session_state.price_accepted = 0
481
- st.session_state.current_page = "transparency_questions"
482
  st.rerun()
483
-
484
  def transparency_questions():
485
  """سوالات شفافیت"""
486
  st.header("📊")
@@ -608,6 +664,10 @@ def thank_you_page():
608
 
609
  # ========== مدیریت وضعیت و صفحه‌بندی ==========
610
  def main():
 
 
 
 
611
  if 'current_page' not in st.session_state:
612
  st.session_state.current_page = "welcome"
613
  st.session_state.scenario_type = random.choice(["control", "input", "counterfactual"])
 
41
  --background-color: #121212;
42
  }
43
  }
44
+ /* تنظیمات پایه برای تمام دستگاه‌ها */
45
+ :root {
46
+ color-scheme: light only;
47
+ --rahyar-primary: #6a0dad;
48
+ --rahyar-text: #333333;
49
+ --rahyar-bg: #ffffff;
50
+ --rahyar-white: #ffffff;
51
+ }
52
+
53
+ /* بازنویسی کامل بخش تنظیمات دسکتاپ */
54
+ @media only screen and (min-width: 769px) {
55
+ html, body, [class*="css"] {
56
+ color: var(--rahyar-text) !important;
57
+ background-color: var(--rahyar-bg) !important;
58
+ }
59
+
60
+ .stApp {
61
+ background-color: var(--rahyar-bg) !important;
62
+ }
63
+
64
+ /* تنظیمات مخصوص دسکتاپ */
65
+ .folium-map {
66
+ height: 500px !important;
67
+ width: 100% !important;
68
+ }
69
+
70
+ .price-container {
71
+ width: 80% !important;
72
+ margin: 20px auto !important;
73
+ }
74
+
75
+ /* دکمه‌های دسکتاپ */
76
+ .accept-btn, .reject-btn {
77
+ padding: 16px 32px !important;
78
+ font-size: 18px !important;
79
+ max-width: 300px !important;
80
+ }
81
+ }
82
+
83
+ /* تنظیمات موبایل */
84
+ @media only screen and (max-width: 768px) {
85
+ .folium-map {
86
+ height: 300px !important;
87
+ }
88
+
89
+ .price-container {
90
+ width: 95% !important;
91
+ }
92
+ }
93
 
94
  * {
95
  font-family: 'Vazir', sans-serif !important;
 
497
  <h2 style="color: #6a0dad; margin: 0;">رهیار 🚖</h2>
498
  <p style="color: #6a0dad; margin: 0;">همراه سفرهای درون‌شهری شما، راهی مطمئن، راهی روشن، رهیار</p>
499
  """, unsafe_allow_html=True)
500
+
501
  st.markdown("### مسیر سفر شما")
502
+ map_obj = create_ride_map()
503
+ folium_static(map_obj, width=1000 if st.session_state.is_desktop else 800,
504
+ height=500 if st.session_state.is_desktop else 400)
505
+
506
+ # قیمت
507
  st.markdown(f"""
508
  <div class="price-container">
509
  <div style="display: flex; justify-content: space-between; align-items: center;">
 
515
 
516
  show_explanation(st.session_state.scenario_type)
517
 
518
+ # دکمه‌ها با چیدمان بهینه برای دسکتاپ
519
+ if st.session_state.is_desktop:
520
+ cols = st.columns(2)
521
+ with cols[0]:
522
+ if st.button("درخواست راهیار", key="accept_btn_desktop",
523
+ type="primary", use_container_width=True):
524
+ st.session_state.price_accepted = 1
525
+ st.rerun()
526
+ with cols[1]:
527
+ if st.button("رد قیمت", key="reject_btn_desktop",
528
+ type="secondary", use_container_width=True):
529
+ st.session_state.price_accepted = 0
530
+ st.rerun()
531
+ else:
532
+ # نسخه موبایل
533
+ if st.button("درخواست راهیار", key="accept_btn_mobile"):
534
  st.session_state.price_accepted = 1
 
535
  st.rerun()
536
+ if st.button("رد قیمت", key="reject_btn_mobile"):
 
 
 
 
537
  st.session_state.price_accepted = 0
 
538
  st.rerun()
539
+
540
  def transparency_questions():
541
  """سوالات شفافیت"""
542
  st.header("📊")
 
664
 
665
  # ========== مدیریت وضعیت و صفحه‌بندی ==========
666
  def main():
667
+ # تشخیص دستگاه
668
+ user_agent = st.experimental_get_query_params().get("user_agent", [""])[0]
669
+ st.session_state.is_desktop = "mobile" not in user_agent.lower()
670
+
671
  if 'current_page' not in st.session_state:
672
  st.session_state.current_page = "welcome"
673
  st.session_state.scenario_type = random.choice(["control", "input", "counterfactual"])