Commit 3cd2892e by Pranay Madasi

ios color crash fix

parent 5081b259
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
); );
inputPaths = ( inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputFileListPaths = ( outputFileListPaths = (
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
@implementation FluttertoastPlugin { @implementation FluttertoastPlugin {
FlutterResult _result; FlutterResult _result;
} }
+ (void)registerWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar { + (void)registerWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:CHANNEL_NAME methodChannelWithName:CHANNEL_NAME
...@@ -39,6 +39,10 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -39,6 +39,10 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSNumber *bgcolor = call.arguments[@"bgcolor"]; NSNumber *bgcolor = call.arguments[@"bgcolor"];
NSNumber *textcolor = call.arguments[@"textcolor"]; NSNumber *textcolor = call.arguments[@"textcolor"];
NSLog(@"BG %d", bgcolor);
NSLog(@"TC %d", textcolor);
int time = 1; int time = 1;
@try { @try {
time = [durationTime intValue]; time = [durationTime intValue];
...@@ -54,7 +58,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -54,7 +58,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
style.backgroundColor = [self colorWithHex:bgcolor.unsignedIntegerValue]; style.backgroundColor = [self colorWithHex:bgcolor.unsignedIntegerValue];
style.messageColor = [self colorWithHex:textcolor.unsignedIntegerValue]; style.messageColor = [self colorWithHex:textcolor.unsignedIntegerValue];
if ([gravity isEqualToString:@"top"]) { if ([gravity isEqualToString:@"top"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg [[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration:time duration:time
......
import 'dart:async'; import 'dart:async';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:flutter/foundation.dart';
enum Toast { LENGTH_SHORT, LENGTH_LONG } enum Toast { LENGTH_SHORT, LENGTH_LONG }
...@@ -34,14 +35,24 @@ class Fluttertoast { ...@@ -34,14 +35,24 @@ class Fluttertoast {
gravityToast = "bottom"; gravityToast = "bottom";
} }
print(backgroundColor);
print(textColor);
if(backgroundColor == null && defaultTargetPlatform == TargetPlatform.iOS) {
backgroundColor = Colors.black;
}
if(textColor == null && defaultTargetPlatform == TargetPlatform.iOS) {
textColor = Colors.white;
}
final Map<String, dynamic> params = <String, dynamic>{ final Map<String, dynamic> params = <String, dynamic>{
'msg': msg, 'msg': msg,
'length': toast, 'length': toast,
'time': timeInSecForIos, 'time': timeInSecForIos,
'gravity': gravityToast, 'gravity': gravityToast,
'bgcolor': backgroundColor != null ? backgroundColor.value : backgroundColor, 'bgcolor': backgroundColor != null ? backgroundColor.value : null,
'textcolor': textColor != null ? textColor.value: textColor, 'textcolor': textColor != null ? textColor.value: null,
}; };
String res = await _channel.invokeMethod('showToast', params); String res = await _channel.invokeMethod('showToast', params);
return res; return res;
} }
......
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