Skip to content

Commit 748ff2d

Browse files
author
Franco Bugnano
committed
Ready to launch
1 parent 5d54e28 commit 748ff2d

File tree

6 files changed

+83
-81
lines changed

6 files changed

+83
-81
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
## [0.0.1] - TODO: Add release date.
1+
## 0.1.0
2+
3+
- Initial version.
24

3-
* TODO: Describe initial release.

LICENSE

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
TODO: Add your license here.
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022, TalkJS
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 43 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,64 @@
1-
# TalkJS
1+
# TalkJS Flutter SDK
22

3-
Flutter SDK for [TalkJS](https://talkjs.com)
3+
Official TalkJS SDK for Flutter
4+
5+
**What is TalkJS?**
6+
7+
TalkJS lets you add user-to-user chat to your marketplace, on-demand app, or
8+
social platform.
9+
For more information, visit
10+
[talkjs.com](https://talkjs.com/?ref=jssdk-npm-readme).
11+
12+
![Screenshots of TalkJS running on various devices](https://talkjs.com/images/devices_home.jpg)
13+
14+
Don't hesitate to
15+
[let us know](https://talkjs.com/?chat)
16+
if you have any questions about TalkJS.
417

518
## Requirements
619

7-
- Dart sdk: ">=2.12.0 <3.0.0"
8-
- Flutter: ">=1.17.0"
20+
- Dart sdk: ">=2.15.0 <3.0.0"
21+
- Flutter: ">=2.8.1"
922
- Android: `minSDKVersion 19`
1023

1124
## Installation
1225

13-
Assumption: You have an existing Flutter Project. You can follow this [guide](https://flutter.dev/docs/get-started/test-drive#create-app)
14-
on how to create a new Flutter Project.
15-
16-
First, clone this repository on your computer.
17-
```sh
18-
git clone https://github.com/talkjs/flutter-sdk-victor.git
19-
```
20-
21-
To add the package as a dependency, edit the dependencies section of
22-
your project's **pubspec.yaml** file in your Flutter project as follows:
26+
Edit the dependencies section of your project's `pubspec.yaml` file in your
27+
Flutter project as follows:
2328

2429
```yaml
2530
dependencies:
26-
talkjs:
27-
path: {path to directory containing this repository}/flutter-sdk-victor/talkjs
31+
talkjs_flutter: ^0.1.0
2832
```
2933
30-
The path specified should be an absolute path from the root directory of
31-
your system.
32-
33-
Run the command: ```flutter pub get``` on the command line or through
34-
Android Studio's **Get dependencies** button.
35-
36-
To debug on Android, put this line in the `android/app/src/main/AndroidManifest.xml` as a property of the `<application` tag:
34+
Run the command: `flutter pub get` on the command line or through Android
35+
Studio's **Get dependencies** button.
3736

38-
```xml
39-
android:usesCleartextTraffic="true"
40-
```
4137

42-
## Getting Started
38+
## Usage
4339

44-
If you used the [guide](https://flutter.dev/docs/get-started/test-drive#create-app)
45-
mentioned above to create a new Flutter project, replace everything in
46-
**lib/main.dart** with the following code:
40+
Import TalkJS in your project source files.
4741

4842
```dart
49-
import 'package:flutter/material.dart';
50-
import 'package:talkjs/talkjs.dart';
51-
52-
void main() {
53-
runApp(MyApp());
54-
}
55-
56-
class MyApp extends StatelessWidget {
57-
@override
58-
Widget build(BuildContext context) {
59-
return MaterialApp(
60-
title: 'TalkJS Demo',
61-
home: Scaffold(
62-
body: initChat()
63-
)
64-
);
65-
}
66-
67-
Widget initChat() {
68-
final me = User(id: '123456', name: 'Alice');
69-
final other = User(id: '654321', name: 'Sebastian');
70-
71-
final session = Session(appId: 'YOUR_APP_ID', me: me);
72-
final conversation = session.getOrCreateConversation(
73-
Talk.oneOnOneId(me.id, other.id)
74-
);
75-
76-
conversation.setParticipant(me);
77-
conversation.setParticipant(other);
78-
79-
final chatBox = session.createChatbox(conversation);
80-
return chatBox.mount();
81-
}
82-
}
43+
import 'package:talkjs_flutter/talkjs.dart';
8344
```
8445

85-
Replace ```YOUR_APP_ID``` with the App ID on the TalkJS [Dashboard](https://talkjs.com/dashboard/login.)
86-
87-
For users with an existing Flutter project, you can use the ```Widget``` returned
88-
by the ```initChat``` function in the example above as part of an existing
89-
```Widget``` definition or a navigation route
90-
91-
## Documentation
46+
Then follow our
47+
[Flutter guide](https://talkjs.com/docs/Getting_Started/Frameworks/Flutter/)
48+
to start using TalkJS in your project.
49+
50+
## TalkJS is fully forward compatible
51+
We promise to never break API compatibility.
52+
We may at times deprecate methods or fields, but we will never remove them.
53+
If something that used to work stops working, then that's a bug.
54+
Please [report it](https://talkjs.com/?chat) and we'll fix it asap.
55+
56+
The package is being released in a beta state.
57+
The reason for this is that there are things that one can do with the TalkJS
58+
JavaScript SDK that aren't possible with the Flutter SDK.
59+
We will release v1.0.0 of this package once the two SDKs are similar in terms
60+
of features.
61+
This however does not take away from our commitment to always maintain backward
62+
compatibility.
63+
So you can be assured that the package is stable for production use.
9264

93-
The SDK API reference can be found in **doc/api**.

lib/src/chatbox.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ class ChatBoxState extends State<ChatBox> {
174174
options["signature"] = widget.session.signature;
175175
}
176176

177-
options["me"] = getUserVariableName(widget.session.me);
177+
execute('const options = ${json.encode(options)};');
178178

179-
execute('const session = new Talk.Session(${json.encode(options)});');
179+
final variableName = getUserVariableName(widget.session.me);
180+
execute('options["me"] = $variableName;');
181+
182+
execute('const session = new Talk.Session(options);');
180183
}
181184

182185
void _createChatBox() {
@@ -285,7 +288,7 @@ class ChatBoxState extends State<ChatBox> {
285288
print('📗 chatbox._webViewCreatedCallback');
286289
}
287290

288-
String htmlData = await rootBundle.loadString('packages/talkjs/assets/index.html');
291+
String htmlData = await rootBundle.loadString('packages/talkjs_flutter/assets/index.html');
289292
Uri uri = Uri.dataFromString(htmlData, mimeType: 'text/html', encoding: Encoding.getByName('utf-8'));
290293
webViewController.loadUrl(uri.toString());
291294

lib/src/conversationlist.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class ConversationListState extends State<ConversationList> {
200200
print('📗 conversationlist._webViewCreatedCallback');
201201
}
202202

203-
String htmlData = await rootBundle.loadString('packages/talkjs/assets/index.html');
203+
String htmlData = await rootBundle.loadString('packages/talkjs_flutter/assets/index.html');
204204
Uri uri = Uri.dataFromString(htmlData, mimeType: 'text/html', encoding: Encoding.getByName('utf-8'));
205205
webViewController.loadUrl(uri.toString());
206206

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: talkjs
1+
name: talkjs_flutter
22
description: Official TalkJS SDK for Flutter
33
version: 0.1.0
44
homepage: https://talkjs.com
@@ -24,7 +24,7 @@ dev_dependencies:
2424
# The following section is specific to Flutter.
2525
flutter:
2626
assets:
27-
- packages/talkjs/assets/index.html
27+
- packages/talkjs_flutter/assets/index.html
2828

2929
# To add assets to your package, add an assets section, like this:
3030
# assets:

0 commit comments

Comments
 (0)