blob: ce940681cde7c2b9bfef23685a77b95fe03d4e65 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import Foundation
import SwiftUI
import WidgetKit
struct DinoGameWidget: Widget {
// Changing |kind| or deleting this widget will cause all installed instances of this widget to
// stop updating and show the placeholder state.
let kind: String = "DinoGameWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
DinoGameWidgetEntryView(entry: entry)
struct DinoGameWidgetEntryView: View {
let background = "widget_dino_background"
let backgroundPlaceholder = "widget_dino_background_placeholder"
var entry: Provider.Entry
@Environment(\.redactionReasons) var redactionReasons
var body: some View {
// We wrap this widget in a link on top of using `widgetUrl` so that the voice over will treat
// the widget as one tap target. Without the wrapping, voice over treats the content within
// the widget as multiple tap targets.
Link(destination: WidgetConstants.DinoGameWidget.url) {
ZStack {
Image(redactionReasons.isEmpty ? background : backgroundPlaceholder)
VStack(alignment: .leading, spacing: 0) {
.frame(minWidth: 0, maxWidth: .infinity)
HStack {
.padding([.leading, .bottom], 16)