gkdivya commited on
Commit
8e20c92
·
1 Parent(s): 27ddd2d

Update influencer_ui.py

Browse files
Files changed (1) hide show
  1. influencer_ui.py +24 -26
influencer_ui.py CHANGED
@@ -3,6 +3,19 @@ from PIL import Image
3
  import requests
4
  from io import BytesIO
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  def display_influencer_details(influencer_info):
8
  with st.container(): # Using a container to organize the layout
@@ -15,27 +28,10 @@ def show_influencer_search_page():
15
  st.markdown("Discover influencers by name, niche, location, follower count, and more.")
16
  search_query = st.text_input("Search Influencers", "")
17
 
18
- influencers_data = {
19
- "influencer1": {
20
- "name": "Influencer One",
21
- "image": "./images/inf1.png", # Replace with actual image paths
22
- "details": "Details about Influencer One..."
23
- },
24
- "influencer2": {
25
- "name": "Influencer Two",
26
- "image": "./images/inf2.png",
27
- "details": "Details about Influencer Two..."
28
- }
29
- # Add more influencers as needed
30
- }
31
-
32
- # Function to display influencer details
33
 
34
-
35
-
36
  # Initialize session state for selected influencer
37
- if 'selected_influencer' not in st.session_state:
38
- st.session_state.selected_influencer = None
39
 
40
  # Influencer search button (assuming this is part of your UI)
41
  search_button = st.button("Search Influencers")
@@ -49,12 +45,14 @@ def show_influencer_search_page():
49
  st.image(influencer_info["image"], width=50)
50
 
51
  with col2:
52
- if st.button(influencer_info["name"], key=influencer_id):
53
- st.session_state.selected_influencer = influencer_id
54
 
55
- # Display the details of the selected influencer outside the loop
56
- if st.session_state.selected_influencer:
57
- selected_influencer_info = influencers_data[st.session_state.selected_influencer]
58
- display_influencer_details(selected_influencer_info)
59
-
 
 
60
 
 
3
  import requests
4
  from io import BytesIO
5
 
6
+ influencers_data = {
7
+ "influencer1": {
8
+ "name": "Influencer One",
9
+ "image": "./images/inf1.png", # Replace with actual image paths
10
+ "details": "Details about Influencer One..."
11
+ },
12
+ "influencer2": {
13
+ "name": "Influencer Two",
14
+ "image": "./images/inf2.png",
15
+ "details": "Details about Influencer Two..."
16
+ }
17
+ # Add more influencers as needed
18
+ }
19
 
20
  def display_influencer_details(influencer_info):
21
  with st.container(): # Using a container to organize the layout
 
28
  st.markdown("Discover influencers by name, niche, location, follower count, and more.")
29
  search_query = st.text_input("Search Influencers", "")
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
 
 
32
  # Initialize session state for selected influencer
33
+ if 'show_details' not in st.session_state:
34
+ st.session_state.show_details = None
35
 
36
  # Influencer search button (assuming this is part of your UI)
37
  search_button = st.button("Search Influencers")
 
45
  st.image(influencer_info["image"], width=50)
46
 
47
  with col2:
48
+ if st.button("Show Details", key=influencer_id):
49
+ st.session_state.show_details = influencer_id
50
 
51
+ # Display the details of the selected influencer in an expander
52
+ if st.session_state.show_details:
53
+ with st.expander("Influencer Details"):
54
+ selected_influencer_info = influencers_data[st.session_state.show_details]
55
+ st.subheader(selected_influencer_info["name"])
56
+ st.image(selected_influencer_info["image"], width=200)
57
+ st.write(selected_influencer_info["details"])
58