mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-06-13 09:35:28 +08:00
add watch extension template
This commit is contained in:
17
lib/motion/project/template/ios-watch-extension/files/.gitignore
vendored
Normal file
17
lib/motion/project/template/ios-watch-extension/files/.gitignore
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
.repl_history
|
||||
build
|
||||
tags
|
||||
app/pixate_code.rb
|
||||
resources/*.nib
|
||||
resources/*.momd
|
||||
resources/*.storyboardc
|
||||
.DS_Store
|
||||
nbproject
|
||||
.redcar
|
||||
#*#
|
||||
*~
|
||||
*.sw[po]
|
||||
.eprj
|
||||
.sass-cache
|
||||
.idea
|
||||
.dat*.*
|
||||
@@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
# Add your dependencies here:
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
$:.unshift("/Library/RubyMotion/lib")
|
||||
require 'motion/project/template/ios-extension'
|
||||
|
||||
begin
|
||||
require 'bundler'
|
||||
Bundler.require
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
Motion::Project::App.setup do |app|
|
||||
# Use `rake config' to see complete project settings.
|
||||
app.name = '<%= name %>'
|
||||
app.frameworks << "WatchKit"
|
||||
app.info_plist['NSExtension'] = {
|
||||
'NSExtensionPointIdentifier' => 'com.apple.watchkit'
|
||||
}
|
||||
app.info_plist['RemoteInterfacePrincipalClass'] = 'InterfaceController'
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
class GlanceController < WKInterfaceController
|
||||
|
||||
def initWithContext(context)
|
||||
super
|
||||
|
||||
# Initialize variables here.
|
||||
# Configure interface objects here.
|
||||
NSLog("%@ initWithContext", self)
|
||||
|
||||
return self;
|
||||
end
|
||||
|
||||
def willActivate
|
||||
# This method is called when watch view controller is about to be visible to user
|
||||
NSLog("%@ will activate", self)
|
||||
end
|
||||
|
||||
def didDeactivate
|
||||
# This method is called when watch view controller is no longer visible
|
||||
NSLog("%@ did deactivate", self)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
class InterfaceController < WKInterfaceController
|
||||
|
||||
def initWithContext(context)
|
||||
super
|
||||
|
||||
# Initialize variables here.
|
||||
# Configure interface objects here.
|
||||
NSLog("%@ initWithContext", self)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
def willActivate
|
||||
# This method is called when watch view controller is about to be visible to user
|
||||
NSLog("%@ will activate", self)
|
||||
end
|
||||
|
||||
def didDeactivate
|
||||
# This method is called when watch view controller is no longer visible
|
||||
NSLog("%@ did deactivate", self)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
class NotificationController < WKUserNotificationInterfaceController
|
||||
|
||||
def init
|
||||
super
|
||||
|
||||
NSLog("%@ init", self)
|
||||
|
||||
return self;
|
||||
end
|
||||
|
||||
def willActivate
|
||||
# This method is called when watch view controller is about to be visible to user
|
||||
NSLog("%@ will activate", self)
|
||||
end
|
||||
|
||||
def didDeactivate
|
||||
# This method is called when watch view controller is no longer visible
|
||||
NSLog("%@ did deactivate", self)
|
||||
end
|
||||
|
||||
def didReceiveLocalNotification(localNotification, withCompletion:completionHandler)
|
||||
# This method is called when a local notification needs to be presented.
|
||||
# Implement it if you use a dynamic notification interface.
|
||||
# Populate your dynamic notification inteface as quickly as possible.
|
||||
|
||||
# After populating your dynamic notification interface call the completion block.
|
||||
completionHandler(WKUserNotificationInterfaceTypeCustom)
|
||||
end
|
||||
|
||||
def didReceiveRemoteNotification(remoteNotification, withCompletion:completionHandler)
|
||||
# This method is called when a remote notification needs to be presented.
|
||||
# Implement it if you use a dynamic notification interface.
|
||||
# Populate your dynamic notification inteface as quickly as possible.
|
||||
|
||||
# After populating your dynamic notification interface call the completion block.
|
||||
completionHandler(WKUserNotificationInterfaceTypeCustom)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user