This file contains hidden or 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
| // | |
| // ContentView.swift | |
| // ScenePhase | |
| // | |
| // Created by Ming on 6/9/2022. | |
| // | |
| import SwiftUI | |
| struct ContentView: View { |
This file contains hidden or 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 | |
| import AVFoundation | |
| func toggleTorch(on: Bool) { | |
| guard let device = AVCaptureDevice.default(for: .video) else { return } | |
| if device.hasTorch { | |
| do { | |
| try device.lockForConfiguration() | |
| device.torchMode = on ? .on : .off |
This file contains hidden or 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 ContentView: View { | |
| @AppStorage("appIcon") private var appIcon: String = "" | |
| @State var appIcons = ["AppIcon", "AppIcon 2"] | |
| var body: some View { | |
| Picker(selection: $appIcon, label: Text("App Icon Picker")) { | |
| ForEach(appIcons, id: \.self) { icon in | |
| Text(icon).tag(icon) | |
| } |
This file contains hidden or 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 PizzaDeliveryAttributes: ActivityAttributes { | |
| public typealias PizzaDeliveryStatus = ContentState | |
| public struct ContentState: Codable, Hashable { | |
| var driverName: String | |
| var estimatedDeliveryTime: Date | |
| } | |
| var numberOfPizzas: Int | |
| var totalAmount: String |
This file contains hidden or 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 ActivityKit | |
| import WidgetKit | |
| import SwiftUI | |
| @main | |
| struct Widgets: WidgetBundle { | |
| var body: some Widget { | |
| PizzaDeliveryActivityWidget() | |
| } | |
| } |
This file contains hidden or 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
| func startDeliveryPizza() { | |
| let pizzaDeliveryAttributes = PizzaDeliveryAttributes(numberOfPizzas: 1, totalAmount:"$99") | |
| let initialContentState = PizzaDeliveryAttributes.PizzaDeliveryStatus(driverName: "TIM 👨🏻🍳", estimatedDeliveryTime: Date().addingTimeInterval(15 * 60)) | |
| do { | |
| let deliveryActivity = try Activity<PizzaDeliveryAttributes>.request( | |
| attributes: pizzaDeliveryAttributes, | |
| contentState: initialContentState, | |
| pushType: nil) |
This file contains hidden or 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
| function getDalle2() { | |
| setError(false); | |
| setLoading(true); | |
| fetch(`/api/dalle2?k=${token}&q=${query}`, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| }, | |
| }) | |
| .then((res) => res.json()) |
This file contains hidden or 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 { Dalle } from "dalle-node" | |
| export default async function handler(req, res) { | |
| const dalle = new Dalle(req.query.k); | |
| const generations = await dalle.generate(req.query.q); | |
| res.status(200).json({ result: generations }) | |
| } |
This file contains hidden or 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
| @media (prefers-color-scheme: dark) { | |
| body { | |
| background-color: #000; | |
| color: white; | |
| } | |
| } |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> | |
| <title>Dark Mode Test</title> | |
| <meta name="color-scheme" content="light dark"> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | |
| <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css"> |