Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 7199 Option dialog implementation #1360

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ protected void onResume()
@Override
protected void onDestroy()
{
TiApplication.removeFromActivityStack(this);

super.onDestroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,9 @@ protected void onDestroy()
}
}

if (!isTabActivity()) {
boolean isTab = isTabActivity();
//When we close a tabgroup, we don't remove its children from the stack, so here we remove the children if the parent is finishing.
if (!isTab || (isTab && this.getParent().isFinishing())) {
TiApplication.removeFromActivityStack(this);
}

Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/OptionDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Titanium.UI.OptionDialog
summary: The Option Dialog is created by <Titanium.UI.createOptionDialog> and allows you to show a modal dialog of one or more options to the user.
extends: Titanium.Proxy
since: "0.8"
platforms: [android, iphone, ipad]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should perhaps include all platforms explicitly, as before.

methods:
- name: show
summary: cause the dialog to become visible
Expand Down
10 changes: 10 additions & 0 deletions apidoc/Titanium/UI/WebView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ properties:
- name: url
summary: the url to the web document. this property will change as the content of the webview changes (such as from internal hyperlinks, etc)
type: String
- name: willHandleTouches
summary: Explicitly specifies if this webview handles touches.
description: |
On the IOS platform, the webview will intercept `all` touch events if this webview or any of its parent views have touch listeners. This makes interaction with native webview components impossible.
Set this flag to `false` to disable the default behavior. Setting this property to `false` will allow the user to interact with the native webview and still honor any `touch` events sent to its parents.
No `touch` events will be generated when the user interacts with the webview itself.
type: Boolean
platforms: [iphone, ipad]
since: "1.9.0"
default: true
description: |
Creating webviews are more expensive than creating pure native views because of the requirement to
load the HTML browser into memory.
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
id reloadData;
id reloadDataProperties;
SEL reloadMethod;

BOOL willHandleTouches;
}

@property(nonatomic,readonly) id url;
Expand Down
7 changes: 6 additions & 1 deletion iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
*/

UIView *view = [super hitTest:point withEvent:event];
if ([self hasTouchableListener])
if ( ([self hasTouchableListener]) && willHandleTouches )
{
UIView *superview = [view superview];
UIView *superduperview = [superview superview];
Expand All @@ -93,6 +93,11 @@ -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
return view;
}

-(void)setWillHandleTouches_:(id)args
{
willHandleTouches = [TiUtils boolValue:args def:YES];
}


-(UIWebView*)webview
{
Expand Down
5 changes: 3 additions & 2 deletions iphone/Classes/TiUIWebViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ -(BOOL)shouldDetachViewForSpace

-(void)_initWithProperties:(NSDictionary *)properties
{
[self replaceValue:[NSArray arrayWithObject:NUMINT(UIDataDetectorTypePhoneNumber)] forKey:@"autoDetect" notification:NO];
[super _initWithProperties:properties];
[self replaceValue:[NSArray arrayWithObject:NUMINT(UIDataDetectorTypePhoneNumber)] forKey:@"autoDetect" notification:NO];
[self initializeProperty:@"willHandleTouches" defaultValue:NUMBOOL(YES)];
[super _initWithProperties:properties];
}


Expand Down
4 changes: 2 additions & 2 deletions mobileweb/src/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ define("Ti/UI", ["Ti/_/dom", "Ti/_/Evented", "Ti/_/lang", "Ti/_/ready", "Ti/_/st
return new Ti.UI.Label(args);
},

createOptionDialog: function() {
console.debug('Method "Titanium.UI.createOptionDialog" is not implemented yet.');
createOptionDialog: function(args) {
return new Ti.UI.OptionDialog(args);
},

createPicker: function(args) {
Expand Down
3 changes: 3 additions & 0 deletions mobileweb/src/Ti/UI/AlertDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ define("Ti/UI/AlertDialog", ["Ti/_/declare", "Ti/_/Evented"], function(declare,
title: title,
index: index
});
if (index === self.cancel) {
button.domNode.className += " TiUIButtonCancel";
}
alertDialog.add(button);
button.addEventListener("singletap",function(){
alertWindow.close();
Expand Down
127 changes: 127 additions & 0 deletions mobileweb/src/Ti/UI/OptionDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
define("Ti/UI/OptionDialog", ["Ti/_/declare", "Ti/_/Evented"], function(declare, Evented) {

var undef;

return declare("Ti.UI.OptionDialog", Evented, {
show: function() {

// Create the window and a background to dim the current view
var optionsWindow = this._optionsWindow = Ti.UI.createWindow();
var dimmingView = Ti.UI.createView({
backgroundColor: "black",
opacity: 0,
left: 0,
top: 0,
right: 0,
bottom: 0
});
optionsWindow.add(dimmingView);

// Create the options dialog itself
var optionsDialog = Ti.UI.createView({
width: "100%",
height: "auto",
bottom: 0,
backgroundColor: "white",
layout: "vertical",
opacity: 0
});
optionsWindow.add(optionsDialog);

// Add the title
optionsDialog.add(Ti.UI.createLabel({
text: this.title,
font: {fontWeight: "bold"},
left: 5,
right: 5,
top: 5,
height: "auto",
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
}));

var self = this;
function addButton(title, index, bottom) {
var button = Ti.UI.createButton({
left: 5,
right: 5,
top: 5,
bottom: bottom,
height: "auto",
title: title,
index: index
});
if (index === self.destructive) {
button.domNode.className += " TiUIButtonDestructive";
} else if (index === self.cancel) {
button.domNode.className += " TiUIButtonCancel";
}
optionsDialog.add(button);
button.addEventListener("singletap",function(){
optionsWindow.close();
self._optionsWindow = undef;
self.fireEvent("click",{
index: index,
cancel: self.cancel,
destructive: self.destructive
});
});
}

// Add the buttons
var options = this.options,
i = 0;
if (require.is(options,"Array")) {
for (; i < options.length; i++) {
addButton(options[i], i, i === options.length - 1 ? 5 : 0);
}
}

// Show the options dialog
optionsWindow.open();

// Animate the background after waiting for the first layout to occur
setTimeout(function(){
optionsDialog.animate({
bottom: -optionsDialog._measuredHeight,
opacity: 1,
duration: 0
});
dimmingView.animate({
opacity: 0.5,
duration: 150
}, function(){
setTimeout(function(){
optionsDialog.animate({
bottom: 0,
duration: 150
});
},0);
});
},30);
},

properties: {

cancel: -1,

destructive: -1,

options: undef,

title: "",

titleid: {
get: function(value) {
console.debug('Property "Titanium.UI.optionsDialog#.titleid" is not implemented yet.');
return value;
},
set: function(value) {
console.debug('Property "Titanium.UI.optionsDialog#.titleid" is not implemented yet.');
return value;
}
}
}

});

});
80 changes: 80 additions & 0 deletions mobileweb/src/titanium.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,86 @@ textarea {
to(#fff));
}

.TiUIButtonDestructive {
background: -moz-linear-gradient(
top,
#f00 0%,
#f00 50%,
#a00);
background: -webkit-gradient(
linear, left top, left bottom,
from(#f00),
color-stop(0.50, #f00),
to(#a00));
color: white;
}

.TiUIButtonDestructive:hover {
background: -moz-linear-gradient(
top,
#f00 0%,
#f00 50%,
#700);
background: -webkit-gradient(
linear, left top, left bottom,
from(#f00),
color-stop(0.50, #f00),
to(#700));
}

.TiUIButtonDestructive:active {
background: -moz-linear-gradient(
top,
#a00 0%,
#f00 50%,
#f00);
background: -webkit-gradient(
linear, left top, left bottom,
from(#b00),
color-stop(0.50, #f00),
to(#f00));
}

.TiUIButtonCancel {
background: -moz-linear-gradient(
top,
#666 0%,
#666 50%,
#333);
background: -webkit-gradient(
linear, left top, left bottom,
from(#666),
color-stop(0.50, #666),
to(#333));
color: white;
}

.TiUIButtonCancel:hover {
background: -moz-linear-gradient(
top,
#666 0%,
#666 50%,
#222);
background: -webkit-gradient(
linear, left top, left bottom,
from(#666),
color-stop(0.50, #666),
to(#222));
}

.TiUIButtonCancel:active {
background: -moz-linear-gradient(
top,
#333 0%,
#666 50%,
#666);
background: -webkit-gradient(
linear, left top, left bottom,
from(#333),
color-stop(0.50, #666),
to(#666));
}

.TiUITab {
background-color: silver;
border: solid 1px black;
Expand Down
1 change: 1 addition & 0 deletions support/mobileweb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __init__(self,project_dir,deploytype):
'Ti/UI/Button.js',
'Ti/UI/ImageView.js',
'Ti/UI/Label.js',
'Ti/UI/OptionDialog.js',
'Ti/UI/ScrollableView.js',
'Ti/UI/ScrollView.js',
'Ti/UI/Slider.js',
Expand Down