Advertisement
iforaa

Swift Code

May 1st, 2025 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 6.99 KB | None | 0 0
  1. 2struct MapFeatureView: View {
  2.     @Perception.Bindable var store: StoreOf<MapFeature_>
  3.    
  4.     @State var switchMapTypeEvent: MKMapType? = nil
  5.     @State var addedAnnotations: [PointOfInterestAnnotation] = []
  6.     var fogOverlay: FogOverlay = FogOverlay(mapRect: MapView.createWorldBoundingBox())
  7.     @Environment(\.openURL) var openURL
  8.    
  9.    
  10.     @Namespace var animation
  11.     fdsfsdfsdf
  12.     var body: some View {
  13.         WithPerceptionTracking {
  14.             MapView(
  15.                 pointsOfInterest: store.pointsOfInterest,
  16.                 region: $store.region,
  17.                 selectedPointOfInterest: $store.selectedPointOfInterest,
  18.                 zoom: $store.zoom,
  19.                 isUserChangingRegion: $store.isUserChangingRegion,
  20.                 switchMapTypeEvent: $switchMapTypeEvent,
  21.                 centerEventRegion: $store.eventCenter,
  22.                 addedAnnotations: $addedAnnotations,
  23.                 fogOverlay: fogOverlay
  24.             )
  25.             .onAppear(perform: {
  26.                 store.send(.requestLocationAuthStatus)
  27.             })
  28.             .overlay(alignment: .bottom, content: {
  29.                 LinearGradient(gradient: Gradient(colors: [.white.opacity(0.65), .clear]), startPoint: .bottom, endPoint: .top)
  30.                     .frame(height: 180)
  31.             })
  32.             .overlay(alignment: .bottom) {
  33.                 Group {
  34.                     //                    if store.isListOfFriendsShown == false {
  35.                     //                        Button {
  36.                     //                            store.send(.updateListOfFriendsShownStatus(true), animation: .bouncy)
  37.                     //                        } label: {
  38.                     //                            ZStack {
  39.                     //                                ForEach(Array(store.friends.prefix(3).enumerated()), id: \.offset) { index, user  in
  40.                     //                                    UserpicView(user: user, size: CGSize(width: 25, height: 25))
  41.                     //                                        .offset(x: CGFloat(index) * 15)
  42.                     //                                }
  43.                     //
  44.                     //                            }
  45.                     //                            .offset(x: -15)
  46.                     //                            .matchedGeometryEffect(id: "isListOfFriendsShown", in: animation)
  47.                     //                        }
  48.                     //                    } else {
  49.                     ScrollView(.horizontal, showsIndicators: false) {
  50.                         HStack {
  51.                             ForEach(store.pointsOfInterest) { poi in
  52.                                
  53.                                 VStack(spacing: 0) {
  54.                                     UserpicView(user: poi.owner, isWithStroke: true, strokeColor: .white, strokeLineWidth: 2)
  55.                                    
  56.                                     Text("\(poi.owner.shownName)")
  57.                                         .padding(2)
  58.                                         .font(.gilroy(size: 14, weight: .medium))
  59.                                         .fixedSize(horizontal: false, vertical: true)
  60.                                         .lineLimit(2)
  61.                                         .multilineTextAlignment(.center)
  62.                                         .background(.white)
  63.                                         .foregroundColor(.black)
  64.                                         .padding(.top, 2)
  65.                                         .frame(width: 65)
  66.                                 }
  67.                                 .onTapGesture {
  68.                                     store.send(.focusOnUser(poi.owner))
  69.                                 }
  70.                                
  71.                                
  72.                             }
  73.                         }
  74.                         .offset(x: 5)
  75.                     }
  76.                     .frame(width: UIScreen.main.bounds.width, height: 54)
  77.                     .matchedGeometryEffect(id: "isListOfFriendsShown", in: animation)
  78.                     //                    }
  79.                 }
  80.                 .padding(.bottom, 110)
  81.                 .opacity(store.currentLocationAuthStatus != .authorizedAlways ? 0.0 : 1.0)
  82.             }
  83.             .overlay {
  84.                 if store.currentLocationAuthStatus != .authorizedAlways {
  85.                     ZStack {
  86.                         Color.white.opacity(0.80)
  87.                         VStack {
  88.                            
  89.                             Text("We need your location permission first")
  90.                                 .foregroundColor(.black)
  91.                                 .font(.gilroy(size: 20, weight: .medium))
  92.                                 .multilineTextAlignment(.center)
  93.                                 .padding()
  94.                            
  95.                             ROTextButton(title: "Share!") {
  96.                                 if store.currentLocationAuthStatus != .authorizedAlways {
  97.                                     if let url = URL(string: UIApplication.openSettingsURLString),
  98.                                        UIApplication.shared.canOpenURL(url) {
  99.                                         openURL(url)
  100.                                     }
  101.                                 } else {
  102.                                     store.send(.requestPermission)
  103.                                 }
  104.                             }
  105.                             .frame(width: 100, height: 50)
  106.                         }
  107.                     }
  108.                     .frame(width: UIScreen.main.bounds.width * 0.95, height: UIScreen.main.bounds.width * 1.5)
  109.                     .cornerRadius(14)
  110.                 }
  111.             }
  112.             .overlay(alignment: .topLeading) {
  113.                 if let weatherData = store.weatherData {
  114.                    
  115.                        
  116.                        
  117.                             VStack(alignment: .leading) {
  118.                                 Text(weatherData.name)
  119.                                     .foregroundColor(.white)
  120.                                     .font(.gilroy(size: 50, weight: .bold))
  121.                                     .shadow(color: Color.gray, radius: 2, x: 0, y: 2)
  122.                                
  123.                                 Text(weatherData.formattedTemp)
  124.                                     .font(.gilroy(size: 15, weight: .medium))
  125.                                     .padding(.top, 2)
  126.                                     .foregroundColor(.black)
  127.                                     .background(.white)
  128.                                
  129.                             }
  130.                             .padding(.leading, 20)
  131.                             .padding(.top, 55)
  132.                                    
  133.                                
  134.                                
  135.                        
  136.                    
  137.                    
  138.                 }
  139.             }
  140.         }
  141.     }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement