Commit 653e7dc3 by Karthik

default toast style fix

parent 6b2987a0
## [2.2.1]
* default toast style fix #38
## [2.2.0] ## [2.2.0]
* Background color fixed #29 * Background color fixed #29
......
...@@ -11,7 +11,7 @@ Android Toast Library for Flutter ...@@ -11,7 +11,7 @@ Android Toast Library for Flutter
```yaml ```yaml
# add this line to your dependencies # add this line to your dependencies
fluttertoast: ^2.2.0 fluttertoast: ^2.2.1
``` ```
```dart ```dart
......
...@@ -7,6 +7,7 @@ import android.graphics.PorterDuff; ...@@ -7,6 +7,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -22,8 +23,6 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -22,8 +23,6 @@ public class FluttertoastPlugin implements MethodCallHandler {
Context ctx; Context ctx;
int defaultTextColor = Color.TRANSPARENT;
FluttertoastPlugin(Context context) { FluttertoastPlugin(Context context) {
ctx = context; ctx = context;
} }
...@@ -43,6 +42,7 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -43,6 +42,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number bgcolor = call.argument("bgcolor"); Number bgcolor = call.argument("bgcolor");
Number textcolor = call.argument("textcolor"); Number textcolor = call.argument("textcolor");
Toast toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT); Toast toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
toast.setText(msg); toast.setText(msg);
...@@ -66,10 +66,6 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -66,10 +66,6 @@ public class FluttertoastPlugin implements MethodCallHandler {
TextView text = toast.getView().findViewById(android.R.id.message); TextView text = toast.getView().findViewById(android.R.id.message);
if (defaultTextColor == 0) {
defaultTextColor = text.getCurrentTextColor();
}
if(bgcolor != null) { if(bgcolor != null) {
Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg); Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg);
...@@ -84,10 +80,8 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -84,10 +80,8 @@ public class FluttertoastPlugin implements MethodCallHandler {
} }
try { if(textcolor != null) {
text.setTextColor(textcolor != null ? textcolor.intValue() : defaultTextColor); text.setTextColor(textcolor.intValue());
} catch (Exception e) {
e.printStackTrace();
} }
toast.show(); toast.show();
......
...@@ -8,7 +8,7 @@ buildscript { ...@@ -8,7 +8,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.android.tools.build:gradle:3.2.1'
} }
} }
......
#Fri Jun 23 08:50:38 CEST 2017 #Thu Dec 20 12:42:32 IST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
...@@ -17,8 +17,8 @@ class Fluttertoast { ...@@ -17,8 +17,8 @@ class Fluttertoast {
Toast toastLength, Toast toastLength,
int timeInSecForIos = 1, int timeInSecForIos = 1,
ToastGravity gravity, ToastGravity gravity,
Color backgroundColor = const Color.fromARGB(255, 0, 0, 0), Color backgroundColor,
Color textColor = const Color.fromARGB(255, 255, 255, 255), Color textColor,
}) async { }) async {
String toast = "short"; String toast = "short";
if (toastLength == Toast.LENGTH_LONG) { if (toastLength == Toast.LENGTH_LONG) {
...@@ -39,8 +39,8 @@ class Fluttertoast { ...@@ -39,8 +39,8 @@ class Fluttertoast {
'length': toast, 'length': toast,
'time': timeInSecForIos, 'time': timeInSecForIos,
'gravity': gravityToast, 'gravity': gravityToast,
'bgcolor': backgroundColor.value, 'bgcolor': backgroundColor != null ? backgroundColor.value : backgroundColor,
'textcolor': textColor.value, 'textcolor': textColor != null ? textColor.value: textColor,
}; };
String res = await _channel.invokeMethod('showToast', params); String res = await _channel.invokeMethod('showToast', params);
return res; return res;
......
name: fluttertoast name: fluttertoast
description: Toast Library for FLutter description: Toast Library for FLutter
version: 2.2.0 version: 2.2.1
author: Karthik Ponnam <ponnamkarthik3@gmail.com> author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment