Skip to content

Commit

Permalink
Merge pull request #20 from Giphy/development
Browse files Browse the repository at this point in the history
dev->main
  • Loading branch information
ALexanderLonsky authored May 29, 2024
2 parents 9ccde54 + 4ef24bb commit 49d70ab
Show file tree
Hide file tree
Showing 116 changed files with 6,728 additions and 606 deletions.
51 changes: 51 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: 🐛 Bug Report
about: Submit a bug report to help us improve
labels: 'bug'
---

## 🐛 Bug Report

(A clear and concise description of what the bug is)

## To Reproduce

(Write your steps here:)

1. Step 1...
1. Step 2...
1. Step 3...

## Expected behavior

<!--
How did you expect your project to behave?
It’s fine if you’re not sure your understanding is correct.
Write down what you thought would happen.
-->

(Write what you thought would happen.)

## Actual Behavior

<!--
Did something go wrong?
Is something broken, or not behaving as you expected?
Describe this section in detail, and attach screenshots if possible.
-->

(Write what happened. Add screenshots, if applicable.)

## Your Environment

<!-- Include as many relevant details about the environment you experienced the bug in -->

- Giphy Flutter SDK version: FILL THIS OUT
- Dart SDK version: FILL THIS OUT
- Flutter SDK version: FILL THIS OUT
- Platform(s) (iOS, Android, or both?): FILL THIS OUT
- Device info (Simulator/Device? OS version? Debug/Release?): FILL THIS OUT

## Reproducible Demo

<!-- Let us know how to reproduce the issue. Include a code sample or share a project that reproduces the issue. -->
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 💡 Feature request
description: Suggest a new idea for Giphy Flutter SDK.
labels: ['feature request']
body:
- type: markdown
attributes:
value: |
Please provide a searchable summary of the issue in the title above ⬆️.
Thanks for contributing by creating an issue! ❤️
- type: checkboxes
attributes:
label: Duplicates
description: Please [search the history](https://github.com/Giphy/giphy-flutter-sdk/issues) to see if an issue already exists for the same problem.
options:
- label: I have searched the existing issues
required: true
- type: checkboxes
attributes:
label: Latest version
description: We roll bug fixes, performance enhancements, and other improvements into new releases.
options:
- label: I have tested the latest version
required: true
- type: textarea
attributes:
label: Summary 💡
description: Describe how it should work.
validations:
required: true
- type: textarea
attributes:
label: Motivation 🔦
description: What are you trying to accomplish? How has the lack of this feature affected you? Providing context helps us come up with a solution that is more useful in the real world.
validations:
required: false
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.1
## 0.1.2

* TODO: Describe initial release.
### Native SDKs

- Giphy Android SDK [v2.3.13](https://github.com/Giphy/giphy-android-sdk/releases/tag/v2.3.13)
- Giphy iOS SDK [v2.2.9](https://github.com/Giphy/giphy-ios-sdk/releases/tag/v2.2.9)
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing

We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the
project.

## Development workflow

### Install dependencies

To get started with the project, run `flutter pub get` in the root directory to install the required dependencies for each package:

```sh
flutter pub get
```

To edit the Swift files, open `example/ios/Runner.xcworkspace` in XCode and find the source
files at `Pods > Development Pods > giphy_flutter_sdk`.

To edit the Kotlin files, open `example/android` in Android studio and find the source files at `giphy_flutter_sdk`
under `Android`.

While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's
Dart and the native code will be reflected in the example app.

### Run the example app

- To run the example application, you need to configure the GIPHY API keys. To do this,
you can copy the `config.example.dart` file and fill in the necessary variables:
```sh
cp example/lib/config_example.dart/ example/lib/config.dart
```

- To list all available devices IDs:
```sh
flutter devices
```

- Run the example app:
```sh
cd example && flutter run -d YOUR_DEVICE_ID && cd ..
```


### Publishing to pub.dev

- *note* While we welcome feedback and prs, publishing new versions of the project to pub.dev is reserved for GIPHY engineers.

- Dry Run to validate and ensure that everything is set up correctly before performing the actual publication
```sh
flutter pub publish --dry-run
```

- Authenticate Using pub
```sh
flutter pub login
```

- Publish
```sh
flutter pub publish
```

### Scripts

- `scripts/sdk.sh bump android`: update the GIPHY Android SDK to the latest version.
- `scripts/sdk.sh bump ios`: update the GIPHY iOS SDK to the latest version.

### Sending a pull request

> **Working on your first pull request?** You can learn how from this _free_
>
series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).

When you're sending a pull request:

- Prefer small pull requests focused on one change.
- Verify that linters and tests are passing.
- Review the documentation to make sure it looks good.
- Follow the pull request template when opening a pull request.
- For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# giphy-flutter-sdk
<p align="center">
<img width="750" height="150" src="https://github.com/Giphy/giphy-flutter-sdk/blob/main/doc/assets/sdk_logo.gif">
</p>

Giphy FLutter SDK
<img align="right" width="300" height="483" src="https://github.com/Giphy/giphy-flutter-sdk/blob/main/doc/assets/example_app.gif">

## Getting Started
# GIPHY SDK for Flutter

The fastest and easiest way to bring the full GIPHY experience directly to your app is with the GIPHY SDK. Built with developers and product designers in mind, GIPHY SDK is a top-to-bottom solution for all things GIF in your app. Introducing support for the Flutter developer ecosystem, this project enables you to easily integrate our battle-tested native [iOS](https://github.com/Giphy/giphy-ios-sdk) and [Android](https://github.com/Giphy/giphy-ios-sdk) SDKs, which handle everything from interfacing with the GIPHY API, fetching and caching assets, and displaying GIFs and Stickers on screen in customizable UI templates.

With billions of requests a day, it’s safe to say GIPHY knows GIFs. We're excited to share our best-in-class tools with you so your users can have the best GIF experience possible, with all the same features they're already enjoying on Facebook, Slack, Instagram, and more – with just a few lines of code.

### [Getting Started](doc/getting-started.md)

- [Requirements](doc/getting-started.md#requirements)
- [Installation](doc/getting-started.md#installation)
- [Basic Usage](doc/getting-started.md#basic-usage)
- [GIPHY Clips: GIFs with Sound](doc/clips.md)
- [GIPHY Animated Text Creation](doc/animated.md)
- [Example App](https://github.com/Giphy/giphy-flutter-sdk/tree/main/example)

### [API Reference](doc/api.md)

- [GiphyFlutterSDK](doc/api.md#giphyfluttersdk)
- [GiphyDialog](doc/api.md#giphydialog)
- [GiphyMediaView](doc/api.md#giphymediaview)
- [GiphyVideoView](doc/api.md#giphyvideoview)
- [GiphyVideoManager](doc/api.md#giphyvideomanager)
- [GiphyGridView](doc/api.md#giphygridview)
- [GiphyContent](doc/api.md#giphycontent)
- [GiphyTheme](doc/api.md#giphytheme)

92 changes: 87 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
group 'com.giphy.giphy_flutter_sdk'
version '1.0-SNAPSHOT'

import org.yaml.snakeyaml.Yaml
import java.nio.file.Files

File findPubspecYaml() {
def dir = project.projectDir
while (dir != null) {
def pubspecFile = new File(dir, "pubspec.yaml")
if (pubspecFile.exists()) {
return pubspecFile
}
dir = dir.parentFile
}
throw new FileNotFoundException("pubspec.yaml not found")
}

def getVersionFromPubspec() {
def pubspecPath = findPubspecYaml()
def yaml = new Yaml()
def pubspecContent = yaml.load(Files.newInputStream(pubspecPath.toPath()))
return pubspecContent['version']
}

ext.sdkVersion = getVersionFromPubspec()

buildscript {
ext.kotlin_version = '1.7.10'
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["GiphyFlutterSDK.kotlinVersion"]
repositories {
google()
mavenCentral()
Expand All @@ -11,6 +35,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.yaml:snakeyaml:2.2'
}
}

Expand All @@ -24,12 +49,30 @@ allprojects {
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def getExt(name, prefix = 'GiphyFlutterSDK.') {
return rootProject.ext.has(prefix + name) ? rootProject.ext.get(prefix + name) : null
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["GiphyFlutterSDK." + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["GiphyFlutterSDK." + name]).toInteger()
}

android {
if (project.android.hasProperty("namespace")) {
namespace 'com.giphy.giphy_flutter_sdk'
namespace 'com.giphyfluttersdk'
}

compileSdkVersion 33
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

buildTypes {
release {
minifyEnabled false
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -46,12 +89,14 @@ android {
}

defaultConfig {
minSdkVersion 19
buildConfigField "String", "SDK_VERSION", "\"${sdkVersion}\""
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
}

dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
implementation 'com.giphy.sdk:ui:2.3.14'
}

testOptions {
Expand All @@ -66,3 +111,40 @@ android {
}
}
}

tasks.register('configureGiphyVideoPlayerAdapter') {
String sdkRoot = new File(projectDir, '..')
String targetFolder = new File(sdkRoot, 'android/src/main/kotlin/com/giphy/giphy_flutter_sdk/videoplayeradapter')
String sdkResources = new File(sdkRoot, 'android/resources')

// copy the default implementation
apply from: new File(sdkResources, 'videoplayeradapter/dependencies.gradle')
project.delete(targetFolder)
project.copy {
from new File(sdkResources, 'videoplayeradapter')
include '**/*.*'
exclude 'dependencies.gradle'
into targetFolder
}

// replace with a custom adapter
String videoPlayerAdapter = getExt('videoPlayerAdapter')
if (!videoPlayerAdapter) {
return
}
String videoPlayerAdaptersPath = getExt('videoPlayerAdaptersPath') ?: sdkResources
File videoPlayerAdapterFullPath = new File(videoPlayerAdaptersPath, videoPlayerAdapter)
if (!videoPlayerAdapterFullPath.exists()) {
throw new GradleException("The video player adapter \"${videoPlayerAdapter}\" " +
"cannot be found in this \"${videoPlayerAdaptersPath}\" folder.")
}
apply from: new File(videoPlayerAdapterFullPath, 'dependencies.gradle')
project.copy {
from videoPlayerAdapterFullPath
include '**/*.*'
exclude 'dependencies.gradle'
into targetFolder
}
}

preBuild.dependsOn configureGiphyVideoPlayerAdapter
17 changes: 17 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri May 07 15:08:27 EEST 2021
GiphyFlutterSDK.kotlinVersion=1.7.20
GiphyFlutterSDK.minSdkVersion=21
GiphyFlutterSDK.targetSdkVersion=31
GiphyFlutterSDK.compileSdkVersion=33
6 changes: 6 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 49d70ab

Please sign in to comment.