Skip to content

Commit

Permalink
#86 Is there anyway to get a significantly larger font on IOS and And…
Browse files Browse the repository at this point in the history
…roid?
  • Loading branch information
EddyVerbruggen committed Apr 28, 2016
1 parent 9ed9f01 commit dc6c537
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 30 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html)

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.
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ If you like this plugin and want to say thanks please send a PR or donation. Bot
4. [Styling](#styling)
5. [Credits](#5-credits)
6. [Changelog](#6-changelog)
7. [License](#7-license)

## 1. Description

Expand Down Expand Up @@ -230,6 +229,7 @@ Note that on WP this object is currently ignored.
opacity: 0.75, // 0.0 (transparent) to 1.0 (opaque). Default 0.8
backgroundColor: '#FF0000', // make sure you use #RRGGBB. Default #333333
textColor: '#FFFF00', // Ditto. Default #FFFFFF
textSize: 20.5, // Default is approx. 13.
cornerRadius: 16, // minimum is 0 (square). iOS default 20, Android default 100
horizontalPadding: 20, // iOS default 16, Android default 50
verticalPadding: 16 // iOS default 12, Android default 30
Expand All @@ -254,6 +254,7 @@ The Android code was entirely created by me.
For iOS most credits go to this excellent [Toast for iOS project by Charles Scalesse] (https://github.com/scalessec/Toast).

## 6. CHANGELOG
- 2.5.1: You can now specify the `textSize` used in the font for iOS and Android.
- 2.5.0: By popular demand: Specify the duration of the Toast on iOS and Android. Pass in `short` (2000ms), `long` (4000ms), or any nr of milliseconds: `900`.
- 2.4.2: You can now also set the Toast `opacity` for iOS.
- 2.4.1: As an addition to 2.4.0, [Sino](https://github.com/SinoBoeckmann) added the option to change the text color!
Expand All @@ -263,25 +264,3 @@ For iOS most credits go to this excellent [Toast for iOS project by Charles Scal
- 2.0.1: iOS messages are hidden when another one is shown. [Thanks Richie Min!](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/pull/13)
- 2.0: WP8 support
- 1.0: initial version supporting Android and iOS

## 7. License

[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html)

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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-x-toast",
"version": "2.5.0",
"version": "2.5.1",
"description": "This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.",
"cordova": {
"id": "cordova-plugin-x-toast",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-x-toast"
version="2.5.0">
version="2.5.1">

<name>Toast</name>

Expand Down
4 changes: 4 additions & 0 deletions src/android/nl/xservices/plugins/Toast.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void run() {
// the defaults mimic the default toast as close as possible
final String backgroundColor = styling.optString("backgroundColor", "#333333");
final String textColor = styling.optString("textColor", "#ffffff");
final Double textSize = styling.optDouble("textSize", -1);
final double opacity = styling.optDouble("opacity", 0.8);
final int cornerRadius = styling.optInt("cornerRadius", 100);
final int horizontalPadding = styling.optInt("horizontalPadding", 50);
Expand All @@ -104,6 +105,9 @@ public void run() {
final TextView toastTextView;
toastTextView = (TextView) toast.getView().findViewById(android.R.id.message);
toastTextView.setTextColor(Color.parseColor(textColor));
if (textSize > -1) {
toastTextView.setTextSize(textSize.floatValue());
}

toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);

Expand Down
10 changes: 7 additions & 3 deletions src/ios/Toast+UIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ - (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UI
UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor];

NSNumber * horizontalPadding = styling[@"horizontalPadding"];
NSNumber * verticalPadding = styling[@"verticalPadding"];
CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue];

NSNumber * verticalPadding = styling[@"verticalPadding"];
CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue];

NSNumber * textSize = styling[@"textSize"];
CGFloat theTextSize = textSize == nil ? CSToastFontSize : [textSize floatValue];

wrapperView.backgroundColor = theColor;

if(image != nil) {
Expand All @@ -352,7 +356,7 @@ - (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UI

titleLabel = [[UILabel alloc] init];
titleLabel.numberOfLines = CSToastMaxTitleLines;
titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize];
titleLabel.font = [UIFont boldSystemFontOfSize:theTextSize];
titleLabel.textAlignment = NSTextAlignmentLeft;
titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
titleLabel.textColor = theTitleLabelTextColor;
Expand All @@ -372,7 +376,7 @@ - (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UI

messageLabel = [[UILabel alloc] init];
messageLabel.numberOfLines = CSToastMaxMessageLines;
messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize];
messageLabel.font = [UIFont systemFontOfSize:theTextSize];
messageLabel.lineBreakMode = NSLineBreakByWordWrapping;
messageLabel.textColor = theMessageLabelTextColor;
messageLabel.backgroundColor = [UIColor clearColor];
Expand Down
4 changes: 2 additions & 2 deletions www/Toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Toast.prototype.optionsBuilder = function () {
duration: duration,
position: position,
addPixelsY: addPixelsY
}
};
}
}
};
};


Expand Down

0 comments on commit dc6c537

Please sign in to comment.