mirror of
https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
synced 2026-07-31 00:02:14 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dbcc43e68 | ||
|
|
4f6463e3f2 | ||
|
|
41a568c549 | ||
|
|
811e0a82ed | ||
|
|
a2d253bdde | ||
|
|
ffe056db75 | ||
|
|
5e5251bbd2 | ||
|
|
37c14a6d2d | ||
|
|
369ab363b9 | ||
|
|
6ba778dd22 | ||
|
|
e8ade312d9 | ||
|
|
f6479c8846 | ||
|
|
658ee711db | ||
|
|
c7a329a7ac | ||
|
|
577b1704d9 | ||
|
|
7a08e6afd6 | ||
|
|
23d35404b5 | ||
|
|
c5b6060973 | ||
|
|
cabeea18ed | ||
|
|
6e13de8982 |
@@ -226,6 +226,7 @@ Note that on WP this object is currently ignored.
|
||||
styling: {
|
||||
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
|
||||
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
|
||||
@@ -250,6 +251,8 @@ 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.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.0: You can now style the Toast with a number of properties. See
|
||||
- 2.3.2: The click event introduced with 2.3.0 did not work with Android 5+.
|
||||
- 2.3.0: The plugin will now report back to JS if Toasts were tapped by the user.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
### Expected behaviour
|
||||
Tell us what should happen.
|
||||
|
||||
### Actual behaviour
|
||||
Tell us what happens instead. Provide a log message if relevant.
|
||||
|
||||
### I'm seeing this behaviour on
|
||||
_Remove this hint: these checkboxes can be checked like this: [x]_
|
||||
|
||||
- [ ] iOS device
|
||||
- [ ] iOS sim
|
||||
- [ ] Android device
|
||||
- [ ] Android sim
|
||||
|
||||
#### Hardware models
|
||||
Example: Samsung Galaxy S6, iPhone 6s
|
||||
|
||||
#### OS versions
|
||||
Example: Android 4.4.2, iOS 9.2
|
||||
|
||||
### I'm not a dummy, so I've checked these
|
||||
- [ ] It happens on a fresh Cordova CLI project as well.
|
||||
- [ ] I'm waiting for `deviceready` to fire.
|
||||
- [ ] My JavaScript has no errors (`window.onerror` catches nothing).
|
||||
|
||||
### So how can we reproduce this?
|
||||
_Remove this hint: Pick one of these - use the Preview feature of this editor to get a sense which option we like best_
|
||||
|
||||
#### Awesome :star::star::star::star::star:
|
||||
Provide a (link to a) minimal demo app showing the faulty behaviour.
|
||||
|
||||
#### Sweet :star::star::star::star:
|
||||
Provide a concise code sample which can be dropped into a freshly created Cordova CLI app.
|
||||
|
||||
#### Good :star::star::star:
|
||||
Provide your own app and instructions how to reproduce the issue.
|
||||
|
||||
#### Meh :star::star:
|
||||
Provide a code sample with a bunch of magic parameters which I need to interpolate by guessing to reconstruct the actual runtime code.
|
||||
|
||||
#### Worst :poop:
|
||||
Say the source code can't be disclosed and refuse to provide any of the above. Expect this issue to be closed by a bunch of angry aliens :alien::alien::alien::alien::alien: that will hunt you down and :fire: your :computer:. You've been warned. :fire_engine:
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-x-toast",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.2",
|
||||
"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",
|
||||
|
||||
+1
-1
@@ -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.4.0">
|
||||
version="2.4.2">
|
||||
|
||||
<name>Toast</name>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
@@ -92,6 +93,7 @@ public class Toast extends CordovaPlugin {
|
||||
|
||||
// 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 opacity = styling.optDouble("opacity", 0.8);
|
||||
final int cornerRadius = styling.optInt("cornerRadius", 100);
|
||||
final int horizontalPadding = styling.optInt("horizontalPadding", 50);
|
||||
@@ -102,6 +104,11 @@ public class Toast extends CordovaPlugin {
|
||||
shape.setAlpha((int)(opacity * 255)); // 0-255, where 0 is an invisible background
|
||||
shape.setColor(Color.parseColor(backgroundColor));
|
||||
toast.getView().setBackground(shape);
|
||||
|
||||
final TextView toastTextView;
|
||||
toastTextView = (TextView) toast.getView().findViewById(android.R.id.message);
|
||||
toastTextView.setTextColor(Color.parseColor(textColor));
|
||||
|
||||
toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
|
||||
|
||||
// this gives the toast a very subtle shadow on newer devices
|
||||
|
||||
+14
-8
@@ -140,11 +140,14 @@ static id styling;
|
||||
UIView *v = [vc view];
|
||||
[v addSubview:toast];
|
||||
|
||||
NSNumber * opacity = styling[@"opacity"];
|
||||
CGFloat theOpacity = opacity == nil ? CSToastOpacity : [opacity floatValue];
|
||||
|
||||
[UIView animateWithDuration:CSToastFadeDuration
|
||||
delay:0.0
|
||||
options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction)
|
||||
animations:^{
|
||||
toast.alpha = CSToastOpacity;
|
||||
toast.alpha = theOpacity;
|
||||
} completion:^(BOOL finished) {
|
||||
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(toastTimerDidFinish:) userInfo:toast repeats:NO];
|
||||
// associate the timer with the toast view
|
||||
@@ -319,16 +322,13 @@ static id styling;
|
||||
NSString * backgroundColor = styling[@"backgroundColor"];
|
||||
UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor];
|
||||
|
||||
NSNumber * opacity = styling[@"opacity"];
|
||||
CGFloat theOpacity = opacity == nil ? CSToastOpacity : [opacity floatValue];
|
||||
|
||||
NSNumber * horizontalPadding = styling[@"horizontalPadding"];
|
||||
NSNumber * verticalPadding = styling[@"verticalPadding"];
|
||||
CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue];
|
||||
CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue];
|
||||
|
||||
wrapperView.backgroundColor = [theColor colorWithAlphaComponent:theOpacity];
|
||||
|
||||
wrapperView.backgroundColor = theColor;
|
||||
|
||||
if(image != nil) {
|
||||
imageView = [[UIImageView alloc] initWithImage:image];
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
@@ -347,12 +347,15 @@ static id styling;
|
||||
}
|
||||
|
||||
if (title != nil) {
|
||||
NSString * titleLabelTextColor = styling[@"textColor"];
|
||||
UIColor *theTitleLabelTextColor = titleLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:titleLabelTextColor];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.numberOfLines = CSToastMaxTitleLines;
|
||||
titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize];
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
titleLabel.textColor = [UIColor whiteColor];
|
||||
titleLabel.textColor = theTitleLabelTextColor;
|
||||
titleLabel.backgroundColor = [UIColor clearColor];
|
||||
titleLabel.alpha = 1.0;
|
||||
titleLabel.text = title;
|
||||
@@ -364,11 +367,14 @@ static id styling;
|
||||
}
|
||||
|
||||
if (message != nil) {
|
||||
NSString * messageLabelTextColor = styling[@"textColor"];
|
||||
UIColor *theMessageLabelTextColor = messageLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:messageLabelTextColor];
|
||||
|
||||
messageLabel = [[UILabel alloc] init];
|
||||
messageLabel.numberOfLines = CSToastMaxMessageLines;
|
||||
messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize];
|
||||
messageLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
messageLabel.textColor = [UIColor whiteColor];
|
||||
messageLabel.textColor = theMessageLabelTextColor;
|
||||
messageLabel.backgroundColor = [UIColor clearColor];
|
||||
messageLabel.alpha = 1.0;
|
||||
messageLabel.text = message;
|
||||
|
||||
Reference in New Issue
Block a user