Skip to content

Commit

Permalink
小组件兼容iOS17 最新版的API
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Sep 20, 2023
1 parent 873c197 commit d293b52
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 27 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/BookTime.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/runConfigurations/BookTime.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/xcode.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@
endingLineNumber = "461"
landmarkName = "body"
landmarkType = "24">
<Locations>
<Location
uuid = "855CC4E9-7626-4DDA-B789-03D1B639B3D3 - dd4cd93133af14b8"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #5 (Swift.Result&lt;Swift.Array&lt;Foundation.URL&gt;, Swift.Error&gt;) -&gt; () in closure #1 () -&gt; &lt;&lt;opaque return type of SwiftUI.View.fileImporter(isPresented: SwiftUI.Binding&lt;Swift.Bool&gt;, allowedContentTypes: Swift.Array&lt;UniformTypeIdentifiers.UTType&gt;, allowsMultipleSelection: Swift.Bool, onCompletion: (Swift.Result&lt;Swift.Array&lt;Foundation.URL&gt;, Swift.Error&gt;) -&gt; ()) -&gt; some&gt;&gt;.0 in BookTime.Setting.body.getter : some"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/View/Setting.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "461"
endingLineNumber = "461"
offsetFromSymbolStart = "11916">
</Location>
<Location
uuid = "855CC4E9-7626-4DDA-B789-03D1B639B3D3 - dd4cd93133af14b8"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #5 (Swift.Result&lt;Swift.Array&lt;Foundation.URL&gt;, Swift.Error&gt;) -&gt; () in closure #1 () -&gt; &lt;&lt;opaque return type of SwiftUI.View.fileImporter(isPresented: SwiftUI.Binding&lt;Swift.Bool&gt;, allowedContentTypes: Swift.Array&lt;UniformTypeIdentifiers.UTType&gt;, allowsMultipleSelection: Swift.Bool, onCompletion: (Swift.Result&lt;Swift.Array&lt;Foundation.URL&gt;, Swift.Error&gt;) -&gt; ()) -&gt; some&gt;&gt;.0 in BookTime.Setting.body.getter : some"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/View/Setting.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "461"
endingLineNumber = "461"
offsetFromSymbolStart = "11160">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down Expand Up @@ -81,6 +113,36 @@
endingLineNumber = "65"
offsetFromSymbolStart = "144">
</Location>
<Location
uuid = "A2D51D84-F2D1-4226-B39F-7B65F0E8312A - a69e5c0a889289e0"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #2 (Swift.String) -&gt; () in BookTime.ImagePicker.Coordinator.imagePickerController(_: __C.UIImagePickerController, didFinishPickingMediaWithInfo: Swift.Dictionary&lt;__C.UIImagePickerControllerInfoKey, Any&gt;) -&gt; ()"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/Util/ImagePicker.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "65"
endingLineNumber = "65"
offsetFromSymbolStart = "204">
</Location>
<Location
uuid = "A2D51D84-F2D1-4226-B39F-7B65F0E8312A - a69e5c0a889289e0"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #2 (Swift.String) -&gt; () in BookTime.ImagePicker.Coordinator.imagePickerController(_: __C.UIImagePickerController, didFinishPickingMediaWithInfo: Swift.Dictionary&lt;__C.UIImagePickerControllerInfoKey, Any&gt;) -&gt; ()"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/Util/ImagePicker.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "65"
endingLineNumber = "65"
offsetFromSymbolStart = "184">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -98,6 +160,38 @@
endingLineNumber = "95"
landmarkName = "body"
landmarkType = "24">
<Locations>
<Location
uuid = "4C9F2313-BD4A-4D92-A0F4-CDCE8C73C26A - 444bb46f6df62d13"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 () -&gt; () in closure #1 (Swift.Int) -&gt; &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0 in closure #3 () -&gt; SwiftUI.ForEach&lt;Swift.ClosedRange&lt;Swift.Int&gt;, Swift.Int, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.Text, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0, Swift.Optional&lt;Swift.Optional&lt;SwiftUI.HStack&lt;SwiftUI.ForEach&lt;Swift.Array&lt;BookTime.Tag&gt;, Swift.String, &lt;&lt;opaque return type of SwiftUI.View.font(Swift.Optional&lt;SwiftUI.Font&gt;) -&gt; some&gt;&gt;.0&gt;&gt;&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.gesture&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.Gesture&gt;(_: &#x3c4;_1_0, including: SwiftUI.GestureMask) -&gt; some&gt;&gt;.0, Swift.Optional&lt;SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(BookTime.Slogan, BookTime.Slogan)&gt;&gt;&gt;)&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(SwiftUI.Text, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0, Swift.Optional&lt;Swift.Optional&lt;SwiftUI.HStack&lt;SwiftUI.ForEach&lt;Swift.Array&lt;BookTime.Tag&gt;, Swift.String, &lt;&lt;opaque return type of SwiftUI.View.font(Swift.Optional&lt;SwiftUI.Font&gt;) -&gt; some&gt;&gt;.0&gt;&gt;&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.gesture&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.Gesture&gt;(_: &#x3c4;_1_0, including: SwiftUI.GestureMask) -&gt; some&gt;&gt;.0, Swift.Optional&lt;SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(BookTime.Slogan, BookTime.Slogan)&gt;&gt;&gt;)&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.animation&lt;&#x3c4;_0_0 where &#x3c4;_1_0: Swift.Equatable&gt;(_: Swift.Optional&lt;SwiftUI.Animation&gt;, value: &#x3c4;_1_0) -&gt; some&gt;&gt;.0, Swift.Optional&lt;&lt;&lt;opaque return type of SwiftUI.View.onAppear(perform: Swift.Optional&lt;() -&gt; ()&gt;) -&gt; some&gt;&gt;.0&gt;)&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(&lt;&lt;opaque return type of SwiftUI.View.toolbar&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.View&gt;(content: () -&gt; &#x3c4;_1_0) -&gt; some&gt;&gt;.0, ConfettiSwiftUI.ConfettiCannon)&gt; in BookTime.BookCard.body.getter : some"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/View/BookCard.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
offsetFromSymbolStart = "172">
</Location>
<Location
uuid = "4C9F2313-BD4A-4D92-A0F4-CDCE8C73C26A - 444bb46f6df62d13"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 () -&gt; () in closure #1 (Swift.Int) -&gt; &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0 in closure #3 () -&gt; SwiftUI.ForEach&lt;Swift.ClosedRange&lt;Swift.Int&gt;, Swift.Int, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.Text, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0, Swift.Optional&lt;Swift.Optional&lt;SwiftUI.HStack&lt;SwiftUI.ForEach&lt;Swift.Array&lt;BookTime.Tag&gt;, Swift.String, &lt;&lt;opaque return type of SwiftUI.View.font(Swift.Optional&lt;SwiftUI.Font&gt;) -&gt; some&gt;&gt;.0&gt;&gt;&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.gesture&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.Gesture&gt;(_: &#x3c4;_1_0, including: SwiftUI.GestureMask) -&gt; some&gt;&gt;.0, Swift.Optional&lt;SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(BookTime.Slogan, BookTime.Slogan)&gt;&gt;&gt;)&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(SwiftUI.Text, &lt;&lt;opaque return type of SwiftUI.View.onTapGesture(count: Swift.Int, perform: () -&gt; ()) -&gt; some&gt;&gt;.0, Swift.Optional&lt;Swift.Optional&lt;SwiftUI.HStack&lt;SwiftUI.ForEach&lt;Swift.Array&lt;BookTime.Tag&gt;, Swift.String, &lt;&lt;opaque return type of SwiftUI.View.font(Swift.Optional&lt;SwiftUI.Font&gt;) -&gt; some&gt;&gt;.0&gt;&gt;&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.gesture&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.Gesture&gt;(_: &#x3c4;_1_0, including: SwiftUI.GestureMask) -&gt; some&gt;&gt;.0, Swift.Optional&lt;SwiftUI.VStack&lt;SwiftUI.TupleView&lt;(BookTime.Slogan, BookTime.Slogan)&gt;&gt;&gt;)&gt;&gt;, &lt;&lt;opaque return type of SwiftUI.View.animation&lt;&#x3c4;_0_0 where &#x3c4;_1_0: Swift.Equatable&gt;(_: Swift.Optional&lt;SwiftUI.Animation&gt;, value: &#x3c4;_1_0) -&gt; some&gt;&gt;.0, Swift.Optional&lt;&lt;&lt;opaque return type of SwiftUI.View.onAppear(perform: Swift.Optional&lt;() -&gt; ()&gt;) -&gt; some&gt;&gt;.0&gt;)&gt; in closure #1 () -&gt; SwiftUI.TupleView&lt;(&lt;&lt;opaque return type of SwiftUI.View.toolbar&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.View&gt;(content: () -&gt; &#x3c4;_1_0) -&gt; some&gt;&gt;.0, ConfettiSwiftUI.ConfettiCannon)&gt; in BookTime.BookCard.body.getter : some"
moduleName = "BookTime"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liurui/develop/workspace-xcode/BookTime/BookTime/View/BookCard.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
offsetFromSymbolStart = "152">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down
50 changes: 23 additions & 27 deletions BookTimeWidget/BookTimeWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ struct BookTimeWidgetEntryView : View {
}

}
.padding(.leading, 12)
.padding(.trailing,20)

// .padding(.leading, 12)
// .padding(.trailing,20)
}

@ViewBuilder
Expand All @@ -203,13 +204,13 @@ struct BookTimeWidgetEntryView : View {
}
}
.clipShape(Rectangle())
.padding(10)
// .padding(10)

Spacer()
mediumView(isInLarge: true)
}
.padding(.vertical,10)
.padding(.bottom,15)
// .padding(.vertical,10)
// .padding(.bottom,15)
}

@ViewBuilder
Expand Down Expand Up @@ -248,43 +249,26 @@ struct BookTimeWidgetEntryView : View {
case .systemSmall:
smallView
.frame(maxWidth: .infinity, maxHeight: .infinity) // << here !!
.background(Color("WidgetBackground"))
.widgetBackground(Color("WidgetBackground"))

case .systemMedium:
mediumView()
.frame(maxWidth: .infinity, maxHeight: .infinity) // << here !!
.background(Color("WidgetBackground"))
.widgetBackground(Color("WidgetBackground"))

case .systemLarge:
largeView
.frame(maxWidth: .infinity, maxHeight: .infinity) // << here !!
.background(Color("WidgetBackground"))
.widgetBackground(Color("WidgetBackground"))

case .accessoryCircular:
circularView
.widgetBackground(Color("WidgetBackground"))

default:
smallView
}


// VStack{
// let encodedData = UserDefaults(suiteName: "group.com.aruistar.BookTime")!.object(forKey: "sharedata") as? Data
// /* Decoding it using JSONDecoder*/
// if let carEncoded = encodedData {
// let carDecoded = try? JSONDecoder().decode(ShareData.self, from: carEncoded)
// if let car = carDecoded{
// Text("\(car.todayReadMin)")
// // You successfully retrieved your car object!
// }
// }
//
//
// Text(entry.date, style: .time)
// }.onAppear{
// }




}
}
Expand Down Expand Up @@ -314,3 +298,15 @@ struct BookTimeWidget_Previews: PreviewProvider {

}
}

extension View {
func widgetBackground(_ backgroundView: some View) -> some View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) {
backgroundView
}
} else {
return background(backgroundView).padding(15)
}
}
}

0 comments on commit d293b52

Please sign in to comment.