Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Added App Extension Support
Browse files Browse the repository at this point in the history
  • Loading branch information
vicc committed Sep 17, 2016
1 parent 95bbe46 commit 6ed7a41
Show file tree
Hide file tree
Showing 24 changed files with 690 additions and 373 deletions.
Binary file added .DS_Store
Binary file not shown.
290 changes: 286 additions & 4 deletions Chameleon.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
23 changes: 12 additions & 11 deletions Chameleon/Chameleon.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ FOUNDATION_EXPORT const unsigned char ChameleonVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <Chameleon/PublicHeader.h>

#import "Chameleon_.h"
#import <Chameleon/Chameleon_.h>

#import "UIButton+Chameleon.h"
#import "UILabel+Chameleon.h"
#import "UIColor+ChameleonPrivate.h"
#import "UIImage+ChameleonPrivate.h"
#import "UIView+ChameleonPrivate.h"
#import "UIAppearance+Swift.h"
#import <Chameleon/UIButton+Chameleon.h>
#import <Chameleon/UILabel+Chameleon.h>
#import <Chameleon/UIColor+ChameleonPrivate.h>
#import <Chameleon/UIImage+ChameleonPrivate.h>
#import <Chameleon/UIView+ChameleonPrivate.h>
#import <Chameleon/UIAppearance+Swift.h>

#import "NSArray+Chameleon.h"
#import "UIColor+Chameleon.h"
#import "UINavigationController+Chameleon.h"
#import "UIViewController+Chameleon.h"
#import <Chameleon/NSArray+Chameleon.h>
#import <Chameleon/UIColor+Chameleon.h>
#import <Chameleon/UINavigationController+Chameleon.h>
#import <Chameleon/UIViewController+Chameleon.h>
#import <Chameleon/UIApplication+CHSharedApplication.h>
2 changes: 1 addition & 1 deletion Chameleon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.6</string>
<string>2.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ChameleonDemo-ObjC/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.6</string>
<string>2.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
18 changes: 9 additions & 9 deletions ChameleonDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Chameleon.setGlobalThemeUsingPrimaryColor(FlatMint(),
withSecondaryColor: FlatBlue(),
andContentStyle: UIContentStyle.Contrast)
Chameleon.setGlobalThemeUsingPrimaryColor(.flatMint(),
withSecondaryColor: .flatBlue(),
andContentStyle: UIContentStyle.contrast)

return true
}

func applicationWillResignActive(application: UIApplication) {
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 throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
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) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
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) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
2 changes: 1 addition & 1 deletion ChameleonDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.6</string>
<string>2.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ChameleonDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class ViewController: UIViewController {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

view.backgroundColor = FlatYellow()
view.backgroundColor = .flatYellow()
}
}
42 changes: 42 additions & 0 deletions ChameleonExtension-ObjC/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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>CFBundleDisplayName</key>
<string>ChameleonExtension-ObjC</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>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>2.2.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IsASCIICapable</key>
<false/>
<key>PrefersRightToLeft</key>
<false/>
<key>PrimaryLanguage</key>
<string>en-US</string>
<key>RequestsOpenAccess</key>
<false/>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.keyboard-service</string>
<key>NSExtensionPrincipalClass</key>
<string>KeyboardViewController</string>
</dict>
</dict>
</plist>
14 changes: 14 additions & 0 deletions ChameleonExtension-ObjC/KeyboardViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// KeyboardViewController.h
// ChameleonExtension-ObjC
//
// Created by Vicc Alexander on 9/17/16.
// Copyright © 2016 Vicc Alexander. All rights reserved.
//

#import <UIKit/UIKit.h>
@import Chameleon;

@interface KeyboardViewController : UIInputViewController

@end
65 changes: 65 additions & 0 deletions ChameleonExtension-ObjC/KeyboardViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// KeyboardViewController.m
// ChameleonExtension-ObjC
//
// Created by Vicc Alexander on 9/17/16.
// Copyright © 2016 Vicc Alexander. All rights reserved.
//

#import "KeyboardViewController.h"

@interface KeyboardViewController ()
@property (nonatomic, strong) UIButton *nextKeyboardButton;
@end

@implementation KeyboardViewController

- (void)updateViewConstraints {
[super updateViewConstraints];

// Add custom view sizing constraints here
}

- (void)viewDidLoad {
[super viewDidLoad];

// Perform custom UI setup here
self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];

[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
[self.nextKeyboardButton sizeToFit];
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;

[self.nextKeyboardButton addTarget:self action:@selector(handleInputModeListFromView:withEvent:) forControlEvents:UIControlEventAllTouchEvents];

[self.view addSubview:self.nextKeyboardButton];

[self.nextKeyboardButton.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
[self.nextKeyboardButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;

//Set Background Color
self.inputView.backgroundColor = FlatRed;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated
}

- (void)textWillChange:(id<UITextInput>)textInput {
// The app is about to change the document's contents. Perform any preparation here.
}

- (void)textDidChange:(id<UITextInput>)textInput {
// The app has just changed the document's contents, the document context has been updated.

UIColor *textColor = nil;
if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) {
textColor = [UIColor whiteColor];
} else {
textColor = [UIColor blackColor];
}
[self.nextKeyboardButton setTitleColor:textColor forState:UIControlStateNormal];
}

@end
42 changes: 42 additions & 0 deletions ChameleonExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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>CFBundleDisplayName</key>
<string>ChameleonExtension</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>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IsASCIICapable</key>
<false/>
<key>PrefersRightToLeft</key>
<false/>
<key>PrimaryLanguage</key>
<string>en-US</string>
<key>RequestsOpenAccess</key>
<false/>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.keyboard-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).KeyboardViewController</string>
</dict>
</dict>
</plist>
64 changes: 64 additions & 0 deletions ChameleonExtension/KeyboardViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// KeyboardViewController.swift
// ChameleonExtension
//
// Created by Vicc Alexander on 9/17/16.
// Copyright © 2016 Vicc Alexander. All rights reserved.
//

import UIKit
import Chameleon

class KeyboardViewController: UIInputViewController {

@IBOutlet var nextKeyboardButton: UIButton!

override func updateViewConstraints() {
super.updateViewConstraints()

// Add custom view sizing constraints here
}

override func viewDidLoad() {
super.viewDidLoad()

// Perform custom UI setup here
self.nextKeyboardButton = UIButton(type: .system)

self.nextKeyboardButton.setTitle(NSLocalizedString("Next Keyboard", comment: "Title for 'Next Keyboard' button"), for: [])
self.nextKeyboardButton.sizeToFit()
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = false

self.nextKeyboardButton.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)

self.view.addSubview(self.nextKeyboardButton)

self.nextKeyboardButton.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
self.nextKeyboardButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true

inputView?.backgroundColor = .flatGreen()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated
}

override func textWillChange(_ textInput: UITextInput?) {
// The app is about to change the document's contents. Perform any preparation here.
}

override func textDidChange(_ textInput: UITextInput?) {
// The app has just changed the document's contents, the document context has been updated.

var textColor: UIColor
let proxy = self.textDocumentProxy
if proxy.keyboardAppearance == UIKeyboardAppearance.dark {
textColor = UIColor.white
} else {
textColor = UIColor.black
}
self.nextKeyboardButton.setTitleColor(textColor, for: [])
}

}
2 changes: 1 addition & 1 deletion ChameleonFramework.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ChameleonFramework"
s.version = "2.1.0"
s.version = "2.2.0"
s.summary = "Color Framework for iOS (Obj-C & Swift)"
s.homepage = "https://github.com/ViccAlexander/Chameleon"
s.screenshots = "https://camo.githubusercontent.com/bde5aa6ee0e1feec044d184a735da8024c60c04c/687474703a2f2f692e696d6775722e636f6d2f427771486842342e706e67"
Expand Down
Binary file added Pod/.DS_Store
Binary file not shown.
Binary file added Pod/Classes/.DS_Store
Binary file not shown.
Loading

0 comments on commit 6ed7a41

Please sign in to comment.