2026-02-28-1
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -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
ios/RideWidget/Assets.xcassets/Contents.json
Normal file
6
ios/RideWidget/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024 1.png
vendored
Normal file
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024 1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024 2.png
vendored
Normal file
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024 2.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024.png
vendored
Normal file
BIN
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/1024.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
23
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/Contents.json
vendored
Normal file
23
ios/RideWidget/Assets.xcassets/IntaleqIcon.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "1024.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "1024 1.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "1024 2.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
11
ios/RideWidget/Info.plist
Normal file
11
ios/RideWidget/Info.plist
Normal file
@@ -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>
|
||||
84
ios/RideWidget/RideWidget.swift
Normal file
84
ios/RideWidget/RideWidget.swift
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// RideWidget.swift
|
||||
// RideWidget
|
||||
//
|
||||
// Created by Hamza Aleghwairyeen on 26/02/2026.
|
||||
//
|
||||
|
||||
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 RideWidgetEntryView : View {
|
||||
var entry: Provider.Entry
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("Time:")
|
||||
Text(entry.date, style: .time)
|
||||
|
||||
Text("Emoji:")
|
||||
Text(entry.emoji)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RideWidget: Widget {
|
||||
let kind: String = "RideWidget"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: Provider()) { entry in
|
||||
if #available(iOS 17.0, *) {
|
||||
RideWidgetEntryView(entry: entry)
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
} else {
|
||||
RideWidgetEntryView(entry: entry)
|
||||
.padding()
|
||||
.background()
|
||||
}
|
||||
}
|
||||
.configurationDisplayName("My Widget")
|
||||
.description("This is an example widget.")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview(as: .systemSmall) {
|
||||
RideWidget()
|
||||
} timeline: {
|
||||
SimpleEntry(date: .now, emoji: "😀")
|
||||
SimpleEntry(date: .now, emoji: "🤩")
|
||||
}
|
||||
20
ios/RideWidget/RideWidgetBundle.swift
Normal file
20
ios/RideWidget/RideWidgetBundle.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// RideWidgetBundle.swift
|
||||
// RideWidget
|
||||
//
|
||||
// Created by Hamza Aleghwairyeen on 26/02/2026.
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct RideWidgetBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
RideWidget() // الويدجت العادية
|
||||
RideWidgetLiveActivity() // ← هذا السطر ضروري وغالبًا ناقص!
|
||||
}
|
||||
}
|
||||
54
ios/RideWidget/RideWidgetControl.swift
Normal file
54
ios/RideWidget/RideWidgetControl.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// RideWidgetControl.swift
|
||||
// RideWidget
|
||||
//
|
||||
// Created by Hamza Aleghwairyeen on 26/02/2026.
|
||||
//
|
||||
|
||||
import AppIntents
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct RideWidgetControl: ControlWidget {
|
||||
var body: some ControlWidgetConfiguration {
|
||||
StaticControlConfiguration(
|
||||
kind: "com.Intaleq.intaleq.RideWidget",
|
||||
provider: Provider()
|
||||
) { value in
|
||||
ControlWidgetToggle(
|
||||
"Start Timer",
|
||||
isOn: value,
|
||||
action: StartTimerIntent()
|
||||
) { isRunning in
|
||||
Label(isRunning ? "On" : "Off", systemImage: "timer")
|
||||
}
|
||||
}
|
||||
.displayName("Timer")
|
||||
.description("A an example control that runs a timer.")
|
||||
}
|
||||
}
|
||||
|
||||
extension RideWidgetControl {
|
||||
struct Provider: ControlValueProvider {
|
||||
var previewValue: Bool {
|
||||
false
|
||||
}
|
||||
|
||||
func currentValue() async throws -> Bool {
|
||||
let isRunning = true // Check if the timer is running
|
||||
return isRunning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct StartTimerIntent: SetValueIntent {
|
||||
static let title: LocalizedStringResource = "Start a timer"
|
||||
|
||||
@Parameter(title: "Timer is running")
|
||||
var value: Bool
|
||||
|
||||
func perform() async throws -> some IntentResult {
|
||||
// Start / stop the timer based on `value`.
|
||||
return .result()
|
||||
}
|
||||
}
|
||||
200
ios/RideWidget/RideWidgetLiveActivity.swift
Normal file
200
ios/RideWidget/RideWidgetLiveActivity.swift
Normal file
@@ -0,0 +1,200 @@
|
||||
import ActivityKit
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
// 1️⃣ Attributes (كما هو مع Plugin: ContentState فارغ والقراءة من AppGroup)
|
||||
struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable {
|
||||
public typealias LiveDeliveryData = ContentState
|
||||
public struct ContentState: Codable, Hashable { }
|
||||
var id = UUID()
|
||||
}
|
||||
|
||||
// 2️⃣ Prefix helper
|
||||
extension LiveActivitiesAppAttributes {
|
||||
func prefixedKey(_ key: String) -> String {
|
||||
return "\(id)_\(key)"
|
||||
}
|
||||
}
|
||||
|
||||
// 3️⃣ Shared App Group
|
||||
let sharedDefault = UserDefaults(suiteName: "group.com.Intaleq.intaleq")!
|
||||
|
||||
@available(iOS 16.1, *)
|
||||
struct RideWidgetLiveActivity: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
ActivityConfiguration(for: LiveActivitiesAppAttributes.self) { context in
|
||||
|
||||
// ===== Read from shared defaults =====
|
||||
let status = sharedDefault.string(forKey: context.attributes.prefixedKey("status")) ?? "waiting"
|
||||
let driverName = sharedDefault.string(forKey: context.attributes.prefixedKey("driverName")) ?? "السائق"
|
||||
let carDetails = sharedDefault.string(forKey: context.attributes.prefixedKey("carDetails")) ?? ""
|
||||
let etaText = sharedDefault.string(forKey: context.attributes.prefixedKey("etaText")) ?? "--"
|
||||
let progressRaw = sharedDefault.double(forKey: context.attributes.prefixedKey("progress"))
|
||||
|
||||
// Clamp progress (0..1)
|
||||
let progress = min(max(progressRaw, 0.0), 1.0)
|
||||
|
||||
// ===== Production Lock Screen UI (White background) =====
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 18)
|
||||
.fill(Color.white)
|
||||
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
// Header
|
||||
HStack(alignment: .center, spacing: 10) {
|
||||
|
||||
// App icon badge (clean)
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.fill(Color.black.opacity(0.04))
|
||||
.frame(width: 38, height: 38)
|
||||
|
||||
Image("IntaleqIcon")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 26, height: 26)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(status == "waiting" ? "السائق في الطريق إليك" : "الرحلة جارية")
|
||||
.font(.headline)
|
||||
.foregroundColor(.black)
|
||||
|
||||
Text("\(driverName) • \(carDetails)")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.gray)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(etaText)
|
||||
.font(.title2)
|
||||
.bold()
|
||||
.foregroundColor(.green)
|
||||
.minimumScaleFactor(0.7)
|
||||
}
|
||||
|
||||
// Progress bar with big car
|
||||
GeometryReader { geometry in
|
||||
let barHeight: CGFloat = 10
|
||||
let carSize: CGFloat = 26
|
||||
let usableWidth = max(0, geometry.size.width - carSize)
|
||||
let x = min(max(0, usableWidth * CGFloat(progress)), usableWidth)
|
||||
|
||||
ZStack(alignment: .leading) {
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(Color.black.opacity(0.08))
|
||||
.frame(height: barHeight)
|
||||
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(Color.green)
|
||||
.frame(width: max(0, geometry.size.width * CGFloat(progress)),
|
||||
height: barHeight)
|
||||
|
||||
// Car marker (bigger + slightly above the bar)
|
||||
Image(systemName: "car.side.fill")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: carSize, height: carSize)
|
||||
.foregroundColor(.black)
|
||||
.background(
|
||||
Circle()
|
||||
.fill(Color.white)
|
||||
.frame(width: carSize + 8, height: carSize + 8)
|
||||
.shadow(color: Color.black.opacity(0.12), radius: 4, x: 0, y: 2)
|
||||
)
|
||||
.offset(x: x, y: -10)
|
||||
}
|
||||
}
|
||||
.frame(height: 34)
|
||||
|
||||
// Footer micro status (optional but production-ish)
|
||||
HStack(spacing: 6) {
|
||||
Circle()
|
||||
.fill(status == "waiting" ? Color.orange : Color.green)
|
||||
.frame(width: 8, height: 8)
|
||||
|
||||
Text(status == "waiting" ? "بانتظار وصول السائق" : "أنت الآن في الرحلة")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 14)
|
||||
}
|
||||
.padding(.horizontal, 8)
|
||||
|
||||
} dynamicIsland: { context in
|
||||
// ===== Read again for dynamic island =====
|
||||
let status = sharedDefault.string(forKey: context.attributes.prefixedKey("status")) ?? "waiting"
|
||||
let driverName = sharedDefault.string(forKey: context.attributes.prefixedKey("driverName")) ?? "السائق"
|
||||
let carDetails = sharedDefault.string(forKey: context.attributes.prefixedKey("carDetails")) ?? ""
|
||||
let etaText = sharedDefault.string(forKey: context.attributes.prefixedKey("etaText")) ?? "--"
|
||||
let progressRaw = sharedDefault.double(forKey: context.attributes.prefixedKey("progress"))
|
||||
let progress = min(max(progressRaw, 0.0), 1.0)
|
||||
|
||||
return DynamicIsland {
|
||||
DynamicIslandExpandedRegion(.leading) {
|
||||
HStack(spacing: 6) {
|
||||
Image("IntaleqIcon")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 20, height: 20)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 5))
|
||||
|
||||
Image(systemName: "car.side.fill")
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
}
|
||||
|
||||
DynamicIslandExpandedRegion(.trailing) {
|
||||
VStack(alignment: .trailing, spacing: 2) {
|
||||
Text(etaText)
|
||||
.font(.headline)
|
||||
.foregroundColor(.green)
|
||||
|
||||
Text(status == "waiting" ? "قادم إليك" : "جاري")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
|
||||
DynamicIslandExpandedRegion(.center) {
|
||||
VStack(spacing: 4) {
|
||||
Text(status == "waiting" ? "السائق في الطريق" : "الرحلة جارية")
|
||||
.font(.subheadline)
|
||||
|
||||
ProgressView(value: progress)
|
||||
.progressViewStyle(.linear)
|
||||
}
|
||||
}
|
||||
|
||||
DynamicIslandExpandedRegion(.bottom) {
|
||||
Text("\(driverName) • \(carDetails)")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
} compactLeading: {
|
||||
Image("IntaleqIcon")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 18, height: 18)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
|
||||
} compactTrailing: {
|
||||
Text(etaText)
|
||||
.font(.caption2)
|
||||
.minimumScaleFactor(0.7)
|
||||
|
||||
} minimal: {
|
||||
Image(systemName: "car.side.fill")
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user