Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Chat message attachments and Csat Surveys #64

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e85f00f
chore: updated flutter sdk and major versions of packages
Nov 25, 2024
b3fe248
chore: updated package implementation calls to satisfy version updates
Nov 25, 2024
63ea8ce
chore: updated example app gradle configs
Nov 26, 2024
9ef3700
chore: update chatwoot message object with attachments
Nov 26, 2024
dd8570d
chore: added csat response and request data classes
Nov 26, 2024
5ca5f74
feat(chatwootclient): send csat response & new message media attachment
Nov 26, 2024
19dfed7
feat(chatwootclient): update chatwoot chat page with attachments and …
Nov 26, 2024
d94dbf2
chore: update dialog with message attachments
Nov 26, 2024
c684be0
chore: remove chatwoot dialog deprecation
Nov 26, 2024
cdf3440
feat: add custom link preview
Nov 26, 2024
be9d9fc
chore: remove preview packages
Nov 26, 2024
3d9127f
chore: added chatwoot chat with attachment example
Nov 26, 2024
5172802
fix: set dialog attachment callbacks
Nov 26, 2024
41af12a
fix: clear text after submit
Nov 26, 2024
3c7617c
fix: update send csat request json
Nov 26, 2024
33c7729
fix: update send csat request json
Nov 27, 2024
75df090
chore: move fetch link preview to link metadata class
Nov 27, 2024
8c82464
feat: added custom video preview with cache capabilties
Nov 27, 2024
3232246
fix: launch url on link preview tap
Nov 27, 2024
5ee6232
fix: fixed messages merger logic
Nov 27, 2024
abba4c3
fix: disable csat form interaction on sent tapped
Nov 27, 2024
1cbc534
fix: show link url on preview fetch error
Nov 28, 2024
3b77152
fix: only download attached document if hasn't already been downloaded
Nov 28, 2024
e989442
tests(chatwoot_client_service_test): update send message service tests
Nov 28, 2024
b224f7f
tests(chatwoot_repository_test): update onConversationResolved callba…
Nov 28, 2024
170c397
tests: added tests for send csat survey
Nov 28, 2024
ea21df3
chore: disabled csat form trigger
Nov 28, 2024
b60f5a9
fix(flutter_analyze): remove unused example method
Nov 28, 2024
fd5cfef
fix: fixed manual csat update
Nov 29, 2024
b76a707
fix: fixed system messages classified as user message
Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33

namespace "com.example.example"
compileSdkVersion 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.chatwoot.example"
minSdkVersion 19
targetSdkVersion 33
minSdkVersion flutter.minSdkVersion
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="example"
android:icon="@mipmap/ic_launcher">
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.20'
ext.kotlin_version = '2.0.20'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.1'
classpath 'com.android.tools.build:gradle:8.7.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand Down Expand Up @@ -88,7 +88,7 @@ class _MyHomePageState extends State<MyHomePage> {

final imageData = await photo.readAsBytes();
final decodedImage = image.decodeImage(imageData);
final scaledImage = image.copyResize(decodedImage, width: 500);
final scaledImage = image.copyResize(decodedImage!, width: 500);
final jpg = image.encodeJpg(scaledImage, quality: 90);

final filePath = (await getTemporaryDirectory()).uri.resolve(
Expand Down
110 changes: 110 additions & 0 deletions example/lib/main_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

import 'dart:io';
import 'dart:typed_data';

import 'package:chatwoot_sdk/chatwoot_sdk.dart';
import 'package:chatwoot_sdk/ui/chatwoot_chat_theme.dart';
import 'package:flutter/material.dart';
import 'package:file_picker/file_picker.dart';
import 'package:open_filex/open_filex.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
}

_showDialog(){
ChatwootChatDialog.show(
context,
title: "Customer Support",
inboxIdentifier: "your-api-inbox-identifier",
baseUrl: "https://app.chatwoot.com",
user: ChatwootUser(
identifier: "[email protected]",
name: "Tester test",
email: "[email protected]",
),
primaryColor: const Color(0xff258596),
onAttachmentPressed: _handleAttachmentPressed,
openFile: _handleOpenFile,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Chatwoot Example"),
actions: [
IconButton(onPressed: _showDialog, icon: Icon(Icons.copy))
],
),
body: ChatwootChat(
inboxIdentifier: "your-api-inbox-identifier",
baseUrl: "https://app.chatwoot.com",
user: ChatwootUser(
identifier: "[email protected]",
name: "Tester test",
email: "[email protected]",
),
theme: ChatwootChatTheme(
primaryColor: const Color(0xff258596)
),
onAttachmentPressed: _handleAttachmentPressed,
openFile: _handleOpenFile,
),
);
}

Future<void> _handleOpenFile(String filePath) async{
await OpenFilex.open(filePath);
}

Future<FileAttachment?> _handleAttachmentPressed() async{
return await _handleFileSelection();
}


Future<FileAttachment?> _handleFileSelection() async {
final result = await FilePicker.platform.pickFiles(
type: FileType.any,
);

if (result?.files.isNotEmpty ?? false) {
final bytes = await File(result!.files.first.path!).readAsBytes();
final name = result.files.first.name;
final path = result.files.first.path ?? '';
return FileAttachment(bytes: Uint8List.fromList(bytes), name: name, path: path);
}

return null;
}

}
Loading