I'm unable to find sample code that demonstrates how to support a custom Live Activity layout for Apple Watch. I have read the documentation and have added the supplementalActivityFamilies with small and medium. However, I am not able to detect when the activityFamily is set to small.
This is what I'm trying to use without success:
struct MyWidgetLiveActivity: Widget {
@Environment(\.activityFamily) var activityFamily: ActivityFamily
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyWidgetAttributes.self) { context in
if activityFamily == .small {
Text("Apple Watch! \(activityFamily.description)")
} else {
Text("Not small family: \(activityFamily.description)")
}
} dynamicIsland: { context in
return DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
Text("Leading")
}
DynamicIslandExpandedRegion(.trailing) {
Text("Trailing")
}
DynamicIslandExpandedRegion(.bottom) {
Text("Bottom")
}
} compactLeading: {
Text("CL")
} compactTrailing: {
Text("CT")
} minimal: {
Text("M")
}
}
.supplementalActivityFamilies([.small, .medium])
}
}
This code shows "Not small family: medium" on my Apple Watch. Could somebody provide some insight into why this doesn't work for me?