Commit 8e8117b3 by Dmitriy Stepanets

Added widget extension

parent 4656d2b3
......@@ -27,6 +27,11 @@
CD17C5FF25D15B7C00EE884E /* TodayCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD17C5FE25D15B7C00EE884E /* TodayCoordinator.swift */; };
CD17C60225D15C8500EE884E /* CoordinatorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD17C60125D15C8500EE884E /* CoordinatorProtocol.swift */; };
CD18728B2624763000AFEDAA /* MapLegendView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18728A2624763000AFEDAA /* MapLegendView.swift */; };
CD1B713B2660F95000916E71 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD1B713A2660F95000916E71 /* WidgetKit.framework */; };
CD1B713D2660F95000916E71 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD1B713C2660F95000916E71 /* SwiftUI.framework */; };
CD1B71402660F95000916E71 /* OneWeatherWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1B713F2660F95000916E71 /* OneWeatherWidget.swift */; };
CD1B71422660F95300916E71 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CD1B71412660F95300916E71 /* Assets.xcassets */; };
CD1B71462660F95300916E71 /* OneWeatherWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = CD1B71392660F95000916E71 /* OneWeatherWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
CD1DDD30260218AE00AC62B2 /* DaysControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1DDD2F260218AE00AC62B2 /* DaysControlView.swift */; };
CD1DDD332602305200AC62B2 /* ForecastInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */; };
CD251ED82603633800ED7A65 /* ForecastPrecipitationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */; };
......@@ -209,6 +214,13 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
CD1B71442660F95300916E71 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CD1237B7255D5C5900C98139 /* Project object */;
proxyType = 1;
remoteGlobalIDString = CD1B71382660F95000916E71;
remoteInfo = OneWeatherWidgetExtension;
};
CE849DBA2638C33600DEFFBD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CD1237B7255D5C5900C98139 /* Project object */;
......@@ -242,6 +254,7 @@
dstPath = "";
dstSubfolderSpec = 13;
files = (
CD1B71462660F95300916E71 /* OneWeatherWidgetExtension.appex in Embed App Extensions */,
CE849DBC2638C33600DEFFBD /* OneWeatherNotificationServiceExtension.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
......@@ -279,6 +292,12 @@
CD17C5FE25D15B7C00EE884E /* TodayCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinator.swift; sourceTree = "<group>"; };
CD17C60125D15C8500EE884E /* CoordinatorProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoordinatorProtocol.swift; sourceTree = "<group>"; };
CD18728A2624763000AFEDAA /* MapLegendView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLegendView.swift; sourceTree = "<group>"; };
CD1B71392660F95000916E71 /* OneWeatherWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneWeatherWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
CD1B713A2660F95000916E71 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
CD1B713C2660F95000916E71 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
CD1B713F2660F95000916E71 /* OneWeatherWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneWeatherWidget.swift; sourceTree = "<group>"; };
CD1B71412660F95300916E71 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
CD1B71432660F95300916E71 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CD1DDD2F260218AE00AC62B2 /* DaysControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaysControlView.swift; sourceTree = "<group>"; };
CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastInfoCell.swift; sourceTree = "<group>"; };
CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPrecipitationCell.swift; sourceTree = "<group>"; };
......@@ -479,6 +498,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD1B71362660F95000916E71 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CD1B713D2660F95000916E71 /* SwiftUI.framework in Frameworks */,
CD1B713B2660F95000916E71 /* WidgetKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CE849DB22638C33600DEFFBD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
......@@ -528,6 +556,7 @@
children = (
CD1237C1255D5C5900C98139 /* 1Weather */,
CE849DB62638C33600DEFFBD /* OneWeatherNotificationServiceExtension */,
CD1B713E2660F95000916E71 /* OneWeatherWidget */,
CD1237C0255D5C5900C98139 /* Products */,
5A59BA825D452B7FC9288086 /* Pods */,
DBFD169AA2AA6A3CB5B68BB5 /* Frameworks */,
......@@ -540,6 +569,7 @@
children = (
CD1237BF255D5C5900C98139 /* 1Weather.app */,
CE849DB52638C33600DEFFBD /* OneWeatherNotificationServiceExtension.appex */,
CD1B71392660F95000916E71 /* OneWeatherWidgetExtension.appex */,
);
name = Products;
sourceTree = "<group>";
......@@ -607,6 +637,16 @@
path = Coordinators;
sourceTree = "<group>";
};
CD1B713E2660F95000916E71 /* OneWeatherWidget */ = {
isa = PBXGroup;
children = (
CD1B713F2660F95000916E71 /* OneWeatherWidget.swift */,
CD1B71412660F95300916E71 /* Assets.xcassets */,
CD1B71432660F95300916E71 /* Info.plist */,
);
path = OneWeatherWidget;
sourceTree = "<group>";
};
CD251EDA26036E2F00ED7A65 /* ForecastPrecipitationCell */ = {
isa = PBXGroup;
children = (
......@@ -1263,6 +1303,8 @@
CE14445E2638B6CF008E2162 /* StoreKit.framework */,
6B543196B99BA697763514F6 /* Pods_1Weather.framework */,
871EA87D239E6F89F6F8818E /* Pods_OneWeatherNotificationServiceExtension.framework */,
CD1B713A2660F95000916E71 /* WidgetKit.framework */,
CD1B713C2660F95000916E71 /* SwiftUI.framework */,
);
name = Frameworks;
sourceTree = "<group>";
......@@ -1290,12 +1332,30 @@
);
dependencies = (
CE849DBB2638C33600DEFFBD /* PBXTargetDependency */,
CD1B71452660F95300916E71 /* PBXTargetDependency */,
);
name = 1Weather;
productName = 1Weather;
productReference = CD1237BF255D5C5900C98139 /* 1Weather.app */;
productType = "com.apple.product-type.application";
};
CD1B71382660F95000916E71 /* OneWeatherWidgetExtension */ = {
isa = PBXNativeTarget;
buildConfigurationList = CD1B71492660F95300916E71 /* Build configuration list for PBXNativeTarget "OneWeatherWidgetExtension" */;
buildPhases = (
CD1B71352660F95000916E71 /* Sources */,
CD1B71362660F95000916E71 /* Frameworks */,
CD1B71372660F95000916E71 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = OneWeatherWidgetExtension;
productName = OneWeatherWidgetExtension;
productReference = CD1B71392660F95000916E71 /* OneWeatherWidgetExtension.appex */;
productType = "com.apple.product-type.app-extension";
};
CE849DB42638C33600DEFFBD /* OneWeatherNotificationServiceExtension */ = {
isa = PBXNativeTarget;
buildConfigurationList = CE849DC02638C33600DEFFBD /* Build configuration list for PBXNativeTarget "OneWeatherNotificationServiceExtension" */;
......@@ -1321,12 +1381,15 @@
CD1237B7255D5C5900C98139 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1240;
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1250;
TargetAttributes = {
CD1237BE255D5C5900C98139 = {
CreatedOnToolsVersion = 12.1;
};
CD1B71382660F95000916E71 = {
CreatedOnToolsVersion = 12.5;
};
CE849DB42638C33600DEFFBD = {
CreatedOnToolsVersion = 12.4;
};
......@@ -1347,6 +1410,7 @@
targets = (
CD1237BE255D5C5900C98139 /* 1Weather */,
CE849DB42638C33600DEFFBD /* OneWeatherNotificationServiceExtension */,
CD1B71382660F95000916E71 /* OneWeatherWidgetExtension */,
);
};
/* End PBXProject section */
......@@ -1372,6 +1436,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD1B71372660F95000916E71 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CD1B71422660F95300916E71 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CE849DB32638C33600DEFFBD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
......@@ -1710,6 +1782,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD1B71352660F95000916E71 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CD1B71402660F95000916E71 /* OneWeatherWidget.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CE849DB12638C33600DEFFBD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
......@@ -1721,6 +1801,11 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
CD1B71452660F95300916E71 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CD1B71382660F95000916E71 /* OneWeatherWidgetExtension */;
targetProxy = CD1B71442660F95300916E71 /* PBXContainerItemProxy */;
};
CE849DBB2638C33600DEFFBD /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CE849DB42638C33600DEFFBD /* OneWeatherNotificationServiceExtension */;
......@@ -1920,6 +2005,50 @@
};
name = Release;
};
CD1B71472660F95300916E71 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 24W4XMQ38L;
INFOPLIST_FILE = OneWeatherWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onelouder.oneweather.OneWeatherWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
CD1B71482660F95300916E71 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 24W4XMQ38L;
INFOPLIST_FILE = OneWeatherWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onelouder.oneweather.OneWeatherWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
CE849DBE2638C33600DEFFBD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7082B26061BEBA910124DD8A /* Pods-OneWeatherNotificationServiceExtension.debug.xcconfig */;
......@@ -1987,6 +2116,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CD1B71492660F95300916E71 /* Build configuration list for PBXNativeTarget "OneWeatherWidgetExtension" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CD1B71472660F95300916E71 /* Debug */,
CD1B71482660F95300916E71 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CE849DC02638C33600DEFFBD /* Build configuration list for PBXNativeTarget "OneWeatherNotificationServiceExtension" */ = {
isa = XCConfigurationList;
buildConfigurations = (
......
......@@ -12,7 +12,12 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>49</integer>
<integer>51</integer>
</dict>
<key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>58</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
......
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
<?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>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>OneWeatherWidget</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widgetkit-extension</string>
</dict>
</dict>
</plist>
//
// OneWeatherWidget.swift
// OneWeatherWidget
//
// Created by Dmitry Stepanets on 28.05.2021.
//
import WidgetKit
import SwiftUI
struct Provider: TimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date())
}
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date())
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)
entries.append(entry)
}
let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}
}
struct SimpleEntry: TimelineEntry {
let date: Date
}
struct OneWeatherWidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
Text(entry.date, style: .time)
}
}
@main
struct OneWeatherWidget: Widget {
let kind: String = "OneWeatherWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
OneWeatherWidgetEntryView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
}
}
struct OneWeatherWidget_Previews: PreviewProvider {
static var previews: some View {
OneWeatherWidgetEntryView(entry: SimpleEntry(date: Date()))
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment