This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
List(tweets.identified(by: \.id)) { tweet in | |
HStack { | |
Text(tweet.message) | |
tweet.imageName.map | |
{ ViewBuilder.buildEither(first: Image($0) } | |
?? ViewBuilder.buildEither(second: Text("No image")) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
List(tweets.identified(by: \.id)) { tweet in | |
HStack { | |
Text(tweet.message) | |
tweet.imageName.map { Image($0) } ?? Image("fallback") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
List(tweets.identified(by: \.id)) { tweet in | |
HStack { | |
Text(tweet.message) | |
tweet.imageName.map { Image($0) } | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
List(tweets.identified(by: \.id)) { tweet in | |
HStack { | |
Text(tweet.message) | |
IfLet(tweet.imageName) { imageName in | |
Image(imageName) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct IfLet<T, Out: View>: View { | |
let value: T? | |
let produce: (T) -> Out | |
init(_ value: T?, produce: @escaping (T) -> Out) { | |
self.value = value | |
self.produce = produce | |
} | |
var body: some View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
Group { | |
if x { | |
Text(“Something”) | |
} else { | |
Text(“Something else”) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
Group { | |
Text(“First thing”) | |
Text(“Second thing”) | |
Text(“Third thing”) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Tweet: Identifiable { | |
var id: UUID | |
let message: String | |
let imageName: String? | |
init(message: String, imageName: String? = nil) { | |
self.id = UUID() | |
self.message = message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Types | |
*/ | |
// IState | |
import rootReducer from "./reducers"; | |
export type IState = { | |
// Maps the return type of each reducer into its return-type | |
[K in keyof typeof rootReducer]: ReturnType<typeof rootReducer[K]> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"BTTWidgetName" : "Toggle appearance", | |
"BTTTriggerType" : 639, | |
"BTTTriggerTypeDescription" : "Apple Script Widget", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTPredefinedActionType" : 195, | |
"BTTPredefinedActionName" : "Run Apple Script (async in background)", | |
"BTTInlineAppleScript" : "tell application \"System Events\"\r\ttell appearance preferences\r\t\tset dark mode to not dark mode\r\tend tell\rend tell", | |
"BTTEnabled2" : 1, | |
"BTTUUID" : "ECC2514E-86E5-4304-AABA-BA7749257FDC", |
NewerOlder