Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.945",
"green" : "0.757",
"red" : "0.333"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.898",
"green" : "0.557",
"red" : "0.251"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"images" : [
{
"filename" : "icon_1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions macos/Thoughts-iOS/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
106 changes: 106 additions & 0 deletions macos/Thoughts-iOS/ThoughtsApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright (c) 2021-2026 Jason Morley
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import SwiftUI

import ThoughtsCore

@main
struct ThoughtsApp: App {

enum SheetType: Identifiable {

var id: Self {
return self
}

case introduction
}

class ModelDelegate: NSObject, ApplicationModelDelegate {

func showIntroduction(applicationModel: ApplicationModel) {
}

func showUpdateAlert(applicationModel: ApplicationModel) {
}

func showThought(applicationModel: ApplicationModel) {
}

}

@Environment(\.scenePhase) private var scenePhase

@State private var sheet: SheetType?

var applicationModel: ApplicationModel
var modelDelegate: ModelDelegate

init() {
let applicationModel = ApplicationModel()
let modelDelegate = ModelDelegate()
applicationModel.delegate = modelDelegate
self.applicationModel = applicationModel
self.modelDelegate = modelDelegate
self.applicationModel.start()
}

var body: some Scene {
WindowGroup {
NavigationView {
ContentView(applicationModel: applicationModel)
.navigationBarTitleDisplayMode(.inline)
.sheet(item: $sheet) { sheet in
switch sheet {
case .introduction:
NavigationView {
IntroductionView(applicationModel: applicationModel)
}
}
}
}
.environment(applicationModel)
}
.onChange(of: applicationModel.didShowIntroduction, initial: true) { _, didShowIntroduction in
guard !didShowIntroduction else {
return
}
sheet = .introduction
}
.onChange(of: scenePhase) { _, scenePhase in
switch scenePhase {
case .background, .inactive:
applicationModel.lastBackgroundDate = min(Date(), applicationModel.lastBackgroundDate)
case .active:
let backgroundDuration = applicationModel.lastBackgroundDate.timeIntervalSinceNow * -1
print("Opened after \(backgroundDuration) seconds.")
guard backgroundDuration > 60 * 5 else {
break
}
print("Creating new thought...")
applicationModel.lastBackgroundDate = Date.distantFuture
applicationModel.new()
@unknown default:
break
}
}
}
}
40 changes: 40 additions & 0 deletions macos/Thoughts-iOS/Views/IntroductionView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2021-2026 Jason Morley
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import SwiftUI
import ThoughtsCore

struct IntroductionView: View {

@Environment(\.dismiss) private var dismiss

let applicationModel: ApplicationModel

var body: some View {
Button("Done") {
applicationModel.introductionVersion = ApplicationModel.introductionVersion
applicationModel.new()
dismiss()
}
.navigationTitle("Introduction")
.interactiveDismissDisabled()
}

}
Loading