From 8f0523615d7c30dbedb3f0272160557273e89ebc Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Fri, 8 Apr 2022 13:01:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?storyboad=E5=A4=9A=E8=A8=80=E8=AA=9E?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AgileWorks/AgileWorks.xcodeproj/project.pbxproj | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj index a93c4e3..5655f60 100644 --- a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj +++ b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj @@ -262,10 +262,8 @@ 3AF4A84824A06AD0006C0C0A /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 7503F77D27EAF7E00074A76E /* WidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WidgetExtension.entitlements; sourceTree = ""; }; 75917F8F27BD315A0051E201 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = ""; }; - 75917F9027BD315A0051E201 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainInterface.strings"; sourceTree = ""; }; 75917F9227BD315A0051E201 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 75917F9327BD317D0051E201 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/LaunchScreen.strings"; sourceTree = ""; }; - 75917F9427BD317D0051E201 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/MainInterface.strings"; sourceTree = ""; }; 75917F9627BD317E0051E201 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = ""; }; 75917F9B27BDF0F10051E201 /* Japanese.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Japanese.strings; sourceTree = ""; }; 75917F9D27BDF1C30051E201 /* English.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = English.strings; sourceTree = ""; }; @@ -1562,8 +1560,6 @@ isa = PBXVariantGroup; children = ( 3127EE11241A2A9500535CC7 /* Base */, - 75917F9027BD315A0051E201 /* zh-Hans */, - 75917F9427BD317D0051E201 /* zh-Hant */, ); name = MainInterface.storyboard; sourceTree = ""; @@ -1667,7 +1663,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = "4TWZNUHVN6"; + DEVELOPMENT_TEAM = 4TWZNUHVN6; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1747,7 +1743,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = "4TWZNUHVN6"; + DEVELOPMENT_TEAM = 4TWZNUHVN6; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1798,7 +1794,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = "4TWZNUHVN6"; + DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = ShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( -- GitLab From 9395f040b79683595841604a29ed4bad6ed1cd55 Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Wed, 13 Apr 2022 13:54:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Common=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=81=AB=E3=82=A6=E3=82=A3=E3=82=B8=E3=82=A7=E3=83=83=E3=83=88?= =?UTF-8?q?=E5=85=B1=E9=80=9Aview=E3=82=92=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgileWorks.xcodeproj/project.pbxproj | 24 +- AgileWorks/Common/WidgetView.swift | 221 ++++++++++++++++++ .../WidgetExtension/WidgetExtension.swift | 215 +---------------- 3 files changed, 243 insertions(+), 217 deletions(-) create mode 100644 AgileWorks/Common/WidgetView.swift diff --git a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj index a69ee4a..6139c36 100644 --- a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj +++ b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj @@ -49,6 +49,9 @@ 75917FB527C371390051E201 /* StringsUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75917FB227C371390051E201 /* StringsUtility.swift */; }; 75917FB627C372C80051E201 /* XCGLoggerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD8D55D82420609000A667B0 /* XCGLoggerExtensions.swift */; }; 75917FB727C373060051E201 /* UserDefaultsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAB1F6C240D0D0000EA15FD /* UserDefaultsExtensions.swift */; }; + 75EDD2272806618A0068B4BC /* WidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EDD2262806618A0068B4BC /* WidgetView.swift */; }; + 75EDD2282806618A0068B4BC /* WidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EDD2262806618A0068B4BC /* WidgetView.swift */; }; + 75EDD2292806618A0068B4BC /* WidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EDD2262806618A0068B4BC /* WidgetView.swift */; }; 75EF9CAE27E9E983003178A3 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75EF9CAD27E9E983003178A3 /* WidgetKit.framework */; }; 75EF9CB027E9E983003178A3 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75EF9CAF27E9E983003178A3 /* SwiftUI.framework */; }; 75EF9CB327E9E983003178A3 /* WidgetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EF9CB227E9E983003178A3 /* WidgetExtension.swift */; }; @@ -271,6 +274,7 @@ 75917F9F27BDF2050051E201 /* Chinese-Simplified.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = "Chinese-Simplified.strings"; sourceTree = ""; }; 75917FA127BDF2250051E201 /* Chinese-Traditional.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = "Chinese-Traditional.strings"; sourceTree = ""; }; 75917FB227C371390051E201 /* StringsUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringsUtility.swift; sourceTree = ""; }; + 75EDD2262806618A0068B4BC /* WidgetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetView.swift; sourceTree = ""; }; 75EF9CAC27E9E983003178A3 /* WidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 75EF9CAD27E9E983003178A3 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 75EF9CAF27E9E983003178A3 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; @@ -642,6 +646,7 @@ 76CEA0532511A36E0074837A /* WfAction.swift */, 7604950325380980000D6951 /* FirebaseSupport.swift */, C5E5A4C727853BEF00668C7D /* QRCodeReader.swift */, + 75EDD2262806618A0068B4BC /* WidgetView.swift */, ); path = Common; sourceTree = ""; @@ -1401,6 +1406,7 @@ 75917FB427C371390051E201 /* StringsUtility.swift in Sources */, BDA74C52245016AC000D4351 /* XCGLoggerExtensions.swift in Sources */, BD1B50DD244DABF900783FB5 /* OAuthService.swift in Sources */, + 75EDD2282806618A0068B4BC /* WidgetView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1417,6 +1423,7 @@ 75EF9CCC27E9ED3B003178A3 /* ApprovalResponse.swift in Sources */, 75EF9CCB27E9ED28003178A3 /* Configuration.swift in Sources */, 75EF9CCA27E9ED21003178A3 /* APIResult.swift in Sources */, + 75EDD2292806618A0068B4BC /* WidgetView.swift in Sources */, 75EF9CC827E9ED18003178A3 /* UserDefaultsDataStore.swift in Sources */, 75EF9CC927E9ED18003178A3 /* UserDefaultsExtensions.swift in Sources */, 75EF9CC727E9ECF9003178A3 /* APIEndpoint.swift in Sources */, @@ -1479,6 +1486,7 @@ OHC9HIGNQ5ITYM0SNOFLOAKA /* SplashBuilder.swift in Sources */, WOGRE70TXZTZ79X4CG8A8TJA /* SplashUseCase.swift in Sources */, C51EF0E92769FA2E00361B38 /* WebViewScriptMessageHandler.swift in Sources */, + 75EDD2272806618A0068B4BC /* WidgetView.swift in Sources */, 764D0E1B2580ABCB00AB6617 /* URLAuthenticationUtility.swift in Sources */, BD6C1AE824A475430057756F /* DeleteDeviceEndpoint.swift in Sources */, BD6C1AE624A474050057756F /* GetDeviceEndpoint.swift in Sources */, @@ -1617,7 +1625,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = TodayExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1808,7 +1816,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = ShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1833,7 +1841,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = ShareExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1897,7 +1905,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -1917,7 +1925,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = AgileWorks/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2001,7 +2009,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = TodayExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2065,7 +2073,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -2085,7 +2093,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 4TWZNUHVN6; INFOPLIST_FILE = AgileWorks/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/AgileWorks/Common/WidgetView.swift b/AgileWorks/Common/WidgetView.swift new file mode 100644 index 0000000..ca42935 --- /dev/null +++ b/AgileWorks/Common/WidgetView.swift @@ -0,0 +1,221 @@ +// +// WidgetView.swift +// AgileWorks +// +// Created by Azuma Kasumi on 2022/04/13. +// Copyright © 2022 ATLED CORP. All rights reserved. +// + +import SwiftUI + +let draft = "DRAFT" +let requestApplication = "REQUEST_APPLICATION" +let requestApproval = "REQUEST_APPROVAL" +let remand = "REMAND" +let checkReport = "CHECK_REPORT" +let demand = "DEMAND" +let share = "SHARE" +let shared = "SHARED" +let futurePass = "FUTUREPASS" + +//ウィジェット選択のプレビュー画面などで表示させる項目 +func previewItems() -> [ApprovalItem] { + var items = [ApprovalItem]() + items.append(ApprovalItem(code: draft, name: localizadString(key: "Draft", comment: ""), count: 1)) + items.append(ApprovalItem(code: requestApplication, name: localizadString(key: "RequestApplication", comment: ""), count: 10)) + items.append(ApprovalItem(code: requestApproval, name: localizadString(key: "RequestApproval", comment: ""), count: 35)) + items.append(ApprovalItem(code: remand, name: localizadString(key: "Remand", comment: ""), count: 6)) + items.append(ApprovalItem(code: checkReport, name: localizadString(key: "CheckReport", comment: ""), count: 10)) + items.append(ApprovalItem(code: demand, name: localizadString(key: "Demand", comment: ""), count: 0)) + items.append(ApprovalItem(code: share, name: localizadString(key: "Share", comment: ""), count: 0)) + items.append(ApprovalItem(code: shared, name: localizadString(key: "Shared", comment: ""), count: 0)) + items.append(ApprovalItem(code: futurePass, name: localizadString(key: "FuturePass", comment: ""), count: 0)) + + return items +} + +struct EntryData { + var approvalItems: [ApprovalItem] + var message: String? +} + +//状況確認ウィジェット表示選択 +struct StatusCheckWidgetView: View { + var entry: EntryData + var body: some View { + //API取得成功 + if entry.message == nil { + StatusBoxView(entry: entry) + } else { + //APIサーバーエラー + if entry.message == "-" { + StatusBoxView(entry: entry) + } else { //ログイン・コネクションエラー + FailureWidgetView(entry: entry) + } + } + } +} + +//承認待ちウィジェット表示選択 +struct ApprovalWidgetView: View { + var entry: EntryData + + //「承認依頼」を抜き出す + func findApproval() -> Int? { + for (index, item) in entry.approvalItems.enumerated() where item.code == "REQUEST_APPROVAL" { + return index + } + return nil + } + + var body: some View { + //API取得成功 + if entry.message == nil { + if let num = findApproval() { //「承認依頼」項目あり + if #available(iOS 14.0, *) { + ApprovalItemView(approvalItem: entry.approvalItems[num], message: entry.message) + .widgetURL(URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + "RequestApproval")) + } else { + ApprovalItemView(approvalItem: entry.approvalItems[num], message: entry.message) + } + } else { //「承認依頼」項目なし + ApprovalItemView(approvalItem: ApprovalItem(code: "", name: "", count: 0), message: "-") + } + } else { + //APIサーバーエラー + if entry.message == "-" { + ApprovalItemView(approvalItem: ApprovalItem(code: "", name: "", count: 0), message: "-") + } else {//ログイン・コネクションエラー + FailureWidgetView(entry: entry) + } + } + } +} + +//書類状況を表示するための各BOXビュー +struct StatusBoxView: View { + var entry: EntryData + + //書類状態の種類をカウント + func rowCnt() -> Int { + var row = entry.approvalItems.count / 2 + if entry.approvalItems.count % 2 != 0 { + row += 1 + } + return row + } + + //BOXの右側を表示させるかの条件 + func evenCheck(row: Int) -> Bool { + row < rowCnt() - 1 || entry.approvalItems.count % 2 == 0 + } + + var body: some View { + GeometryReader { geometry in + VStack(spacing: 5) { + ForEach(0.. String { + var url: String = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + + switch approvalItem.code { + case draft: + url += "Draft" + case requestApplication: + url += "RequestApplication" + case requestApproval: + url += "RequestApproval" + case remand: + url += "Remand" + case checkReport: + url += "CheckReport" + case demand: + url += "HasDemand" + case share: + url += "Share" + case shared: + url += "Shared" + case futurePass: + url += "FuturePass" + default: + url = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work" + } + return url + } + + var body: some View { + if #available(iOS 14.0, *) { + Link(destination: URL(string: statusUrl())!, label: { + ApprovalItemView(approvalItem: approvalItem, message: message) + }) + } else { + ApprovalItemView(approvalItem: approvalItem, message: message) + } + } +} + +//書類状況の内容を表示するビュー +struct ApprovalItemView: View { + let approvalItem: ApprovalItem + let message: String? + + var body: some View { + GeometryReader { geometry in + HStack(spacing: 0) { + Image(systemName: "folder") + .frame(width: geometry.size.width * 0.3, height: geometry.size.height) + if message == nil { + VStack(alignment: .leading) { + Text(approvalItem.name) + .frame(alignment: .leading) + Text("\(approvalItem.count)").font(.subheadline) + .frame(alignment: .leading) + } + } else { //APIサーバーエラーの場合の表示 + Text(message ?? "-") + } + } + Spacer() + } + .background(Color.white) + .cornerRadius(20) + } +} + +//エラー文言を表示するビュー +struct FailureWidgetView: View { + var entry: EntryData + + var body: some View { + Text(entry.message ?? "") + } +} diff --git a/AgileWorks/WidgetExtension/WidgetExtension.swift b/AgileWorks/WidgetExtension/WidgetExtension.swift index 9168f35..1a904df 100644 --- a/AgileWorks/WidgetExtension/WidgetExtension.swift +++ b/AgileWorks/WidgetExtension/WidgetExtension.swift @@ -9,36 +9,9 @@ import WidgetKit import SwiftUI -let draft = "DRAFT" -let requestApplication = "REQUEST_APPLICATION" -let requestApproval = "REQUEST_APPROVAL" -let remand = "REMAND" -let checkReport = "CHECK_REPORT" -let demand = "DEMAND" -let share = "SHARE" -let shared = "SHARED" -let futurePass = "FUTUREPASS" - - -//ウィジェット選択のプレビュー画面などで表示させる項目 -private func previewItems() -> [ApprovalItem]{ - var items = [ApprovalItem]() - items.append(ApprovalItem(code: draft, name: localizadString(key: "Draft", comment: ""), count: 1)) - items.append(ApprovalItem(code: requestApplication, name: localizadString(key: "RequestApplication", comment: ""), count: 10)) - items.append(ApprovalItem(code: requestApproval, name: localizadString(key: "RequestApproval", comment: ""), count: 35)) - items.append(ApprovalItem(code: remand, name: localizadString(key: "Remand", comment: ""), count: 6)) - items.append(ApprovalItem(code: checkReport, name: localizadString(key: "CheckReport", comment: ""), count: 10)) - items.append(ApprovalItem(code: demand, name: localizadString(key: "Demand", comment: ""), count: 0)) - items.append(ApprovalItem(code: share, name: localizadString(key: "Share", comment: ""), count: 0)) - items.append(ApprovalItem(code: shared, name: localizadString(key: "Shared", comment: ""), count: 0)) - items.append(ApprovalItem(code: futurePass, name: localizadString(key: "FuturePass", comment: ""), count: 0)) - - return items -} - struct Provider: TimelineProvider { func placeholder(in context: Context) -> SimpleEntry { - SimpleEntry(date: Date(), approvalItems:previewItems(), message: nil) + SimpleEntry(date: Date(), approvalItems: previewItems(), message: nil) } func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { @@ -74,183 +47,6 @@ struct SimpleEntry: TimelineEntry { var approvalItems: [ApprovalItem] var message: String? } -//状況確認ウィジェット表示選択 -struct StatusCheckWidgetView : View { - var entry: Provider.Entry - var body: some View { - //API取得成功 - if entry.message == nil { - StatusBoxView(entry: entry) - }else { - //APIサーバーエラー - if entry.message == "-" { - StatusBoxView(entry: entry) - }else { //ログイン・コネクションエラー - FailureWidgetView(entry: entry) - } - } - } -} - -//承認待ちウィジェット表示選択 -struct ApprovalWidgetView : View { - var entry: Provider.Entry - - //「承認依頼」を抜き出す - func findApproval() -> Int?{ - for (index, item) in entry.approvalItems.enumerated() { - if item.code == "REQUEST_APPROVAL" { - return index - } - } - return nil - } - - var body: some View { - //API取得成功 - if entry.message == nil { - if let num = findApproval() { //「承認依頼」項目あり - ApprovalItemView(approvalItem: entry.approvalItems[num], message: entry.message) - .widgetURL(URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + "RequestApproval")) - }else { //「承認依頼」項目なし - ApprovalItemView(approvalItem: ApprovalItem(code: "", name: "", count: 0), message: "-") - } - }else { - //APIサーバーエラー - if entry.message == "-" { - ApprovalItemView(approvalItem: ApprovalItem(code: "", name: "", count: 0), message: "-") - }else {//ログイン・コネクションエラー - FailureWidgetView(entry: entry) - } - } - } -} - -//書類状況を表示するための各BOXビュー -struct StatusBoxView : View { - var entry: Provider.Entry - - //書類状態の種類をカウント - func rowCnt() -> Int { - var row = entry.approvalItems.count / 2 - if (entry.approvalItems.count % 2 != 0) { - row += 1 - } - return row - } - - //BOXの右側を表示させるかの条件 - func evenCheck(row: Int) -> Bool { - row < rowCnt()-1 || entry.approvalItems.count % 2 == 0 - } - - var body: some View { - GeometryReader { geometry in - VStack (spacing: 5){ - ForEach(0.. String{ - var url: String = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" - - switch approvalItem.code { - case draft: - url += "Draft" - case requestApplication: - url += "RequestApplication" - case requestApproval: - url += "RequestApproval" - case remand: - url += "Remand" - case checkReport: - url += "CheckReport" - case demand: - url += "HasDemand" - case share: - url += "Share" - case shared: - url += "Shared" - case futurePass: - url += "FuturePass" - default: - url = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work" - } - return url - } - - var body: some View { - Link(destination: URL(string: statusUrl())!, label: { - ApprovalItemView(approvalItem: approvalItem, message: message) - }) - } -} - -//書類状況の内容を表示するビュー -struct ApprovalItemView : View { - let approvalItem: ApprovalItem - let message: String? - - var body: some View { - GeometryReader { geometry in - HStack (spacing: 0){ - Image(systemName: "folder") - .frame(width: geometry.size.width * 0.3, height: geometry.size.height) - if message == nil { - VStack (alignment : .leading){ - Text(approvalItem.name) - .frame(alignment: .leading) - Text("\(approvalItem.count)").font(.subheadline) - .frame(alignment: .leading) - } - }else { //APIサーバーエラーの場合の表示 - Text(message ?? "-") - } - } - Spacer() - } - .background(Color.white) - .cornerRadius(20) - } -} - - - -//エラー文言を表示するビュー -struct FailureWidgetView : View { - var entry: Provider.Entry - - var body: some View { - Text(entry.message ?? "") - } -} //状況確認ウィジェット struct StatusCheckWidget: Widget { @@ -258,7 +54,8 @@ struct StatusCheckWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in - StatusCheckWidgetView(entry: entry) + + StatusCheckWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message)) } .configurationDisplayName(localizadString(key: "StatusCheckWidgetName", comment: "")) .description(localizadString(key: "StatusCheckWidgetDescription", comment: "")) @@ -272,7 +69,7 @@ struct ApprovalWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in - ApprovalWidgetView(entry: entry) + ApprovalWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message)) } .configurationDisplayName(localizadString(key: "ApprovalWidgetName", comment: "")) .description(localizadString(key: "ApprovalWidgetDescription", comment: "")) @@ -290,9 +87,9 @@ struct WidgetExtension: WidgetBundle { struct WidgetExtension_Previews: PreviewProvider { static var previews: some View { - StatusCheckWidgetView(entry: SimpleEntry(date: Date(), approvalItems: previewItems(), message: nil)) + StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil)) .previewContext(WidgetPreviewContext(family: .systemLarge)) - ApprovalWidgetView(entry: SimpleEntry(date: Date(), approvalItems: previewItems(), message: nil)) + ApprovalWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil)) .previewContext(WidgetPreviewContext(family: .systemSmall)) } } -- GitLab From 09de153485ecbaa7e9f6999d8d5dd7da2bb58608 Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Mon, 18 Apr 2022 17:00:43 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E3=82=B8?= =?UTF-8?q?=E3=83=A3=E3=83=B3=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgileWorks.xcodeproj/project.pbxproj | 12 +- AgileWorks/AgileWorks/App/AppDelegate.swift | 19 +++ .../Wireframe/MainTabBarViewWireframe.swift | 2 +- .../WebView/View/WebViewController.storyboard | 12 +- AgileWorks/Common/WidgetView.swift | 152 +++++++++++++----- AgileWorks/TodayExtension/Info.plist | 6 +- .../View/Base.lproj/MainInterface.storyboard | 69 -------- .../Base.lproj/TodayViewController.storyboard | 29 ++++ .../View/TodayViewController.swift | 77 ++++----- .../WidgetExtension/WidgetExtension.swift | 12 +- 10 files changed, 210 insertions(+), 180 deletions(-) delete mode 100644 AgileWorks/TodayExtension/View/Base.lproj/MainInterface.storyboard create mode 100644 AgileWorks/TodayExtension/View/Base.lproj/TodayViewController.storyboard diff --git a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj index 6139c36..329877a 100644 --- a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj +++ b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 31253D962417A56200525DB6 /* FormWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31253D952417A56200525DB6 /* FormWebViewController.swift */; }; 3127EE0C241A2A9500535CC7 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3127EE0B241A2A9500535CC7 /* NotificationCenter.framework */; }; 3127EE0F241A2A9500535CC7 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3127EE0E241A2A9500535CC7 /* TodayViewController.swift */; }; - 3127EE12241A2A9500535CC7 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3127EE10241A2A9500535CC7 /* MainInterface.storyboard */; }; + 3127EE12241A2A9500535CC7 /* TodayViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3127EE10241A2A9500535CC7 /* TodayViewController.storyboard */; }; 3127EE16241A2A9500535CC7 /* TodayExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 3127EE0A241A2A9500535CC7 /* TodayExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 3127EE1B241A2B4D00535CC7 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3127EE0E241A2A9500535CC7 /* TodayViewController.swift */; }; 31AA002F24347BBD000177B4 /* ApprovalResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31AA002E24347BBD000177B4 /* ApprovalResponse.swift */; }; @@ -252,7 +252,7 @@ 3127EE0A241A2A9500535CC7 /* TodayExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TodayExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 3127EE0B241A2A9500535CC7 /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; 3127EE0E241A2A9500535CC7 /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; }; - 3127EE11241A2A9500535CC7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 3127EE11241A2A9500535CC7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/TodayViewController.storyboard; sourceTree = ""; }; 3127EE13241A2A9500535CC7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31AA002E24347BBD000177B4 /* ApprovalResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovalResponse.swift; sourceTree = ""; }; 31AA003124347C98000177B4 /* SubmissionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmissionResponse.swift; sourceTree = ""; }; @@ -675,7 +675,7 @@ isa = PBXGroup; children = ( 3127EE0E241A2A9500535CC7 /* TodayViewController.swift */, - 3127EE10241A2A9500535CC7 /* MainInterface.storyboard */, + 3127EE10241A2A9500535CC7 /* TodayViewController.storyboard */, ); path = View; sourceTree = ""; @@ -1236,7 +1236,7 @@ 75917FA927C36D220051E201 /* Chinese-Simplified.strings in Resources */, 75917FAA27C36D220051E201 /* Chinese-Traditional.strings in Resources */, 75917FA727C36D0C0051E201 /* Japanese.strings in Resources */, - 3127EE12241A2A9500535CC7 /* MainInterface.storyboard in Resources */, + 3127EE12241A2A9500535CC7 /* TodayViewController.storyboard in Resources */, BD6DE26F24D1079700C1479E /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1576,12 +1576,12 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 3127EE10241A2A9500535CC7 /* MainInterface.storyboard */ = { + 3127EE10241A2A9500535CC7 /* TodayViewController.storyboard */ = { isa = PBXVariantGroup; children = ( 3127EE11241A2A9500535CC7 /* Base */, ); - name = MainInterface.storyboard; + name = TodayViewController.storyboard; sourceTree = ""; }; 3AF4A84724A06A73006C0C0A /* Localizable.strings */ = { diff --git a/AgileWorks/AgileWorks/App/AppDelegate.swift b/AgileWorks/AgileWorks/App/AppDelegate.swift index c0f6a1e..944d7fb 100644 --- a/AgileWorks/AgileWorks/App/AppDelegate.swift +++ b/AgileWorks/AgileWorks/App/AppDelegate.swift @@ -71,9 +71,28 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if let authorizationFlow = OAuthService.currentAuthorizationFlow, authorizationFlow.resumeExternalUserAgentFlow(with: url) { OAuthService.currentAuthorizationFlow = nil } + + //ios13の場合 + var statusUrl = url.absoluteString + let result: URL + /* + if statusUrl.contains("atled-aw:/") { + statusUrl = statusUrl.replacingOccurrences(of:"atled-aw:/", with:"") + result = getStatusURL(status: statusUrl) + print(result) + return Linker.handleDeeplink(url: result) + } + */ return Linker.handleDeeplink(url: url) } + func getStatusURL(status: String) -> URL { + if status == "nil" { + return URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work")! + } + return URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + status)! + } + // Notification受信 func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { if let messageID = userInfo[gcmMessageIDKey] { diff --git a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift index 368a239..adb1fe7 100644 --- a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift +++ b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift @@ -37,7 +37,7 @@ extension MainTabBarViewWireframeImpl: MainTabBarViewWireframe { //viewの読み込み workVC.loadViewIfNeeded() - workVC.widgetLoadWebView(url: url) + workVC.widgetLoadWebView(url: workVC.loadURL) } // 通知から書類表示 func showDocForm(notificationData: NotificationData) { diff --git a/AgileWorks/AgileWorks/WebView/View/WebViewController.storyboard b/AgileWorks/AgileWorks/WebView/View/WebViewController.storyboard index e5376c3..4eeaaaa 100644 --- a/AgileWorks/AgileWorks/WebView/View/WebViewController.storyboard +++ b/AgileWorks/AgileWorks/WebView/View/WebViewController.storyboard @@ -1,9 +1,9 @@ - + - + @@ -190,7 +190,7 @@ - + @@ -213,7 +213,7 @@ - + @@ -236,7 +236,7 @@ - + @@ -259,7 +259,7 @@ - + diff --git a/AgileWorks/Common/WidgetView.swift b/AgileWorks/Common/WidgetView.swift index ca42935..43eec06 100644 --- a/AgileWorks/Common/WidgetView.swift +++ b/AgileWorks/Common/WidgetView.swift @@ -8,6 +8,8 @@ import SwiftUI +let kCellDefaultHight: CGFloat = 110 + let draft = "DRAFT" let requestApplication = "REQUEST_APPLICATION" let requestApproval = "REQUEST_APPROVAL" @@ -37,6 +39,7 @@ func previewItems() -> [ApprovalItem] { struct EntryData { var approvalItems: [ApprovalItem] var message: String? + var viewController: UIViewController? } //状況確認ウィジェット表示選択 @@ -63,7 +66,7 @@ struct ApprovalWidgetView: View { //「承認依頼」を抜き出す func findApproval() -> Int? { - for (index, item) in entry.approvalItems.enumerated() where item.code == "REQUEST_APPROVAL" { + for (index, item) in entry.approvalItems.enumerated() where item.code == requestApproval { return index } return nil @@ -76,8 +79,6 @@ struct ApprovalWidgetView: View { if #available(iOS 14.0, *) { ApprovalItemView(approvalItem: entry.approvalItems[num], message: entry.message) .widgetURL(URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + "RequestApproval")) - } else { - ApprovalItemView(approvalItem: entry.approvalItems[num], message: entry.message) } } else { //「承認依頼」項目なし ApprovalItemView(approvalItem: ApprovalItem(code: "", name: "", count: 0), message: "-") @@ -96,7 +97,7 @@ struct ApprovalWidgetView: View { //書類状況を表示するための各BOXビュー struct StatusBoxView: View { var entry: EntryData - + //書類状態の種類をカウント func rowCnt() -> Int { var row = entry.approvalItems.count / 2 @@ -106,34 +107,83 @@ struct StatusBoxView: View { return row } - //BOXの右側を表示させるかの条件 - func evenCheck(row: Int) -> Bool { - row < rowCnt() - 1 || entry.approvalItems.count % 2 == 0 + //boxのサイズ + func boxSize(viewSize: CGSize) -> CGSize { + var box = CGSize() + var row = 1 + if viewSize.height > kCellDefaultHight { + row = rowCnt() + } + box.width = viewSize.width / 2 * 0.9 + box.height = viewSize.height / CGFloat(row) * 0.9 + return box + } + + func backColor() -> Color { + if #available(iOS 14.0, *) { + return Color(UIColor.systemGray6) + } else { + return Color(UIColor.clear) + } + } + + //「承認依頼」を抜き出す + func findApproval() -> Int? { + for (index, item) in entry.approvalItems.enumerated() where item.code == requestApproval { + return index + } + return nil } var body: some View { GeometryReader { geometry in - VStack(spacing: 5) { - ForEach(0.. kCellDefaultHight { + VStack(spacing: 5) { + ForEach(0.. String { - var url: String = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + //URL末尾につける書類状態の取得status + func getStatus() -> String? { + var status: String? switch approvalItem.code { case draft: - url += "Draft" + status = "Draft" case requestApplication: - url += "RequestApplication" + status = "RequestApplication" case requestApproval: - url += "RequestApproval" + status = "RequestApproval" case remand: - url += "Remand" + status = "Remand" case checkReport: - url += "CheckReport" + status = "CheckReport" case demand: - url += "HasDemand" + status = "HasDemand" case share: - url += "Share" + status = "Share" case shared: - url += "Shared" + status = "Shared" case futurePass: - url += "FuturePass" + status = "FuturePass" default: - url = Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work" + status = nil } - return url + return status } + //遷移先URLの取得(iOS14以降) + func getURL() -> String { + if let status = getStatus() { + return Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + status + } else { + return Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work" + } + } + + //遷移先URLはアプリ側で設定するためURL末尾のステータスのみ設定(iOS13) + func getStatusURL() -> String { + //スキーム+ステータスで設定 + var urlString = "atled-aw://" + if let status = getStatus() { + return urlString + status + } + return urlString + "nil" + } var body: some View { if #available(iOS 14.0, *) { - Link(destination: URL(string: statusUrl())!, label: { + Link(destination: URL(string: getURL())!, label: { ApprovalItemView(approvalItem: approvalItem, message: message) }) } else { ApprovalItemView(approvalItem: approvalItem, message: message) + .onTapGesture { + if viewController != nil { + viewController!.extensionContext?.open(NSURL(fileURLWithPath: getStatusURL())as URL, completionHandler: nil) + } + } } } } diff --git a/AgileWorks/TodayExtension/Info.plist b/AgileWorks/TodayExtension/Info.plist index 8eac502..d5ee216 100644 --- a/AgileWorks/TodayExtension/Info.plist +++ b/AgileWorks/TodayExtension/Info.plist @@ -4,10 +4,10 @@ AppConfig - OAUTH_CLIENTID - $(OAUTH_CLIENTID) AGILE_WORKS_SHARE_BUNDLE_IDENTIFIER $(AGILE_WORKS_SHARE_BUNDLE_IDENTIFIER) + OAUTH_CLIENTID + $(OAUTH_CLIENTID) AppIdentifierPrefix $(AppIdentifierPrefix) @@ -32,7 +32,7 @@ NSExtension NSExtensionMainStoryboard - MainInterface + TodayViewController NSExtensionPointIdentifier com.apple.widget-extension diff --git a/AgileWorks/TodayExtension/View/Base.lproj/MainInterface.storyboard b/AgileWorks/TodayExtension/View/Base.lproj/MainInterface.storyboard deleted file mode 100644 index b948543..0000000 --- a/AgileWorks/TodayExtension/View/Base.lproj/MainInterface.storyboard +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AgileWorks/TodayExtension/View/Base.lproj/TodayViewController.storyboard b/AgileWorks/TodayExtension/View/Base.lproj/TodayViewController.storyboard new file mode 100644 index 0000000..3511d5e --- /dev/null +++ b/AgileWorks/TodayExtension/View/Base.lproj/TodayViewController.storyboard @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AgileWorks/TodayExtension/View/TodayViewController.swift b/AgileWorks/TodayExtension/View/TodayViewController.swift index 45f7914..d9d5c6d 100644 --- a/AgileWorks/TodayExtension/View/TodayViewController.swift +++ b/AgileWorks/TodayExtension/View/TodayViewController.swift @@ -7,16 +7,11 @@ // import NotificationCenter +import SwiftUI import UIKit class TodayViewController: UIViewController, NCWidgetProviding { - @IBOutlet private var tableView: UITableView! - @IBOutlet private var messageLabel: UILabel! - - private static let kCellDefaultHight: CGFloat = 110 - private static let kCompactCellCount: CGFloat = 3 - private static var cellHight: CGFloat = kCellDefaultHight / kCompactCellCount - private static var expandedCellCount: CGFloat = 0 + var approvalItems: [ApprovalItem] = [] enum APIResult { case success(T) @@ -24,12 +19,6 @@ class TodayViewController: UIViewController, NCWidgetProviding { case failure(String) } - var approvalItems: [ApprovalItem] = [] { - didSet { - self.tableView.reloadData() - } - } - override func viewDidLoad() { super.viewDidLoad() self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded @@ -38,66 +27,53 @@ class TodayViewController: UIViewController, NCWidgetProviding { func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) { fetch { result in DispatchQueue.main.async { + var rootView: StatusCheckWidgetView switch result { case .success(let response): - self.hideMessage() self.approvalItems = response.items + rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: self.approvalItems, message: nil, viewController: self)) completionHandler(.newData) case .nodate(let message): - self.showMessage(message: message) - self.approvalItems = [] + rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: [ApprovalItem](), message: message, viewController: nil)) completionHandler(.noData) case .failure(let message): - self.showMessage(message: message) - self.approvalItems = [] + rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: message, viewController: nil)) completionHandler(.failed) } + self.callWidgetView(vc: UIHostingController(rootView: rootView)) } } } + func callWidgetView(vc: UIViewController) { + self.addChild(vc) + self.view.addSubview(vc.view) + vc.didMove(toParent: self) + + vc.view.translatesAutoresizingMaskIntoConstraints = false + vc.view.heightAnchor.constraint(equalTo: self.view.heightAnchor).isActive = true + vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true + vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true + vc.view.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true + vc.view.backgroundColor = UIColor.clear + } + func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) { if case .compact = activeDisplayMode { - TodayViewController.cellHight = maxSize.height / TodayViewController.kCompactCellCount preferredContentSize = maxSize } else { + var height: CGFloat if !approvalItems.isEmpty { - TodayViewController.expandedCellCount = CGFloat(approvalItems.count) + height = 0 } - let hight = TodayViewController.expandedCellCount * TodayViewController.cellHight - preferredContentSize = CGSize(width: maxSize.width, height: min(maxSize.height, hight)) - } - } - - func hideMessage() { - messageLabel.text = "" - messageLabel.isHidden = true - tableView.separatorStyle = .singleLine - } + let hight = Int(kCellDefaultHight) * approvalItems.count / 2 + approvalItems.count % 2 - func showMessage(message: String) { - messageLabel.text = message - messageLabel.isHidden = false - tableView.separatorStyle = .none - } -} - -extension TodayViewController: UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return approvalItems.count - } - - func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "todayCell", for: indexPath) - cell.textLabel?.text = approvalItems[indexPath.row].name + " (" + String(approvalItems[indexPath.row].count.toFormattedString()) + ")" - return cell + preferredContentSize = CGSize(width: maxSize.width, height: min(maxSize.height, CGFloat(hight))) + } } } +/* extension TodayViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return TodayViewController.cellHight @@ -107,6 +83,7 @@ extension TodayViewController: UITableViewDelegate { self.extensionContext?.open(NSURL(fileURLWithPath: "atled-aw://approvals/" + String(indexPath.row) )as URL, completionHandler: nil) } } + */ extension TodayViewController { func fetch(completion: @escaping (APIResult) -> Void) { diff --git a/AgileWorks/WidgetExtension/WidgetExtension.swift b/AgileWorks/WidgetExtension/WidgetExtension.swift index 1a904df..512f30b 100644 --- a/AgileWorks/WidgetExtension/WidgetExtension.swift +++ b/AgileWorks/WidgetExtension/WidgetExtension.swift @@ -31,9 +31,9 @@ struct Provider: TimelineProvider { case .success(let response): entries.append(SimpleEntry(date: entryDate, approvalItems: response.items, message: nil)) case .nodate(let message): - entries.append(SimpleEntry(date: entryDate, approvalItems: [ApprovalItem](), message: message)) - case .failure(let message): entries.append(SimpleEntry(date: entryDate, approvalItems: previewItems(), message: message)) + case .failure(let message): + entries.append(SimpleEntry(date: entryDate, approvalItems: [ApprovalItem](), message: message)) } let timeline = Timeline(entries: entries, policy: .after(entryDate)) completion(timeline) @@ -55,7 +55,7 @@ struct StatusCheckWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in - StatusCheckWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message)) + StatusCheckWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message, viewController: nil)) } .configurationDisplayName(localizadString(key: "StatusCheckWidgetName", comment: "")) .description(localizadString(key: "StatusCheckWidgetDescription", comment: "")) @@ -69,7 +69,7 @@ struct ApprovalWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in - ApprovalWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message)) + ApprovalWidgetView(entry: EntryData(approvalItems: entry.approvalItems, message: entry.message, viewController: nil)) } .configurationDisplayName(localizadString(key: "ApprovalWidgetName", comment: "")) .description(localizadString(key: "ApprovalWidgetDescription", comment: "")) @@ -87,9 +87,9 @@ struct WidgetExtension: WidgetBundle { struct WidgetExtension_Previews: PreviewProvider { static var previews: some View { - StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil)) + StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil, viewController: nil)) .previewContext(WidgetPreviewContext(family: .systemLarge)) - ApprovalWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil)) + ApprovalWidgetView(entry: EntryData(approvalItems: previewItems(), message: nil, viewController: nil)) .previewContext(WidgetPreviewContext(family: .systemSmall)) } } -- GitLab From 211f91344baeb80952aa1698463f5bd5ac3681b3 Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Tue, 19 Apr 2022 12:46:13 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=81=AEURL=E3=81=A7=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AgileWorks/AgileWorks/App/AppDelegate.swift | 2 -- .../AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/AgileWorks/AgileWorks/App/AppDelegate.swift b/AgileWorks/AgileWorks/App/AppDelegate.swift index 944d7fb..448b09f 100644 --- a/AgileWorks/AgileWorks/App/AppDelegate.swift +++ b/AgileWorks/AgileWorks/App/AppDelegate.swift @@ -75,14 +75,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { //ios13の場合 var statusUrl = url.absoluteString let result: URL - /* if statusUrl.contains("atled-aw:/") { statusUrl = statusUrl.replacingOccurrences(of:"atled-aw:/", with:"") result = getStatusURL(status: statusUrl) print(result) return Linker.handleDeeplink(url: result) } - */ return Linker.handleDeeplink(url: url) } diff --git a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift index adb1fe7..368a239 100644 --- a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift +++ b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift @@ -37,7 +37,7 @@ extension MainTabBarViewWireframeImpl: MainTabBarViewWireframe { //viewの読み込み workVC.loadViewIfNeeded() - workVC.widgetLoadWebView(url: workVC.loadURL) + workVC.widgetLoadWebView(url: url) } // 通知から書類表示 func showDocForm(notificationData: NotificationData) { -- GitLab