Skip to content

Commit

Permalink
feat #95 : 인스타로 공유하기 기본 기능 추가
Browse files Browse the repository at this point in the history
.
  • Loading branch information
enebin committed Sep 12, 2023
1 parent f2cb3a3 commit e895ba5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Plugins/EnvPlugin/ProjectDescriptionHelpers/InfoPlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public extension Project {
],
]
],
"LSApplicationQueriesSchemes": ["kakaokompassauth", "kakaolink"],
"LSApplicationQueriesSchemes": [
"kakaokompassauth",
"kakaolink",
"instagram",
"instagram-stories"
],
"NSPhotoLibraryAddUsageDescription": "스크린샷을 저장하기 위해서 앨범 접근 권한이 필요합니다"
]

Expand Down
56 changes: 50 additions & 6 deletions Projects/Features/Sources/MyPage/MyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,55 @@ struct MyPageView: View {
.border(DSKitAsset.Color.keymeBlack.swiftUIColor, width: viewStore.imageExportMode ? 5 : 0)
}
.sheet(item: $tempImage, content: { image in
Image(uiImage: image.image)
ZStack {
DSKitAsset.Color.keymeBlack.swiftUIColor
Image(uiImage: image.image)
.resizable()
.scaledToFit()
.fullFrame()

VStack {
Spacer()
HStack {
Button(action: {
let image = image.image

if let storiesUrl = URL(string: "instagram-stories:https://share?source_application=969563760790586") {
if UIApplication.shared.canOpenURL(storiesUrl) {
guard let imageData = image.pngData() else { return }
let pasteboardItems: [String: Any] = [
"com.instagram.sharedSticker.stickerImage": imageData,
"com.instagram.sharedSticker.backgroundTopColor": "#171717",
"com.instagram.sharedSticker.backgroundBottomColor": "#171717"
]
let pasteboardOptions = [
UIPasteboard.OptionsKey.expirationDate:
Date().addingTimeInterval(300)
]
UIPasteboard.general.setItems([pasteboardItems], options:
pasteboardOptions)
UIApplication.shared.open(storiesUrl, options: [:],
completionHandler: nil)
} else {
print("Sorry the application is not installed")
}
}


}) {
Text("스토리")
}

Button(action: { imageSaver.save(image.image) { error in
// TODO: Show alert
} }) {
Text("앨범에 저장하기")
}

ShareLink(item: Image(uiImage: image.image), preview: SharePreview("Keyme - 나의 성격", image: Image(uiImage: image.image)))
}
}
}
})
.sheet(
store: store.scope(
Expand Down Expand Up @@ -274,6 +322,7 @@ private extension MyPageView {
.scaleEffect(1.0 / 0.81)
}
}
// .frame(width: 1080 / 3, height: 1920 / 3) // Image size
.frame(width: 310, height: 570) // Image size

let renderer = ImageRenderer(content: exportView)
Expand All @@ -284,11 +333,6 @@ private extension MyPageView {
return
}

imageSaver.save(exportImage) { error in
// TODO: Show alert
return
}

// Show bottom sheets
tempImage = ScreenImage(image: exportImage)
}
Expand Down

0 comments on commit e895ba5

Please sign in to comment.