Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: awaseem/foqos
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5
Choose a base ref
...
head repository: awaseem/foqos
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.6
Choose a head ref
  • 13 commits
  • 22 files changed
  • 1 contributor

Commits on Mar 11, 2025

  1. updated version number

    awaseem committed Mar 11, 2025

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    e35208d View commit details

Commits on Mar 13, 2025

  1. added boilerplate for code

    awaseem committed Mar 13, 2025

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    1a03c4c View commit details
  2. added live activity sessions

    awaseem committed Mar 13, 2025
    Copy the full SHA
    5ed7d75 View commit details
  3. added live activity sessions

    awaseem committed Mar 13, 2025
    Copy the full SHA
    221fed9 View commit details
  4. added enable live activites

    awaseem committed Mar 13, 2025
    Copy the full SHA
    1ff4a2f View commit details
  5. removed bug for live activity

    awaseem committed Mar 13, 2025
    Copy the full SHA
    6f7803c View commit details
  6. Copy the full SHA
    3022b33 View commit details
  7. updated name

    awaseem committed Mar 13, 2025
    Copy the full SHA
    52ecbcb View commit details
  8. updated values

    awaseem committed Mar 13, 2025
    Copy the full SHA
    def8a38 View commit details
  9. added live activity message

    awaseem committed Mar 13, 2025
    Copy the full SHA
    462d344 View commit details
  10. added random insp message

    awaseem committed Mar 13, 2025
    Copy the full SHA
    ae55cb2 View commit details
  11. added live activites:

    awaseem committed Mar 13, 2025
    Copy the full SHA
    b3a428b View commit details
  12. updated compliance

    awaseem committed Mar 13, 2025
    Copy the full SHA
    f4819a5 View commit details
11 changes: 11 additions & 0 deletions FoqosWidget/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
35 changes: 35 additions & 0 deletions FoqosWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"images" : [
{
"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
}
}
6 changes: 6 additions & 0 deletions FoqosWidget/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
84 changes: 84 additions & 0 deletions FoqosWidget/FoqosWidget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// FoqosWidget.swift
// FoqosWidget
//
// Created by Ali Waseem on 2025-03-11.
//

import WidgetKit
import SwiftUI

struct Provider: TimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), emoji: "😀")
}

func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(), emoji: "😀")
completion(entry)
}

func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [SimpleEntry] = []

// Generate a timeline consisting of five entries an hour apart, starting from the current date.
let currentDate = Date()
for hourOffset in 0 ..< 5 {
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, emoji: "😀")
entries.append(entry)
}

let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}

// func relevances() async -> WidgetRelevances<Void> {
// // Generate a list containing the contexts this widget is relevant in.
// }
}

struct SimpleEntry: TimelineEntry {
let date: Date
let emoji: String
}

struct FoqosWidgetEntryView : View {
var entry: Provider.Entry

var body: some View {
VStack {
Text("Time:")
Text(entry.date, style: .time)

Text("Emoji:")
Text(entry.emoji)
}
}
}

struct FoqosWidget: Widget {
let kind: String = "FoqosWidget"

var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
if #available(iOS 17.0, *) {
FoqosWidgetEntryView(entry: entry)
.containerBackground(.fill.tertiary, for: .widget)
} else {
FoqosWidgetEntryView(entry: entry)
.padding()
.background()
}
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
}
}

#Preview(as: .systemSmall) {
FoqosWidget()
} timeline: {
SimpleEntry(date: .now, emoji: "😀")
SimpleEntry(date: .now, emoji: "🤩")
}
16 changes: 16 additions & 0 deletions FoqosWidget/FoqosWidgetBundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// FoqosWidgetBundle.swift
// FoqosWidget
//
// Created by Ali Waseem on 2025-03-11.
//

import WidgetKit
import SwiftUI

@main
struct FoqosWidgetBundle: WidgetBundle {
var body: some Widget {
FoqosWidgetLiveActivity()
}
}
142 changes: 142 additions & 0 deletions FoqosWidget/FoqosWidgetLiveActivity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// FoqosWidgetLiveActivity.swift
// FoqosWidget
//
// Created by Ali Waseem on 2025-03-11.
//

import ActivityKit
import WidgetKit
import SwiftUI

struct FoqosWidgetAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
// Dynamic stateful properties about your activity go here!
var elapsedTime: TimeInterval
}

// Fixed non-changing properties about your activity go here!
var name: String
var message: String
}

struct FoqosWidgetLiveActivity: Widget {
private func formatElapsedTime(_ timeInterval: TimeInterval) -> String {
let hours = Int(timeInterval) / 3600
let minutes = (Int(timeInterval) % 3600) / 60
let seconds = Int(timeInterval) % 60

if hours > 0 {
return String(format: "%d:%02d:%02d", hours, minutes, seconds)
} else {
return String(format: "%d:%02d", minutes, seconds)
}
}

private func formatElapsedTimeShort(_ timeInterval: TimeInterval) -> String {
let hours = Int(timeInterval) / 3600
let minutes = (Int(timeInterval) % 3600) / 60

if hours > 0 {
return String(format: "%dh%02dm", hours, minutes)
} else {
return String(format: "%dm", minutes)
}
}

var body: some WidgetConfiguration {
ActivityConfiguration(for: FoqosWidgetAttributes.self) { context in
// Lock screen/banner UI goes here
HStack(alignment: .center) {
// Left side - App info
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 4) {
Text("Foqos")
.font(.headline)
.fontWeight(.bold)
.foregroundColor(.primary)
Image(systemName: "hourglass")
.foregroundColor(.purple)
}

Text(context.attributes.name)
.font(.subheadline)
.foregroundColor(.primary)

Text(context.attributes.message)
.font(.caption)
.foregroundColor(.secondary)
}

Spacer()

// Right side - Timer
Text(formatElapsedTime(context.state.elapsedTime))
.font(.title)
.fontWeight(.semibold)
.foregroundColor(.secondary)
}
.padding()

} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.center) {
VStack(spacing: 4) {
Image(systemName: "hourglass")
.foregroundColor(.purple)

Text(context.attributes.name)
.font(.headline)
.fontWeight(.medium)

Text(context.attributes.message)
.font(.headline)
.foregroundColor(.secondary)

Text(formatElapsedTime(context.state.elapsedTime))
.font(.body)
.fontWeight(.semibold)
}
}
} compactLeading: {
// Compact leading state
Image(systemName: "hourglass")
.foregroundColor(.purple)
} compactTrailing: {
// Compact trailing state
Text(formatElapsedTimeShort(context.state.elapsedTime))
.font(.caption)
.fontWeight(.semibold)
} minimal: {
// Minimal state
Image(systemName: "hourglass")
.foregroundColor(.purple)
}
.widgetURL(URL(string: "http://www.foqos.app"))
.keylineTint(Color.purple)
}
}
}

extension FoqosWidgetAttributes {
fileprivate static var preview: FoqosWidgetAttributes {
FoqosWidgetAttributes(name: "Focus Session", message: "Stay focused and avoid distractions")
}
}

extension FoqosWidgetAttributes.ContentState {
fileprivate static var shortTime: FoqosWidgetAttributes.ContentState {
FoqosWidgetAttributes.ContentState(elapsedTime: 60)
}

fileprivate static var longTime: FoqosWidgetAttributes.ContentState {
FoqosWidgetAttributes.ContentState(elapsedTime: 300)
}
}

#Preview("Notification", as: .content, using: FoqosWidgetAttributes.preview) {
FoqosWidgetLiveActivity()
} contentStates: {
FoqosWidgetAttributes.ContentState.shortTime
FoqosWidgetAttributes.ContentState.longTime
}
11 changes: 11 additions & 0 deletions FoqosWidget/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widgetkit-extension</string>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions FoqosWidgetExtension.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.dev.ambitionsoftware.foqos</string>
</array>
</dict>
</plist>
Loading