mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-28 12:12:03 +01:00
Add examples project
This commit is contained in:
70
Examples/GitHub Search/.gitignore
vendored
Executable file
70
Examples/GitHub Search/.gitignore
vendored
Executable file
@@ -0,0 +1,70 @@
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
.DS_Store
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xccheckout
|
||||
*.xcscmblueprint
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
401
Examples/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/project.pbxproj
Executable file
401
Examples/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/project.pbxproj
Executable file
@@ -0,0 +1,401 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
ED73146222A6F228004F8DA0 /* RepositoryListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED73146122A6F228004F8DA0 /* RepositoryListView.swift */; };
|
||||
EDDADAB122A808D500FEDC01 /* Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADAB022A808D500FEDC01 /* Combine.swift */; };
|
||||
EDDADAB322A809E600FEDC01 /* URLSession.Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADAB222A809E600FEDC01 /* URLSession.Combine.swift */; };
|
||||
EDDADAB522A821CD00FEDC01 /* ItemResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADAB422A821CD00FEDC01 /* ItemResponse.swift */; };
|
||||
EDDADAB722A829A300FEDC01 /* RepositoryAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADAB622A829A300FEDC01 /* RepositoryAPI.swift */; };
|
||||
EDDADAB922A82C0400FEDC01 /* RepositoryListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADAB822A82C0400FEDC01 /* RepositoryListViewModel.swift */; };
|
||||
EDDADABB22A82C2500FEDC01 /* JSONDecoder.Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDADABA22A82C2500FEDC01 /* JSONDecoder.Extension.swift */; };
|
||||
EDDF06A222A6C61C00B23D44 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDF06A122A6C61C00B23D44 /* AppDelegate.swift */; };
|
||||
EDDF06A422A6C61C00B23D44 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDF06A322A6C61C00B23D44 /* SceneDelegate.swift */; };
|
||||
EDDF06A822A6C61D00B23D44 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDDF06A722A6C61D00B23D44 /* Assets.xcassets */; };
|
||||
EDDF06AB22A6C61D00B23D44 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDDF06AA22A6C61D00B23D44 /* Preview Assets.xcassets */; };
|
||||
EDDF06AE22A6C61D00B23D44 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDDF06AC22A6C61D00B23D44 /* LaunchScreen.storyboard */; };
|
||||
EDDF06B722A6CD8300B23D44 /* RepositoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDF06B622A6CD8300B23D44 /* RepositoryView.swift */; };
|
||||
EDDF06BA22A6D78200B23D44 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDF06B922A6D78200B23D44 /* Repository.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
ED73146122A6F228004F8DA0 /* RepositoryListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryListView.swift; sourceTree = "<group>"; };
|
||||
EDDADAB022A808D500FEDC01 /* Combine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Combine.swift; sourceTree = "<group>"; };
|
||||
EDDADAB222A809E600FEDC01 /* URLSession.Combine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSession.Combine.swift; sourceTree = "<group>"; };
|
||||
EDDADAB422A821CD00FEDC01 /* ItemResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemResponse.swift; sourceTree = "<group>"; };
|
||||
EDDADAB622A829A300FEDC01 /* RepositoryAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepositoryAPI.swift; sourceTree = "<group>"; };
|
||||
EDDADAB822A82C0400FEDC01 /* RepositoryListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepositoryListViewModel.swift; sourceTree = "<group>"; };
|
||||
EDDADABA22A82C2500FEDC01 /* JSONDecoder.Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONDecoder.Extension.swift; sourceTree = "<group>"; };
|
||||
EDDF069E22A6C61C00B23D44 /* GitHubSearchWithSwiftUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitHubSearchWithSwiftUI.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EDDF06A122A6C61C00B23D44 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
EDDF06A322A6C61C00B23D44 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
EDDF06A722A6C61D00B23D44 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EDDF06AA22A6C61D00B23D44 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
EDDF06AD22A6C61D00B23D44 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
EDDF06AF22A6C61D00B23D44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
EDDF06B622A6CD8300B23D44 /* RepositoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepositoryView.swift; sourceTree = "<group>"; };
|
||||
EDDF06B922A6D78200B23D44 /* Repository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
EDDF069B22A6C61C00B23D44 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
EDDADAAF22A808C300FEDC01 /* Extension */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDADAB022A808D500FEDC01 /* Combine.swift */,
|
||||
EDDADAB222A809E600FEDC01 /* URLSession.Combine.swift */,
|
||||
EDDADABA22A82C2500FEDC01 /* JSONDecoder.Extension.swift */,
|
||||
);
|
||||
path = Extension;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF069522A6C61C00B23D44 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDF06A022A6C61C00B23D44 /* GitHubSearchWithSwiftUI */,
|
||||
EDDF069F22A6C61C00B23D44 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF069F22A6C61C00B23D44 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDF069E22A6C61C00B23D44 /* GitHubSearchWithSwiftUI.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF06A022A6C61C00B23D44 /* GitHubSearchWithSwiftUI */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDF06A122A6C61C00B23D44 /* AppDelegate.swift */,
|
||||
EDDF06A322A6C61C00B23D44 /* SceneDelegate.swift */,
|
||||
EDDADAAF22A808C300FEDC01 /* Extension */,
|
||||
EDDF06B822A6D77000B23D44 /* Model */,
|
||||
EDDF06B522A6CD6400B23D44 /* View */,
|
||||
EDDF06A722A6C61D00B23D44 /* Assets.xcassets */,
|
||||
EDDF06AC22A6C61D00B23D44 /* LaunchScreen.storyboard */,
|
||||
EDDF06AF22A6C61D00B23D44 /* Info.plist */,
|
||||
EDDF06A922A6C61D00B23D44 /* Preview Content */,
|
||||
);
|
||||
path = GitHubSearchWithSwiftUI;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF06A922A6C61D00B23D44 /* Preview Content */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDF06AA22A6C61D00B23D44 /* Preview Assets.xcassets */,
|
||||
);
|
||||
path = "Preview Content";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF06B522A6CD6400B23D44 /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ED73146122A6F228004F8DA0 /* RepositoryListView.swift */,
|
||||
EDDF06B622A6CD8300B23D44 /* RepositoryView.swift */,
|
||||
EDDADAB822A82C0400FEDC01 /* RepositoryListViewModel.swift */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDDF06B822A6D77000B23D44 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDDF06B922A6D78200B23D44 /* Repository.swift */,
|
||||
EDDADAB422A821CD00FEDC01 /* ItemResponse.swift */,
|
||||
EDDADAB622A829A300FEDC01 /* RepositoryAPI.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
EDDF069D22A6C61C00B23D44 /* GitHubSearchWithSwiftUI */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = EDDF06B222A6C61D00B23D44 /* Build configuration list for PBXNativeTarget "GitHubSearchWithSwiftUI" */;
|
||||
buildPhases = (
|
||||
EDDF069A22A6C61C00B23D44 /* Sources */,
|
||||
EDDF069B22A6C61C00B23D44 /* Frameworks */,
|
||||
EDDF069C22A6C61C00B23D44 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = GitHubSearchWithSwiftUI;
|
||||
productName = GitHubSearchWithSwiftUI;
|
||||
productReference = EDDF069E22A6C61C00B23D44 /* GitHubSearchWithSwiftUI.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
EDDF069622A6C61C00B23D44 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1100;
|
||||
LastUpgradeCheck = 1100;
|
||||
ORGANIZATIONNAME = "jp.marty-suzuki";
|
||||
TargetAttributes = {
|
||||
EDDF069D22A6C61C00B23D44 = {
|
||||
CreatedOnToolsVersion = 11.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = EDDF069922A6C61C00B23D44 /* Build configuration list for PBXProject "GitHubSearchWithSwiftUI" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = EDDF069522A6C61C00B23D44;
|
||||
productRefGroup = EDDF069F22A6C61C00B23D44 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
EDDF069D22A6C61C00B23D44 /* GitHubSearchWithSwiftUI */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
EDDF069C22A6C61C00B23D44 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EDDF06AE22A6C61D00B23D44 /* LaunchScreen.storyboard in Resources */,
|
||||
EDDF06AB22A6C61D00B23D44 /* Preview Assets.xcassets in Resources */,
|
||||
EDDF06A822A6C61D00B23D44 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
EDDF069A22A6C61C00B23D44 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
ED73146222A6F228004F8DA0 /* RepositoryListView.swift in Sources */,
|
||||
EDDADAB722A829A300FEDC01 /* RepositoryAPI.swift in Sources */,
|
||||
EDDF06A222A6C61C00B23D44 /* AppDelegate.swift in Sources */,
|
||||
EDDADAB522A821CD00FEDC01 /* ItemResponse.swift in Sources */,
|
||||
EDDF06A422A6C61C00B23D44 /* SceneDelegate.swift in Sources */,
|
||||
EDDADAB922A82C0400FEDC01 /* RepositoryListViewModel.swift in Sources */,
|
||||
EDDF06BA22A6D78200B23D44 /* Repository.swift in Sources */,
|
||||
EDDF06B722A6CD8300B23D44 /* RepositoryView.swift in Sources */,
|
||||
EDDADAB322A809E600FEDC01 /* URLSession.Combine.swift in Sources */,
|
||||
EDDADABB22A82C2500FEDC01 /* JSONDecoder.Extension.swift in Sources */,
|
||||
EDDADAB122A808D500FEDC01 /* Combine.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
EDDF06AC22A6C61D00B23D44 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
EDDF06AD22A6C61D00B23D44 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
EDDF06B022A6C61D00B23D44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EDDF06B122A6C61D00B23D44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EDDF06B322A6C61D00B23D44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "GitHubSearchWithSwiftUI/Preview\\ Content";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = GitHubSearchWithSwiftUI/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "jp.marty-suzuki.GitHubSearchWithSwiftUI";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EDDF06B422A6C61D00B23D44 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "GitHubSearchWithSwiftUI/Preview\\ Content";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = GitHubSearchWithSwiftUI/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "jp.marty-suzuki.GitHubSearchWithSwiftUI";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
EDDF069922A6C61C00B23D44 /* Build configuration list for PBXProject "GitHubSearchWithSwiftUI" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EDDF06B022A6C61D00B23D44 /* Debug */,
|
||||
EDDF06B122A6C61D00B23D44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
EDDF06B222A6C61D00B23D44 /* Build configuration list for PBXNativeTarget "GitHubSearchWithSwiftUI" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EDDF06B322A6C61D00B23D44 /* Debug */,
|
||||
EDDF06B422A6C61D00B23D44 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = EDDF069622A6C61C00B23D44 /* Project object */;
|
||||
}
|
||||
7
Examples/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Executable file
7
Examples/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Executable file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:GitHubSearchWithSwiftUI.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
41
Examples/GitHub Search/GitHubSearchWithSwiftUI/AppDelegate.swift
Executable file
41
Examples/GitHub Search/GitHubSearchWithSwiftUI/AppDelegate.swift
Executable file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "83.5x83.5",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"size" : "1024x1024",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
41
Examples/GitHub Search/GitHubSearchWithSwiftUI/Extension/Combine.swift
Executable file
41
Examples/GitHub Search/GitHubSearchWithSwiftUI/Extension/Combine.swift
Executable file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Combine.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct CombineExtension<Base> {
|
||||
let base: Base
|
||||
|
||||
init(_ base: Base) {
|
||||
self.base = base
|
||||
}
|
||||
}
|
||||
|
||||
protocol CombineCompatible {
|
||||
associatedtype CombineExtensionBase
|
||||
|
||||
static var combine: CombineExtension<CombineExtensionBase>.Type { get set }
|
||||
var combine: CombineExtension<CombineExtensionBase> { get set }
|
||||
}
|
||||
|
||||
extension CombineCompatible {
|
||||
|
||||
static var combine: CombineExtension<Self>.Type {
|
||||
get {
|
||||
return CombineExtension<Self>.self
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
var combine: CombineExtension<Self> {
|
||||
get {
|
||||
return CombineExtension<Self>(self)
|
||||
}
|
||||
set {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// JSONDecoder.Extension.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/06.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
extension JSONDecoder: TopLevelDecoder {}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// URLSession.Combine.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
extension URLSession: CombineCompatible {}
|
||||
|
||||
extension CombineExtension where Base == URLSession {
|
||||
|
||||
func send(request: URLRequest) -> AnyPublisher<Data, URLSessionError> {
|
||||
|
||||
AnyPublisher<Data, URLSessionError> { [base] subscriber in
|
||||
|
||||
let task = base.dataTask(with: request) { data, response, error in
|
||||
|
||||
guard let response = response as? HTTPURLResponse else {
|
||||
subscriber.receive(completion: .failure(.invalidResponse))
|
||||
return
|
||||
}
|
||||
|
||||
guard 200..<300 ~= response.statusCode else {
|
||||
let e = URLSessionError.serverError(statusCode: response.statusCode,
|
||||
error: error)
|
||||
subscriber.receive(completion: .failure(e))
|
||||
return
|
||||
}
|
||||
|
||||
guard let data = data else {
|
||||
subscriber.receive(completion: .failure(.noData))
|
||||
return
|
||||
}
|
||||
|
||||
if let error = error {
|
||||
subscriber.receive(completion: .failure(.unknown(error)))
|
||||
} else {
|
||||
_ = subscriber.receive(data)
|
||||
subscriber.receive(completion: .finished)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: cancel task when subscriber cancelled
|
||||
task.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum URLSessionError: Error {
|
||||
case invalidResponse
|
||||
case noData
|
||||
case serverError(statusCode: Int, error: Error?)
|
||||
case unknown(Error)
|
||||
}
|
||||
62
Examples/GitHub Search/GitHubSearchWithSwiftUI/Info.plist
Executable file
62
Examples/GitHub Search/GitHubSearchWithSwiftUI/Info.plist
Executable file
@@ -0,0 +1,62 @@
|
||||
<?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>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>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
13
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/ItemResponse.swift
Executable file
13
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/ItemResponse.swift
Executable file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// ItemResponse.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/06.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct ItemResponse<T: Decodable>: Decodable {
|
||||
let items: [T]
|
||||
}
|
||||
17
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/Repository.swift
Executable file
17
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/Repository.swift
Executable file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Repository.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Repository: Decodable {
|
||||
let id: Int
|
||||
let fullName: String
|
||||
let description: String?
|
||||
let stargazersCount: Int
|
||||
let htmlUrl: URL
|
||||
}
|
||||
36
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/RepositoryAPI.swift
Executable file
36
Examples/GitHub Search/GitHubSearchWithSwiftUI/Model/RepositoryAPI.swift
Executable file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// RepositoryModel.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/06.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
enum RepositoryAPI {
|
||||
|
||||
static func search(query: String) -> AnyPublisher<[Repository], Error> {
|
||||
|
||||
guard var components = URLComponents(string: "https://api.github.com/search/repositories") else {
|
||||
return Publishers.Empty<[Repository], Error>().eraseToAnyPublisher()
|
||||
}
|
||||
components.queryItems = [URLQueryItem(name: "q", value: query)]
|
||||
|
||||
guard let url = components.url else {
|
||||
return Publishers.Empty<[Repository], Error>().eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
let decoder = JSONDecoder()
|
||||
decoder.keyDecodingStrategy = .convertFromSnakeCase
|
||||
return URLSession.shared.combine.send(request: request)
|
||||
.decode(type: ItemResponse<Repository>.self, decoder: decoder)
|
||||
.map { $0.items }
|
||||
.handleEvents(receiveOutput: { print($0) },
|
||||
receiveCompletion: { print($0)})
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
61
Examples/GitHub Search/GitHubSearchWithSwiftUI/SceneDelegate.swift
Executable file
61
Examples/GitHub Search/GitHubSearchWithSwiftUI/SceneDelegate.swift
Executable file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// SceneDelegate.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
// Use a UIHostingController as window root view controller
|
||||
let window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window.rootViewController = UIHostingController(rootView:
|
||||
RepositoryListView().environmentObject(RepositoryListViewModel())
|
||||
)
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
37
Examples/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift
Executable file
37
Examples/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift
Executable file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RepositoryListView.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RepositoryListView : View {
|
||||
|
||||
@EnvironmentObject private var viewModel: RepositoryListViewModel
|
||||
@State private var text: String = ""
|
||||
|
||||
var body: some View {
|
||||
|
||||
NavigationView {
|
||||
|
||||
TextField($text,
|
||||
placeholder: Text("Search reposipories..."),
|
||||
onCommit: { self.viewModel.search(query: self.text) })
|
||||
.frame(height: 40)
|
||||
.padding(EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 8))
|
||||
.border(Color.gray, cornerRadius: 8)
|
||||
.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
|
||||
|
||||
List {
|
||||
|
||||
ForEach(viewModel.repositories.identified(by: \.id)) { repository in
|
||||
RepositoryView(repository: repository)
|
||||
}
|
||||
}
|
||||
.navigationBarTitle(Text("Search🔍"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// RepositoryListViewModel.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/06.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
final class RepositoryListViewModel: BindableObject {
|
||||
|
||||
let didChange: AnyPublisher<RepositoryListViewModel, Never>
|
||||
private let _didChange = PassthroughSubject<RepositoryListViewModel, Never>()
|
||||
|
||||
private let _searchWithQuery = PassthroughSubject<String, Never>()
|
||||
private lazy var repositoriesAssign = Subscribers.Assign(object: self, keyPath: \.repositories)
|
||||
|
||||
private(set) var repositories: [Repository] = [] {
|
||||
didSet {
|
||||
// TODO: Do not want to use DispatchQueue.main here
|
||||
DispatchQueue.main.async {
|
||||
self._didChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
repositoriesAssign.cancel()
|
||||
}
|
||||
|
||||
init() {
|
||||
self.didChange = _didChange.eraseToAnyPublisher()
|
||||
|
||||
_searchWithQuery
|
||||
.flatMap { query -> AnyPublisher<[Repository], Never> in
|
||||
RepositoryAPI.search(query: query)
|
||||
.replaceError(with: [])
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
.receive(subscriber: repositoriesAssign)
|
||||
}
|
||||
|
||||
func search(query: String) {
|
||||
_searchWithQuery.send(query)
|
||||
}
|
||||
}
|
||||
36
Examples/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryView.swift
Executable file
36
Examples/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryView.swift
Executable file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// RepositoryView.swift
|
||||
// GitHubSearchWithSwiftUI
|
||||
//
|
||||
// Created by marty-suzuki on 2019/06/05.
|
||||
// Copyright © 2019 jp.marty-suzuki. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RepositoryView : View {
|
||||
|
||||
let repository: Repository
|
||||
|
||||
var body: some View {
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
|
||||
HStack {
|
||||
Image(systemName: "doc.text")
|
||||
Text(repository.fullName)
|
||||
.bold()
|
||||
}
|
||||
|
||||
// Show text if description exists
|
||||
repository.description
|
||||
.map(Text.init)?
|
||||
.lineLimit(nil)
|
||||
|
||||
HStack {
|
||||
Image(systemName: "star")
|
||||
Text("\(repository.stargazersCount)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Examples/GitHub Search/LICENSE
Executable file
21
Examples/GitHub Search/LICENSE
Executable file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Taiki Suzuki
|
||||
|
||||
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.
|
||||
30
Examples/GitHub Search/README.md
Executable file
30
Examples/GitHub Search/README.md
Executable file
@@ -0,0 +1,30 @@
|
||||
# GitHubSearchWithSwiftUI
|
||||
|
||||
GitHubSearchWithSwiftUI is an example that using [SwiftUI <img width="18px" src="https://developer.apple.com/assets/elements/icons/swiftui/swiftui-96x96.png"/>](https://developer.apple.com/xcode/swiftui/)
|
||||
|
||||
<img width="400px" src="https://user-images.githubusercontent.com/2082134/58905672-41539280-8745-11e9-99e3-cb3c3c4991f0.png" />
|
||||
|
||||
## TODO
|
||||
|
||||
- [x] Search with TextField's text
|
||||
- [x] Reflect API responses to List
|
||||
- [X] Separate API access from BindableObject
|
||||
- [X] Use Combine with API access
|
||||
- [ ] Reflect responses in MainThread via Combine
|
||||
|
||||
## Requirements
|
||||
|
||||
- Xcode 11 Beta
|
||||
- Swift 5.1
|
||||
- iOS 13 Beta
|
||||
|
||||
## References
|
||||
|
||||
- https://developer.apple.com/tutorials/swiftui/tutorials
|
||||
- https://developer.apple.com/documentation/swiftui
|
||||
- https://developer.apple.com/documentation/combine
|
||||
- https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/
|
||||
|
||||
## License
|
||||
|
||||
GitHubSearchWithSwiftUI is under MIT license. See the [LICENSE](./LICENSE) file for more info.
|
||||
Reference in New Issue
Block a user