first commit

This commit is contained in:
Bob Sun 2017-01-19 21:15:47 +08:00
commit 8e997cc868
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
16 changed files with 1270 additions and 0 deletions

66
.gitignore vendored Normal file
View file

@ -0,0 +1,66 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## 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/
.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
Cartfile.resolved
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://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

2
Cartfile Normal file
View file

@ -0,0 +1,2 @@
github "SwiftGit2/SwiftGit2"
github "SVProgressHUD/SVProgressHUD"

View file

@ -0,0 +1,389 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
DC3DC8391E2F63240062A988 /* PasswordDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */; };
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BD61E2E8231000FDF54 /* AppDelegate.swift */; };
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDA1E2E8231000FDF54 /* Main.storyboard */; };
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDD1E2E8231000FDF54 /* Assets.xcassets */; };
DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */; };
DC917BEF1E2F38C5000FDF54 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC917BEE1E2F38C5000FDF54 /* Result.framework */; };
DC917BF11E2F38C9000FDF54 /* SwiftGit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */; };
DC917BF31E2F3B42000FDF54 /* PasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BF21E2F3B42000FDF54 /* PasswordTableViewController.swift */; };
DC9C451C1E2F8CA7005845CA /* ChangeGitRepositoryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9C451B1E2F8CA7005845CA /* ChangeGitRepositoryTableViewController.swift */; };
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */; };
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */; };
DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */; };
DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailViewController.swift; sourceTree = "<group>"; };
DC917BD31E2E8231000FDF54 /* pass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = pass.app; sourceTree = BUILT_PRODUCTS_DIR; };
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DC917BDB1E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
DC917BDD1E2E8231000FDF54 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
DC917BE01E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
DC917BE21E2E8231000FDF54 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DC917BEE1E2F38C5000FDF54 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = "<group>"; };
DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftGit2.framework; path = Carthage/Build/iOS/SwiftGit2.framework; sourceTree = "<group>"; };
DC917BF21E2F3B42000FDF54 /* PasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordTableViewController.swift; sourceTree = "<group>"; };
DC9C451B1E2F8CA7005845CA /* ChangeGitRepositoryTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChangeGitRepositoryTableViewController.swift; sourceTree = "<group>"; };
DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsTableViewController.swift; sourceTree = "<group>"; };
DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordStore.swift; sourceTree = "<group>"; };
DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SVProgressHUD.framework; path = Carthage/Build/iOS/SVProgressHUD.framework; sourceTree = "<group>"; };
DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = pass.xcdatamodel; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
DC917BD01E2E8231000FDF54 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DC917BEF1E2F38C5000FDF54 /* Result.framework in Frameworks */,
DC917BF11E2F38C9000FDF54 /* SwiftGit2.framework in Frameworks */,
DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
DC917BCA1E2E8231000FDF54 = {
isa = PBXGroup;
children = (
DC917BD51E2E8231000FDF54 /* pass */,
DC917BD41E2E8231000FDF54 /* Products */,
DC917BED1E2F38C4000FDF54 /* Frameworks */,
);
sourceTree = "<group>";
};
DC917BD41E2E8231000FDF54 /* Products */ = {
isa = PBXGroup;
children = (
DC917BD31E2E8231000FDF54 /* pass.app */,
);
name = Products;
sourceTree = "<group>";
};
DC917BD51E2E8231000FDF54 /* pass */ = {
isa = PBXGroup;
children = (
DC917BF21E2F3B42000FDF54 /* PasswordTableViewController.swift */,
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */,
DC917BDA1E2E8231000FDF54 /* Main.storyboard */,
DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */,
DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */,
DC9C451B1E2F8CA7005845CA /* ChangeGitRepositoryTableViewController.swift */,
DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */,
DC917BDD1E2E8231000FDF54 /* Assets.xcassets */,
DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */,
DC917BE21E2E8231000FDF54 /* Info.plist */,
DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */,
);
path = pass;
sourceTree = "<group>";
};
DC917BED1E2F38C4000FDF54 /* Frameworks */ = {
isa = PBXGroup;
children = (
DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */,
DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */,
DC917BEE1E2F38C5000FDF54 /* Result.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
DC917BD21E2E8231000FDF54 /* pass */ = {
isa = PBXNativeTarget;
buildConfigurationList = DC917BE51E2E8231000FDF54 /* Build configuration list for PBXNativeTarget "pass" */;
buildPhases = (
DC917BCF1E2E8231000FDF54 /* Sources */,
DC917BD01E2E8231000FDF54 /* Frameworks */,
DC917BD11E2E8231000FDF54 /* Resources */,
DC917BEC1E2F3659000FDF54 /* ShellScript */,
);
buildRules = (
);
dependencies = (
);
name = pass;
productName = pass;
productReference = DC917BD31E2E8231000FDF54 /* pass.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
DC917BCB1E2E8231000FDF54 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Bob Sun";
TargetAttributes = {
DC917BD21E2E8231000FDF54 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 779BQYPRCF;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = DC917BCE1E2E8231000FDF54 /* Build configuration list for PBXProject "pass" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = DC917BCA1E2E8231000FDF54;
productRefGroup = DC917BD41E2E8231000FDF54 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
DC917BD21E2E8231000FDF54 /* pass */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
DC917BD11E2E8231000FDF54 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */,
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */,
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
DC917BEC1E2F3659000FDF54 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
"$(SRCROOT)/Carthage/Build/iOS/SwiftGit2.framework",
"$(SRCROOT)/Carthage/Build/iOS/Result.framework",
"$(SRCROOT)/Carthage/Build/iOS/SVProgressHUD.framework",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/local/bin/carthage copy-frameworks";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
DC917BCF1E2E8231000FDF54 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DC917BF31E2F3B42000FDF54 /* PasswordTableViewController.swift in Sources */,
DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */,
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */,
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */,
DC3DC8391E2F63240062A988 /* PasswordDetailViewController.swift in Sources */,
DC9C451C1E2F8CA7005845CA /* ChangeGitRepositoryTableViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
DC917BDA1E2E8231000FDF54 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
DC917BDB1E2E8231000FDF54 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
DC917BE01E2E8231000FDF54 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
DC917BE31E2E8231000FDF54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
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 = 10.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
DC917BE41E2E8231000FDF54 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
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 = 10.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
DC917BE61E2E8231000FDF54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 779BQYPRCF;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = pass/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.mssun.pass;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
DC917BE71E2E8231000FDF54 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 779BQYPRCF;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = pass/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.mssun.pass;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
DC917BCE1E2E8231000FDF54 /* Build configuration list for PBXProject "pass" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DC917BE31E2E8231000FDF54 /* Debug */,
DC917BE41E2E8231000FDF54 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DC917BE51E2E8231000FDF54 /* Build configuration list for PBXNativeTarget "pass" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DC917BE61E2E8231000FDF54 /* Debug */,
DC917BE71E2E8231000FDF54 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */,
);
currentVersion = DCC408C91E30BA1300F29B0E /* pass.xcdatamodel */;
path = pass.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = DC917BCB1E2E8231000FDF54 /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:pass.xcodeproj">
</FileRef>
</Workspace>

93
pass/AppDelegate.swift Normal file
View file

@ -0,0 +1,93 @@
//
// AppDelegate.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "pass")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
// MARK: - Core Data Saving support
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}

View file

@ -0,0 +1,48 @@
{
"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"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<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">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<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" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</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>

View file

@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="YoR-iB-XAd">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--All-->
<scene sceneID="2hn-YS-T8K">
<objects>
<tableViewController id="vGH-8E-Zez" customClass="PasswordTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Cow-I6-Nig">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="passwordTableViewCell" textLabel="E7G-EA-HbK" style="IBUITableViewCellStyleDefault" id="kff-Zw-ti1">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kff-Zw-ti1" id="x1h-9k-B9w">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="E7G-EA-HbK">
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="Jts-IV-D1A" kind="show" id="i0a-rZ-Bqd"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="vGH-8E-Zez" id="WBi-YU-wSW"/>
<outlet property="delegate" destination="vGH-8E-Zez" id="EG1-wX-VRt"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="All" id="2I8-8c-JEA"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CHd-Vz-2cA" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2573.5999999999999" y="174.96251874062969"/>
</scene>
<!--Settings-->
<scene sceneID="nsc-pJ-wyw">
<objects>
<tableViewController id="YoJ-QG-vxx" customClass="SettingsTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="gtM-Vg-miF">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections>
<tableViewSection id="v5Z-yg-wbs">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Dxt-Zc-V1O" detailTextLabel="b8R-Sr-vDS" style="IBUITableViewCellStyleSubtitle" id="m0U-Ux-y4t">
<rect key="frame" x="0.0" y="35" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="m0U-Ux-y4t" id="stt-IU-aEQ">
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Git Repository" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Dxt-Zc-V1O">
<rect key="frame" x="15" y="5" width="108.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="https://github.com/mssun/public-password-store.git" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="b8R-Sr-vDS">
<rect key="frame" x="15" y="25.5" width="297" height="14.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="SGu-Tc-C19" kind="showDetail" id="lK2-tW-xaM"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="YoJ-QG-vxx" id="1vs-dq-AQt"/>
<outlet property="delegate" destination="YoJ-QG-vxx" id="1cj-Ko-lZe"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Settings" id="Dmx-d6-hjL"/>
<connections>
<outlet property="gitRepositoryTableViewCell" destination="m0U-Ux-y4t" id="CBU-Jj-dK0"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LjA-Ne-PyF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2574" y="913"/>
</scene>
<!--Change Git Repository-->
<scene sceneID="xnx-9L-bCV">
<objects>
<tableViewController id="4cL-li-vzc" customClass="ChangeGitRepositoryTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="9h6-Ga-agw">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections>
<tableViewSection headerTitle="Git Repository" id="6ZR-IS-6HM">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="Uf8-Mp-2hU">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" contentMode="center" tableViewCell="Uf8-Mp-2hU" id="PHY-pV-bc1">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="https://github.com/mssun/public-password-store.git" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="8mS-VD-Cap">
<rect key="frame" x="8" y="-1" width="359" height="44"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="URL" returnKeyType="done"/>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="8mS-VD-Cap" secondAttribute="bottom" id="2et-i1-1ls"/>
<constraint firstItem="8mS-VD-Cap" firstAttribute="centerY" secondItem="PHY-pV-bc1" secondAttribute="centerY" id="a7Z-qH-geK"/>
<constraint firstItem="8mS-VD-Cap" firstAttribute="trailing" secondItem="PHY-pV-bc1" secondAttribute="trailingMargin" id="rlP-fB-6hF"/>
<constraint firstItem="8mS-VD-Cap" firstAttribute="leading" secondItem="PHY-pV-bc1" secondAttribute="leadingMargin" id="uSJ-3n-i28"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="4cL-li-vzc" id="Tgy-pO-pUk"/>
<outlet property="delegate" destination="4cL-li-vzc" id="313-Ji-k69"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Change Git Repository" id="Sk1-FY-8vi">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="VWm-Vs-kHL">
<connections>
<segue destination="sQU-ax-3Ie" kind="unwind" identifier="" unwindAction="cancelWithSegue:" id="q7x-B2-fBi"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="save" id="hfp-fF-TOL">
<connections>
<segue destination="sQU-ax-3Ie" kind="unwind" identifier="save" unwindAction="saveWithSegue:" id="kk2-Dn-WsY"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="gitRepositoryURLTextField" destination="8mS-VD-Cap" id="RUK-V5-ci6"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="PuF-lo-JTb" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="sQU-ax-3Ie" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="4472.8000000000002" y="909.89505247376314"/>
</scene>
<!--Password Detail View Controller-->
<scene sceneID="9b5-fu-vx9">
<objects>
<viewController id="Jts-IV-D1A" customClass="PasswordDetailViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Vhp-eB-nlX"/>
<viewControllerLayoutGuide type="bottom" id="AwD-QU-ZDy"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="aAM-Iy-xPP">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Password: 1234567890" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xry-JW-IEp">
<rect key="frame" x="16" y="72" width="182" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ek1-Cw-dZH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3422" y="175"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="ACd-rk-Zf3">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="5ZN-vm-3gw" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" systemItem="favorites" id="gNg-YT-cGW"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="DUk-ZD-z4m">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vGH-8E-Zez" kind="relationship" relationship="rootViewController" id="Zi5-Xc-g3i"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="25X-hm-lLo" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1634.4000000000001" y="174.96251874062969"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="QAo-AP-q8o">
<objects>
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="YoR-iB-XAd" sceneMemberID="viewController">
<toolbarItems/>
<tabBar key="tabBar" contentMode="scaleToFill" id="5J0-mT-bks">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tabBar>
<connections>
<segue destination="5ZN-vm-3gw" kind="relationship" relationship="viewControllers" id="VZu-vG-Fum"/>
<segue destination="gD9-d9-fB7" kind="relationship" relationship="viewControllers" id="ust-LA-VtZ"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="h18-hY-pkk" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="654" y="565"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="rsO-Qo-dfa">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="gD9-d9-fB7" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" systemItem="more" id="hvf-Rq-ETT"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="BbW-Nu-3Oq">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="YoJ-QG-vxx" kind="relationship" relationship="rootViewController" id="XQj-Ua-n9c"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mEM-ZA-sXv" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1634" y="913"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="1BG-v6-p5d">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="SGu-Tc-C19" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="RX0-TZ-T9b">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="4cL-li-vzc" kind="relationship" relationship="rootViewController" id="KD6-82-zA2"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="s3T-Zx-nmR" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3533.5999999999999" y="909.89505247376314"/>
</scene>
</scenes>
</document>

View file

@ -0,0 +1,42 @@
//
// ChangeGitRepositoryTableViewController.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import CoreData
import SVProgressHUD
class ChangeGitRepositoryTableViewController: UITableViewController {
let userDefaults = UserDefaults.standard
var gitRepositoryURL: String?
@IBOutlet weak var gitRepositoryURLTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
if let url = userDefaults.string(forKey: "gitRepositoryURL") {
gitRepositoryURLTextField.text = url
} else {
gitRepositoryURLTextField.text = "https://github.com/mssun/public-password-store.git"
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
gitRepositoryURLTextField.becomeFirstResponder()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
view.endEditing(true)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "save" {
gitRepositoryURL = gitRepositoryURLTextField.text!
}
}
}

38
pass/Info.plist Normal file
View file

@ -0,0 +1,38 @@
<?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>en</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>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>Main</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,35 @@
//
// PasswordDetailViewController.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class PasswordDetailViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}

93
pass/PasswordStore.swift Normal file
View file

@ -0,0 +1,93 @@
//
// PasswordStore.swift
// pass
//
// Created by Mingshen Sun on 19/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import Foundation
import SwiftGit2
import Result
import CoreData
import UIKit
class PasswordStore {
static let shared = PasswordStore()
let storeURL = URL(fileURLWithPath: "\(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])/password-store")
var storeRepo: Repository?
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
private init() {
let result = Repository.at(storeURL)
if case .success(let r) = result {
storeRepo = r
}
}
func cloneRemoteRepo(remoteRepoURL: URL) -> Bool{
print("start cloning remote repo")
let fm = FileManager.default
if (storeRepo != nil) {
print("remove item")
do {
try fm.removeItem(at: storeURL)
} catch let error as NSError {
print(error.debugDescription)
}
}
let cloneResult = Repository.clone(from: remoteRepoURL, to: storeURL)
switch cloneResult {
case let .success(clonedRepo):
storeRepo = clonedRepo
print("clone repo: \(storeURL) success")
updatePasswordEntityCoreData()
return true
case let .failure(error):
print(error)
return false
}
}
func updatePasswordEntityCoreData() {
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest)
do {
try context.execute(deleteRequest)
} catch let error as NSError {
print(error)
}
let fm = FileManager.default
fm.enumerator(atPath: storeURL.path)?.forEach({ (e) in
if let e = e as? String, let url = URL(string: e) {
if url.pathExtension == "gpg" {
let entity = PasswordEntity(context: context)
entity.name = url.lastPathComponent
entity.rawPath = url.path
}
}
})
do {
try context.save()
} catch {
print("Error with save: \(error)")
}
}
func fetchPasswordEntityCoreData() -> [PasswordEntity] {
let passwordEntityFetch = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
do {
let fetchedPasswordEntities = try context.fetch(passwordEntityFetch) as! [PasswordEntity]
return fetchedPasswordEntities
} catch {
fatalError("Failed to fetch employees: \(error)")
}
}
func updateRemoteRepo() {
}
}

View file

@ -0,0 +1,81 @@
//
// PasswordTableViewController.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import SwiftGit2
import Result
import SVProgressHUD
class PasswordTableViewController: UITableViewController {
private var passwordNameArray = [String]()
private var passwordEntities: [PasswordEntity]?
func temporaryURL(forPurpose purpose: String) -> URL {
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
print("\(NSHomeDirectory())/vault")
return URL(fileURLWithPath: path)
}
override func viewDidLoad() {
super.viewDidLoad()
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
NotificationCenter.default.addObserver(self, selector: #selector(PasswordTableViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
// SVProgressHUD.setDefaultMaskType(SVProgressHUDMaskType.black)
// SVProgressHUD.show(withStatus: "Cloning Password Repository")
//
// let remoteRepoURL = URL(string: "https://github.com/mssun/public-password-store.git")
// let localURL = self.temporaryURL(forPurpose: "public-remote-clone")
// DispatchQueue.global(qos: .userInitiated).async {
// let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL)
// if case .success(let clonedRepo) = cloneResult {
// let latestCommit: Result<Commit, NSError> = clonedRepo
// .HEAD()
// .flatMap { clonedRepo.commit($0.oid) }
// print("localURL \(localURL.path)")
// if let commit = latestCommit.value {
// print("Latest Commit: \(commit.message) by \(commit.author.name)")
// } else {
// print("Could not get commit: \(latestCommit.error)")
// }
// let fd = FileManager.default
// fd.enumerator(atPath: localURL.path)?.forEach({ (e) in
// if let e = e as? String, let url = URL(string: e) {
// if url.pathExtension == "gpg" {
// self.passwordNameArray.append(url.lastPathComponent);
// }
// }
// })
// }
// DispatchQueue.main.async {
// SVProgressHUD.dismiss()
// self.tableView.reloadData()
// }
//
// }
}
func actOnPasswordUpdatedNotification() {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
self.tableView.reloadData()
print("actOnPasswordUpdatedNotification")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return passwordEntities!.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
cell.textLabel?.text = passwordEntities![indexPath.row].name
return cell
}
}

View file

@ -0,0 +1,57 @@
//
// SettingsTableViewController.swift
// pass
//
// Created by Mingshen Sun on 18/1/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import SVProgressHUD
import CoreData
class SettingsTableViewController: UITableViewController {
@IBOutlet weak var gitRepositoryTableViewCell: UITableViewCell!
@IBAction func cancel(segue: UIStoryboardSegue) {
}
@IBAction func save(segue: UIStoryboardSegue) {
if let changeGitRepositoryTableViewController = segue.source as? ChangeGitRepositoryTableViewController {
if let gitRepositoryURL = changeGitRepositoryTableViewController.gitRepositoryURL {
if gitRepositoryTableViewCell.detailTextLabel?.text != gitRepositoryURL {
UserDefaults.standard.set(gitRepositoryURL, forKey: "gitRepositoryURL")
gitRepositoryTableViewCell.detailTextLabel?.text = gitRepositoryURL
}
SVProgressHUD.show(withStatus: "Cloning Remote Repository")
DispatchQueue.global(qos: .userInitiated).async {
let ret = PasswordStore.shared.cloneRemoteRepo(remoteRepoURL: URL(string: gitRepositoryURL)!)
if ret {
DispatchQueue.main.async {
SVProgressHUD.dismiss()
SVProgressHUD.setMaximumDismissTimeInterval(1)
SVProgressHUD.showSuccess(withStatus: "Success")
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
}
} else {
DispatchQueue.main.async {
SVProgressHUD.showError(withStatus: "Error")
}
}
}
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
if let url = UserDefaults.standard.string(forKey: "gitRepositoryURL") {
gitRepositoryTableViewCell.detailTextLabel?.text = url
} else {
gitRepositoryTableViewCell.detailTextLabel?.text = "Not set"
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11759" systemVersion="16C67" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="PasswordEntity" representedClassName="PasswordEntity" syncable="YES" codeGenerationType="class">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="raw" optional="YES" attributeType="Binary" syncable="YES"/>
<attribute name="rawPath" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<elements>
<element name="PasswordEntity" positionX="-63" positionY="-18" width="128" height="90"/>
</elements>
</model>