Skip to content

Commit

Permalink
Merge pull request #66 from ryg-git/issue-58
Browse files Browse the repository at this point in the history
Closes #58
  • Loading branch information
aguilaair committed May 23, 2021
2 parents a45c068 + 74612d7 commit 7acbef9
Show file tree
Hide file tree
Showing 15 changed files with 755 additions and 54 deletions.
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
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-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
1 change: 1 addition & 0 deletions example/android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
104 changes: 101 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
file_picker:
dependency: transitive
description:
name: file_picker
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
flex_color_picker:
dependency: "direct main"
description:
Expand All @@ -97,6 +118,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -113,7 +141,7 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0"
version: "0.13.3"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -177,6 +205,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
pedantic:
dependency: transitive
description:
Expand All @@ -191,13 +254,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
quiver:
dependency: transitive
description:
Expand Down Expand Up @@ -264,7 +341,7 @@ packages:
description:
path: "."
ref: main
resolved-ref: "30e3c6ae592305adbb4d32cec2e1b627002f310f"
resolved-ref: d5271adc99a3199b4cdb0df321a999dd61fb5832
url: "git://github.com/aguilaair/thememode_selector"
source: git
version: "0.1.0"
Expand All @@ -282,13 +359,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
universal_io:
dependency: transitive
description:
name: universal_io
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.2"
version: "6.0.3"
url_launcher_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -338,6 +422,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
12 changes: 5 additions & 7 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Papercups.io Flutter Example App.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
Expand All @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 2.0.0

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -31,15 +31,14 @@ dependencies:
# the parent directory to use the current plugin's version.
path: ../


# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flex_color_picker: ^2.0.0-nullsafety.3
thememode_selector:
thememode_selector:
git:
url: git://github.com/aguilaair/thememode_selector
ref: main
url: git://github.com/aguilaair/thememode_selector
ref: main
url_launcher: ^6.0.2

dev_dependencies:
Expand All @@ -51,7 +50,6 @@ dev_dependencies:

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down
8 changes: 8 additions & 0 deletions lib/models/attachment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PapercupsAttachment {
String? id;
String? fileName;
String? fileUrl;
String? contentType;

PapercupsAttachment({this.id, this.fileName, this.fileUrl, this.contentType});
}
10 changes: 10 additions & 0 deletions lib/models/message.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Imports
import 'package:papercups_flutter/models/models.dart';

import 'user.dart';
import 'customer.dart';
export 'user.dart';
Expand Down Expand Up @@ -34,6 +36,12 @@ class PapercupsMessage {
/// The userID of the person sending. Is nullable is the person sending is a customer.
int? userId;

/// The file ids of files to be sent, could be null if message does not contain files
List<String>? fileIds;

/// the metadata of files attached
List<PapercupsAttachment>? attachments;

PapercupsMessage({
this.accountId,
this.body,
Expand All @@ -46,5 +54,7 @@ class PapercupsMessage {
this.user,
this.userId,
this.customer,
this.fileIds,
this.attachments,
});
}
1 change: 1 addition & 0 deletions lib/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export 'customer.dart';
export 'message.dart';
export 'message.dart';
export 'user.dart';
export 'attachment.dart';
6 changes: 6 additions & 0 deletions lib/papercups_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class PaperCupsWidget extends StatefulWidget {
/// Set to true in order to make the send message section float
final bool floatingSendMessage;

/// Function to handle message bubble tap action
final void Function(PapercupsMessage)? onMessageBubbleTap;

PaperCupsWidget({
required this.props,
this.dateLocale = "en-US",
Expand All @@ -46,6 +49,7 @@ class PaperCupsWidget extends StatefulWidget {
this.sentText = "Sent",
this.closeAction,
this.floatingSendMessage = false,
this.onMessageBubbleTap,
});

@override
Expand Down Expand Up @@ -116,6 +120,7 @@ class _PaperCupsWidgetState extends State<PaperCupsWidget> {
props: widget.props,
).then((failed) {
if (failed) {
// TODO: Internationalize this
Alert.show(
"There was an issue retrieving your details. Please try again!",
context,
Expand Down Expand Up @@ -299,6 +304,7 @@ class _PaperCupsWidgetState extends State<PaperCupsWidget> {
widget.sendingText,
widget.sentText,
textColor,
widget.onMessageBubbleTap,
),
),
if (!widget.floatingSendMessage) PoweredBy(),
Expand Down
18 changes: 18 additions & 0 deletions lib/utils/downloadFile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:http/http.dart';
import 'package:url_launcher/url_launcher.dart';

Future<Stream<StreamedResponse>> downloadFile(String url) async {
var httpClient = Client();
var request = Request('GET', Uri.parse(url));
var response = httpClient.send(request);

return response.asStream();
}

void downloadFileWeb(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}

0 comments on commit 7acbef9

Please sign in to comment.