Skip to content

Commit

Permalink
Merge pull request #1 from eyro-labs/refactoring
Browse files Browse the repository at this point in the history
Refactoring package name
  • Loading branch information
alann-maulana committed Dec 18, 2019
2 parents 33ebf16 + 849389c commit 327850b
Show file tree
Hide file tree
Showing 32 changed files with 180 additions and 137 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
@@ -0,0 +1,26 @@
os: linux
dist: trusty
jdk: oraclejdk8
sudo: required
addons:
apt:
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
sources:
- ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version
packages:
- lib32stdc++6 # https://github.com/flutter/flutter/issues/6207
- libstdc++6
- curl
cache:
directories:
- $HOME/.pub-cache
before_script:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
install:
- gem install coveralls-lcov
script:
- flutter doctor -v
- make
after_success:
- coveralls-lcov --repo-token $COVERALLS_TOKEN coverage/lcov.info
12 changes: 6 additions & 6 deletions README.md
@@ -1,6 +1,6 @@
# Flutter Toast

[![Pub](https://img.shields.io/pub/v/flutter_toast)](https://pub.dev/packages/flutter_toast) [![Build Status](https://travis-ci.org/eyro-labs/flutter_toast.svg?branch=master)](https://travis-ci.org/eyro-labs/flutter_toast) [![Coverage Status](https://coveralls.io/repos/github/eyro-labs/flutter_toast/badge.svg?branch=master)](https://coveralls.io/github/eyro-labs/flutter_toast?branch=master) [![GitHub](https://img.shields.io/github/license/eyro-labs/flutter_toast?color=2196F3)](https://github.com/eyro-labs/flutter_toast/blob/master/LICENSE) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feyro-labs%2Fflutter_toast.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Feyro-labs%2Fflutter_toast?ref=badge_shield)
[![Pub](https://img.shields.io/pub/v/eyro_toast)](https://pub.dev/packages/eyro_toast) [![Build Status](https://travis-ci.org/eyro-labs/eyro_toast.svg?branch=master)](https://travis-ci.org/eyro-labs/eyro_toast) [![Coverage Status](https://coveralls.io/repos/github/eyro-labs/eyro_toast/badge.svg?branch=master)](https://coveralls.io/github/eyro-labs/eyro_toast?branch=master) [![GitHub](https://img.shields.io/github/license/eyro-labs/eyro_toast?color=2196F3)](https://github.com/eyro-labs/eyro_toast/blob/master/LICENSE) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feyro-labs%2Feyro_toast.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Feyro-labs%2Feyro_toast?ref=badge_shield)

A simple yet powerful Flutter plugin for showing Toast at Android and iOS.

Expand All @@ -14,24 +14,24 @@ Add to pubspec.yaml:

```yaml
dependencies:
flutter_toast: any
eyro_toast: any
```

## Import Library
```dart
import 'package:flutter_toast/flutter_toast.dart';
import 'package:eyro_toast/eyro_toast.dart';
```

## Native Toast
```dart
// showing short Toast
await FlutterToast.showToast(
await EyroToast.showToast(
text: 'This is short toast',
duration: ToastDuration.short,
);
// showing long Toast
await FlutterToast.showToast(
await EyroToast.showToast(
text: 'This is long toast',
duration: ToastDuration.long,
);
Expand Down Expand Up @@ -59,4 +59,4 @@ await showToaster(

## Author

Flutter Toast plugin is developed by Eyro Labs. You can contact us at <admin@cubeacon.com>.
Eyro Toast plugin is developed by Eyro Labs. You can contact us at <admin@cubeacon.com>.
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fluttertoast">
package="com.eyrotoast">
</manifest>
@@ -1,27 +1,27 @@
package com.fluttertoast;
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
package com.eyrotoast;

import android.widget.Toast;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Map;

/**
* User: maulana
* Date: 2019-11-05
* Time: 21:07
*/
class FlutterToastData {
class EyroToastData {
private String text;
private int duration;

FlutterToastData(String text, int duration) {
EyroToastData(String text, int duration) {
this.text = text;
this.duration = duration;
}

static FlutterToastData fromObject(Object arg) {
static EyroToastData fromObject(Object arg) {
if (arg instanceof Map) {
Map map = (Map) arg;
String text = "";
Expand All @@ -33,7 +33,7 @@ static FlutterToastData fromObject(Object arg) {
if (map.get("duration") instanceof Integer) {
duration = (int) map.get("duration");
}
return new FlutterToastData(
return new EyroToastData(
text,
duration
);
Expand Down
@@ -1,4 +1,7 @@
package com.fluttertoast;
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
package com.eyrotoast;

import android.content.Context;
import android.widget.Toast;
Expand All @@ -9,24 +12,24 @@
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/** FlutterToastPlugin */
public class FlutterToastPlugin implements MethodCallHandler {
/** EyroToastPlugin */
public class EyroToastPlugin implements MethodCallHandler {
private final Context applicationContext;

public FlutterToastPlugin(Context applicationContext) {
public EyroToastPlugin(Context applicationContext) {
this.applicationContext = applicationContext;
}

/** Plugin registration. */
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_toast");
channel.setMethodCallHandler(new FlutterToastPlugin(registrar.context().getApplicationContext()));
final MethodChannel channel = new MethodChannel(registrar.messenger(), "eyro_toast");
channel.setMethodCallHandler(new EyroToastPlugin(registrar.context().getApplicationContext()));
}

@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("showToast")) {
FlutterToastData data = FlutterToastData.fromObject(call.arguments);
EyroToastData data = EyroToastData.fromObject(call.arguments);
if (data != null) {
Toast.makeText(applicationContext, data.getText(), data.getDuration()).show();
result.success(true);
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
@@ -1 +1 @@
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_toast","dependencies":[]}]}
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"eyro_toast","dependencies":[]}]}
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
@@ -1,27 +1,27 @@
PODS:
- Flutter (1.0.0)
- flutter_toast (0.1.0):
- eyro_toast (0.1.0):
- Flutter
- Toast
- Flutter (1.0.0)
- Toast (4.0.0)

DEPENDENCIES:
- eyro_toast (from `.symlinks/plugins/eyro_toast/ios`)
- Flutter (from `Flutter`)
- flutter_toast (from `.symlinks/plugins/flutter_toast/ios`)

SPEC REPOS:
trunk:
- Toast

EXTERNAL SOURCES:
eyro_toast:
:path: ".symlinks/plugins/eyro_toast/ios"
Flutter:
:path: Flutter
flutter_toast:
:path: ".symlinks/plugins/flutter_toast/ios"

SPEC CHECKSUMS:
eyro_toast: b0faa8d790ab8d8e8a3bce717c5922e87de6a18c
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_toast: 6b878e9774d9c6245a79a0698893d43f0867a2ea
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196

PODFILE CHECKSUM: 3dbe063e9c90a5d7c9e4e76e70a821b9e2c1d271
Expand Down
10 changes: 5 additions & 5 deletions example/lib/main.dart
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';

import 'package:flutter_toast/flutter_toast.dart';
import 'package:eyro_toast/eyro_toast.dart';

void main() {
FlutterToastSetup.shared.navigatorKey = GlobalKey<NavigatorState>();
EyroToastSetup.shared.navigatorKey = GlobalKey<NavigatorState>();
runApp(MyApp());
}

Expand All @@ -23,7 +23,7 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
// don't forget to set the global navigator key
// if you're using pure Flutter Toaster
navigatorKey: FlutterToastSetup.shared.navigatorKey,
navigatorKey: EyroToastSetup.shared.navigatorKey,
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Toast'),
Expand All @@ -40,7 +40,7 @@ class _MyAppState extends State<MyApp> {
subtitle: Text('Show toast for a short 2 seconds time'),
trailing: Icon(Icons.chevron_right),
onTap: () async {
await FlutterToast.showToast(
await EyroToast.showToast(
text: 'This is short toast',
duration: ToastDuration.short,
);
Expand All @@ -52,7 +52,7 @@ class _MyAppState extends State<MyApp> {
subtitle: Text('Show toast for a long 3.5 seconds time'),
trailing: Icon(Icons.chevron_right),
onTap: () async {
await FlutterToast.showToast(
await EyroToast.showToast(
text: 'This is long toast',
duration: ToastDuration.long,
);
Expand Down
16 changes: 8 additions & 8 deletions example/pubspec.lock
Expand Up @@ -63,7 +63,14 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
version: "0.1.3"
eyro_toast:
dependency: "direct dev"
description:
path: ".."
relative: true
source: path
version: "0.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -74,13 +81,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_toast:
dependency: "direct dev"
description:
path: ".."
relative: true
source: path
version: "0.1.0"
image:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
@@ -1,4 +1,4 @@
name: flutter_toast_example
name: eyro_toast_example
description: Demonstrates how to use the flutter_toast plugin.
publish_to: 'none'

Expand All @@ -17,7 +17,7 @@ dev_dependencies:
flutter_test:
sdk: flutter

flutter_toast:
eyro_toast:
path: ../

# For information on the generic Dart part of this file, see the
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Expand Up @@ -8,7 +8,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_toast_example/main.dart';
import 'package:eyro_toast_example/main.dart';

void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
Expand Down
20 changes: 20 additions & 0 deletions ios/Classes/EyroToastData.h
@@ -0,0 +1,20 @@
//
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface EyroToastData : NSObject

@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) NSNumber *duration;

-(instancetype) initWithObject:(id)object;

@end

NS_ASSUME_NONNULL_END
11 changes: 5 additions & 6 deletions ios/Classes/FlutterToastData.m → ios/Classes/EyroToastData.m
@@ -1,13 +1,12 @@
//
// FlutterToastData.m
// flutter_toast
//
// Created by Alann Maulana on 05/11/19.
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
//

#import "FlutterToastData.h"
#import "EyroToastData.h"

@implementation FlutterToastData
@implementation EyroToastData

-(instancetype) initWithObject:(id)object {
if (self = [super init]) {
Expand Down
10 changes: 10 additions & 0 deletions ios/Classes/EyroToastPlugin.h
@@ -0,0 +1,10 @@
//
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
//

#import <Flutter/Flutter.h>

@interface EyroToastPlugin : NSObject<FlutterPlugin>
@end
18 changes: 12 additions & 6 deletions ios/Classes/FlutterToastPlugin.m → ios/Classes/EyroToastPlugin.m
@@ -1,19 +1,25 @@
#import "FlutterToastPlugin.h"
#import "FlutterToastData.h"
//
// Copyright (c) 2019, the Eyro Toast project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// MIT license that can be found in the LICENSE file.
//

#import "EyroToastPlugin.h"
#import "EyroToastData.h"
#import <Toast/Toast.h>

@implementation FlutterToastPlugin
@implementation EyroToastPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"flutter_toast"
methodChannelWithName:@"eyro_toast"
binaryMessenger:[registrar messenger]];
FlutterToastPlugin* instance = [[FlutterToastPlugin alloc] init];
EyroToastPlugin* instance = [[EyroToastPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"showToast" isEqualToString:call.method]) {
FlutterToastData *data = [[FlutterToastData alloc] initWithObject:call.arguments];
EyroToastData *data = [[EyroToastData alloc] initWithObject:call.arguments];
if (data) {
id<UIApplicationDelegate> appDelegate = [[UIApplication sharedApplication] delegate];
UIView *rootView = appDelegate.window.rootViewController.view;
Expand Down
21 changes: 0 additions & 21 deletions ios/Classes/FlutterToastData.h

This file was deleted.

0 comments on commit 327850b

Please sign in to comment.