#86 Is there anyway to get a significantly larger font on IOS and Android?

This commit is contained in:
EddyVerbruggen 2016-04-28 19:52:33 +02:00
parent 9ed9f018a7
commit dc6c537125
7 changed files with 36 additions and 30 deletions

19
LICENSE Normal file
View File

@ -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.

View File

@ -25,7 +25,6 @@ If you like this plugin and want to say thanks please send a PR or donation. Bot
4. [Styling](#styling) 4. [Styling](#styling)
5. [Credits](#5-credits) 5. [Credits](#5-credits)
6. [Changelog](#6-changelog) 6. [Changelog](#6-changelog)
7. [License](#7-license)
## 1. Description ## 1. Description
@ -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 opacity: 0.75, // 0.0 (transparent) to 1.0 (opaque). Default 0.8
backgroundColor: '#FF0000', // make sure you use #RRGGBB. Default #333333 backgroundColor: '#FF0000', // make sure you use #RRGGBB. Default #333333
textColor: '#FFFF00', // Ditto. Default #FFFFFF textColor: '#FFFF00', // Ditto. Default #FFFFFF
textSize: 20.5, // Default is approx. 13.
cornerRadius: 16, // minimum is 0 (square). iOS default 20, Android default 100 cornerRadius: 16, // minimum is 0 (square). iOS default 20, Android default 100
horizontalPadding: 20, // iOS default 16, Android default 50 horizontalPadding: 20, // iOS default 16, Android default 50
verticalPadding: 16 // iOS default 12, Android default 30 verticalPadding: 16 // iOS default 12, Android default 30
@ -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). For iOS most credits go to this excellent [Toast for iOS project by Charles Scalesse] (https://github.com/scalessec/Toast).
## 6. CHANGELOG ## 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.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.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! - 2.4.1: As an addition to 2.4.0, [Sino](https://github.com/SinoBoeckmann) added the option to change the text color!
@ -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.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 - 2.0: WP8 support
- 1.0: initial version supporting Android and iOS - 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.

View File

@ -1,6 +1,6 @@
{ {
"name": "cordova-plugin-x-toast", "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.", "description": "This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.",
"cordova": { "cordova": {
"id": "cordova-plugin-x-toast", "id": "cordova-plugin-x-toast",

View File

@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-x-toast" id="cordova-plugin-x-toast"
version="2.5.0"> version="2.5.1">
<name>Toast</name> <name>Toast</name>

View File

@ -90,6 +90,7 @@ public class Toast extends CordovaPlugin {
// the defaults mimic the default toast as close as possible // the defaults mimic the default toast as close as possible
final String backgroundColor = styling.optString("backgroundColor", "#333333"); final String backgroundColor = styling.optString("backgroundColor", "#333333");
final String textColor = styling.optString("textColor", "#ffffff"); final String textColor = styling.optString("textColor", "#ffffff");
final Double textSize = styling.optDouble("textSize", -1);
final double opacity = styling.optDouble("opacity", 0.8); final double opacity = styling.optDouble("opacity", 0.8);
final int cornerRadius = styling.optInt("cornerRadius", 100); final int cornerRadius = styling.optInt("cornerRadius", 100);
final int horizontalPadding = styling.optInt("horizontalPadding", 50); final int horizontalPadding = styling.optInt("horizontalPadding", 50);
@ -104,6 +105,9 @@ public class Toast extends CordovaPlugin {
final TextView toastTextView; final TextView toastTextView;
toastTextView = (TextView) toast.getView().findViewById(android.R.id.message); toastTextView = (TextView) toast.getView().findViewById(android.R.id.message);
toastTextView.setTextColor(Color.parseColor(textColor)); toastTextView.setTextColor(Color.parseColor(textColor));
if (textSize > -1) {
toastTextView.setTextSize(textSize.floatValue());
}
toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);

View File

@ -323,10 +323,14 @@ static id styling;
UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor]; UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor];
NSNumber * horizontalPadding = styling[@"horizontalPadding"]; NSNumber * horizontalPadding = styling[@"horizontalPadding"];
NSNumber * verticalPadding = styling[@"verticalPadding"];
CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue]; CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue];
NSNumber * verticalPadding = styling[@"verticalPadding"];
CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue]; CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue];
NSNumber * textSize = styling[@"textSize"];
CGFloat theTextSize = textSize == nil ? CSToastFontSize : [textSize floatValue];
wrapperView.backgroundColor = theColor; wrapperView.backgroundColor = theColor;
if(image != nil) { if(image != nil) {
@ -352,7 +356,7 @@ static id styling;
titleLabel = [[UILabel alloc] init]; titleLabel = [[UILabel alloc] init];
titleLabel.numberOfLines = CSToastMaxTitleLines; titleLabel.numberOfLines = CSToastMaxTitleLines;
titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize]; titleLabel.font = [UIFont boldSystemFontOfSize:theTextSize];
titleLabel.textAlignment = NSTextAlignmentLeft; titleLabel.textAlignment = NSTextAlignmentLeft;
titleLabel.lineBreakMode = NSLineBreakByWordWrapping; titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
titleLabel.textColor = theTitleLabelTextColor; titleLabel.textColor = theTitleLabelTextColor;
@ -372,7 +376,7 @@ static id styling;
messageLabel = [[UILabel alloc] init]; messageLabel = [[UILabel alloc] init];
messageLabel.numberOfLines = CSToastMaxMessageLines; messageLabel.numberOfLines = CSToastMaxMessageLines;
messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize]; messageLabel.font = [UIFont systemFontOfSize:theTextSize];
messageLabel.lineBreakMode = NSLineBreakByWordWrapping; messageLabel.lineBreakMode = NSLineBreakByWordWrapping;
messageLabel.textColor = theMessageLabelTextColor; messageLabel.textColor = theMessageLabelTextColor;
messageLabel.backgroundColor = [UIColor clearColor]; messageLabel.backgroundColor = [UIColor clearColor];

View File

@ -36,9 +36,9 @@ Toast.prototype.optionsBuilder = function () {
duration: duration, duration: duration,
position: position, position: position,
addPixelsY: addPixelsY addPixelsY: addPixelsY
} };
} }
} };
}; };