diff --git a/Vernissage/Views/SignInView.swift b/Vernissage/Views/SignInView.swift index 9b51961..2b0a044 100644 --- a/Vernissage/Views/SignInView.swift +++ b/Vernissage/Views/SignInView.swift @@ -12,7 +12,7 @@ struct SignInView: View { @State private var serverAddress: String = "" - var onSignInStateChenge: (_ applicationViewMode: ApplicationViewMode) -> Void? + var onSignInStateChenge: ((_ applicationViewMode: ApplicationViewMode) -> Void)? var body: some View { VStack { @@ -32,7 +32,7 @@ struct SignInView: View { try await AuthorizationService.shared.signIn(serverAddress: serverAddress, { accountData in DispatchQueue.main.async { self.applicationState.accountData = accountData - onSignInStateChenge(.mainView) + onSignInStateChenge?(.mainView) } }) } @@ -47,6 +47,6 @@ struct SignInView: View { struct SignInView_Previews: PreviewProvider { static var previews: some View { - SignInView { applicationViewMode in } + SignInView() } } diff --git a/Vernissage/Views/StatusView.swift b/Vernissage/Views/StatusView.swift index 7f54461..093b9ed 100644 --- a/Vernissage/Views/StatusView.swift +++ b/Vernissage/Views/StatusView.swift @@ -24,9 +24,11 @@ struct StatusView: View { ScrollView { if let statusData = self.statusData { VStack (alignment: .leading) { - ImagesCarousel(attachments: statusData.attachments()) { attachmentData in - self.setAttachment(attachmentData) - } + ImagesCarousel(attachments: statusData.attachments(), + exifCamera: $exifCamera, + exifExposure: $exifExposure, + exifCreatedDate: $exifCreatedDate, + exifLens: $exifLens) VStack(alignment: .leading) { NavigationLink(destination: UserProfileView( diff --git a/Vernissage/Widgets/CommentsSection.swift b/Vernissage/Widgets/CommentsSection.swift index 68d0343..5399362 100644 --- a/Vernissage/Widgets/CommentsSection.swift +++ b/Vernissage/Widgets/CommentsSection.swift @@ -15,7 +15,7 @@ struct CommentsSection: View { @State public var withDivider = true @State private var context: Context? - var onNewStatus: (_ context: Status) -> Void? + var onNewStatus: ((_ context: Status) -> Void)? private let contentWidth = Int(UIScreen.main.bounds.width) - 50 @@ -122,7 +122,7 @@ struct CommentsSection: View { favourited: status.favourited, favouritesCount: status.favouritesCount, bookmarked: status.bookmarked) { - onNewStatus(status) + self.onNewStatus?(status) } .foregroundColor(self.getInteractionRowTextColor()) .padding(.horizontal, 16) @@ -133,7 +133,7 @@ struct CommentsSection: View { } CommentsSection(statusId: status.id, withDivider: false) { context in - onNewStatus(context) + self.onNewStatus?(context) } } } @@ -167,6 +167,6 @@ struct CommentsSection: View { struct CommentsSection_Previews: PreviewProvider { static var previews: some View { - CommentsSection(statusId: "", withDivider: true) { context in } + CommentsSection(statusId: "", withDivider: true) } } diff --git a/Vernissage/Widgets/ImagesCarousel.swift b/Vernissage/Widgets/ImagesCarousel.swift index 8df6172..a6b8a3e 100644 --- a/Vernissage/Widgets/ImagesCarousel.swift +++ b/Vernissage/Widgets/ImagesCarousel.swift @@ -11,10 +11,13 @@ struct ImagesCarousel: View { @State private var height: Double = 0.0 @State private var selectedAttachmentId = "" - var onAttachmentChange: (_ attachmentData: AttachmentData) -> Void? + @Binding public var exifCamera: String? + @Binding public var exifExposure: String? + @Binding public var exifCreatedDate: String? + @Binding public var exifLens: String? var body: some View { - TabView(selection: $selectedAttachmentId) { + TabView() { ForEach(attachments, id: \.id) { attachment in if let image = UIImage(data: attachment.data) { Image(uiImage: image) @@ -28,7 +31,10 @@ struct ImagesCarousel: View { .tabViewStyle(PageTabViewStyle()) .onChange(of: selectedAttachmentId, perform: { index in if let attachment = attachments.first(where: { item in item.id == index }) { - onAttachmentChange(attachment) + self.exifCamera = attachment.exifCamera + self.exifExposure = attachment.exifExposure + self.exifCreatedDate = attachment.exifCreatedDate + self.exifLens = attachment.exifLens } }) .onAppear { @@ -57,8 +63,7 @@ struct ImagesCarousel: View { struct ImagesCarousel_Previews: PreviewProvider { static var previews: some View { - ImagesCarousel(attachments: []) { attachmentData in - - } + ImagesCarousel(attachments: [], exifCamera: .constant(""), exifExposure: .constant(""), exifCreatedDate: .constant(""), exifLens: .constant("")) + // ImagesCarousel(attachments: []) } } diff --git a/Vernissage/Widgets/InteractionRow.swift b/Vernissage/Widgets/InteractionRow.swift index 5c113af..cfedea5 100644 --- a/Vernissage/Widgets/InteractionRow.swift +++ b/Vernissage/Widgets/InteractionRow.swift @@ -16,13 +16,13 @@ struct InteractionRow: View { @State var favouritesCount = 0 @State var bookmarked = false - var onNewStatus: () -> Void? + var onNewStatus: (() -> Void)? var body: some View { HStack (alignment: .top) { Button { HapticService.shared.touch() - onNewStatus() + onNewStatus?() } label: { HStack(alignment: .center) { Image(systemName: "message") @@ -127,7 +127,7 @@ struct InteractionRow: View { struct InteractionRow_Previews: PreviewProvider { static var previews: some View { - InteractionRow() { } + InteractionRow() .previewLayout(.fixed(width: 300, height: 70)) } }