Skip to content

Commit

Permalink
分享相关图片前可以先预览其效果
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Aug 11, 2023
1 parent 345f635 commit f88e86f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
8 changes: 4 additions & 4 deletions BookTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@
CODE_SIGN_ENTITLEMENTS = BookTime/BookTime.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 62;
CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_ASSET_PATHS = "\"BookTime/Preview Content\"";
DEVELOPMENT_TEAM = M84W4U7RV7;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -723,7 +723,7 @@
CODE_SIGN_ENTITLEMENTS = BookTime/BookTime.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 62;
CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_ASSET_PATHS = "\"BookTime/Preview Content\"";
DEVELOPMENT_TEAM = M84W4U7RV7;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -762,7 +762,7 @@
CODE_SIGN_ENTITLEMENTS = BookTimeWidgetExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 62;
CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_TEAM = M84W4U7RV7;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = BookTimeWidget/Info.plist;
Expand Down Expand Up @@ -794,7 +794,7 @@
CODE_SIGN_ENTITLEMENTS = BookTimeWidgetExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 62;
CURRENT_PROJECT_VERSION = 63;
DEVELOPMENT_TEAM = M84W4U7RV7;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = BookTimeWidget/Info.plist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
filePath = "BookTime/View/BookCard.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "94"
endingLineNumber = "94"
startingLineNumber = "95"
endingLineNumber = "95"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
Expand All @@ -110,8 +110,8 @@
filePath = "BookTime/View/BookCard.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "111"
endingLineNumber = "111"
startingLineNumber = "112"
endingLineNumber = "112"
landmarkName = "body"
landmarkType = "24">
<Locations>
Expand Down
23 changes: 21 additions & 2 deletions BookTime/View/BookCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct BookCard: View {

@State private var handShowTimer:Bool = false
@State private var showTimer:Bool = false
@State private var showSharePic:Bool = false
@State private var showAlert:Bool = false
@State private var showBatterySheet:Bool = false

Expand Down Expand Up @@ -85,7 +86,7 @@ struct BookCard: View {
.resizable()
.foregroundColor(.accentColor)
.scaledToFit()
.frame(width: 30,height: 30)
.frame(width: 40,height: 40)
.scaleEffect(book.rating == index+1 ? 1.25 : 1.0)
.animation(.linear(duration: 0.1), value: book.rating)
.onTapGesture {
Expand Down Expand Up @@ -207,7 +208,13 @@ struct BookCard: View {
.padding(10)
.toolbar(content: {
if(isDone){
ShareLink(item: Image(uiImage: generateSnapshot()), preview: SharePreview("BookTime"))
Button{
showSharePic = true
}label:{
Image(systemName: "square.and.arrow.up")
}

// ShareLink(item: Image(uiImage: generateSnapshot()), preview: SharePreview("BookTime"))
}

})
Expand Down Expand Up @@ -262,6 +269,18 @@ struct BookCard: View {
generator.notificationOccurred(.success)
})
})
.sheet(isPresented: $showSharePic){
VStack(spacing: 30){
BookCardExport(book: book)
ShareLink(item: Image(uiImage: generateSnapshot()), preview: SharePreview("BookTime")){
Label( "Share",systemImage:"square.and.arrow.up.circle")
.font(.largeTitle)
.labelStyle(.iconOnly)

}
}

}

// .toolbar {
// ToolbarItem(placement: .navigationBarTrailing) {
Expand Down
46 changes: 34 additions & 12 deletions BookTime/View/Statistics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct Statistics: View {
@State private var isShowYear = false

@State private var isShowReadedBooks = false
@State private var showSharePic = false

@State private var shareImage:UIImage? = nil

@State private var selectBookID:String = ""
Expand Down Expand Up @@ -370,7 +372,7 @@ struct Statistics: View {
}

@ViewBuilder
func exportBox(isRendererImage:Bool = false) -> some View{
func exportBox(isRendererImage:Bool = false,isShow:Bool = false) -> some View{
// VStack{
VStack(){
VStack{
Expand All @@ -395,12 +397,14 @@ struct Statistics: View {
}
.padding()
.overlay(
RoundedRectangle(cornerRadius: 10.0)
.stroke(lineWidth: 3.0)
.foregroundColor(Color("AccentColor"))
RoundedRectangle(cornerRadius: 10.0)
.stroke(lineWidth: 3.0)
.foregroundColor(Color("AccentColor"))
.opacity(isShow ? 0 : 1)
)
}
.background(Color.white)
.preferredColorScheme(.light)
// .background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: 10.0))
.padding()
.ignoresSafeArea()
Expand All @@ -419,20 +423,38 @@ struct Statistics: View {
reportView()
.padding()
.navigationTitle("Achievement")
// .navigationBarTitleDisplayMode(.inline)
.toolbar(content: {
ShareLink(item: Image(uiImage: generateSnapshot()), preview: SharePreview("BookTime"))
// Button(action: {
// showOptions = true
// }){
// Image(systemName: "square.and.arrow.up")
// }
Button{
showSharePic = true
}label:{
Image(systemName: "square.and.arrow.up")
}
})

}


}
.sheet(isPresented: $showSharePic){
ScrollView{
VStack(spacing: 20){
exportBox(isRendererImage: true,isShow: true)

Color.accentColor.frame(height:1)

ShareLink(item: Image(uiImage: generateSnapshot()), preview: SharePreview("BookTime")){
Label( "Share",systemImage:"square.and.arrow.up.circle")
.font(.largeTitle)
.labelStyle(.iconOnly)

}
}


}

}

.fullScreenCover(isPresented: $showCover, content: {
GeometryReader{reader in
let scale = reader.size.height / 400 * 0.618
Expand Down

0 comments on commit f88e86f

Please sign in to comment.