Skip to content

Commit 0a5f775

Browse files
committed
Some changes
1 parent 724cc4f commit 0a5f775

File tree

8 files changed

+48
-123
lines changed

8 files changed

+48
-123
lines changed

analysis_options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
analyzer:
22
enable-experiment:
33
- control-flow-collections
4+
exclude: ['**/*.g.dart', '**/*.freezed.dart']

lib/main.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension on Router {
2121
String path, {
2222
Widget Function(BuildContext, Map<String, List<String>>) handler,
2323
}) {
24-
this.define(
24+
define(
2525
path,
2626
handler: Handler(handlerFunc: (ctx, args) => handler(ctx, args)),
2727
);
@@ -33,19 +33,18 @@ class _MyAppState extends State<MyApp> {
3333

3434
_MyAppState() {
3535
router
36-
..handle('/login', handler: (_, __) => LoginPage())
37-
..handle(
38-
'/room/:roomId',
39-
handler: (_, args) => ChatPage(roomId: int.parse(args['roomId'][0])),
40-
)
41-
..handle('/room/:roomId/detail',
42-
handler: (_, args) => RoomDetailPage(
43-
roomId: int.parse(args['roomId'][0]),
44-
))
45-
..handle(
46-
'/room',
47-
handler: (_, __) => RoomListPage(),
48-
);
36+
..handle('/login', handler: (_, __) => LoginPage())
37+
..handle('/room/:roomId',
38+
handler: (_, args) => ChatPage(
39+
roomId: int.parse(args['roomId'][0]),
40+
))
41+
..handle('/room/:roomId/detail',
42+
handler: (_, args) => RoomDetailPage(
43+
roomId: int.parse(args['roomId'][0]),
44+
))
45+
..handle('/room', handler: (_, __) => RoomListPage())
46+
//
47+
;
4948
}
5049

5150
static final appState = AppState();

lib/src/page/chat_page.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ChatPage extends StatefulWidget {
2121
class _ChatState extends State<ChatPage> {
2222
final scrollController = ScrollController();
2323
final scaffoldKey = GlobalKey<ScaffoldState>();
24-
final _debounceTimer = TimerStream(true, const Duration(milliseconds: 500));
24+
final _debounceTimer = TimerStream(true, const Duration(milliseconds: 500)) //
25+
.asBroadcastStream();
2526
final scroll$ = StreamController<ScrollNotification>();
2627
final typing$ = StreamController();
2728

@@ -168,7 +169,7 @@ class _ChatState extends State<ChatPage> {
168169
var messageState = Provider.of<MessageState>(context, listen: false);
169170

170171
controller.addListener(() {
171-
print('controller listener');
172+
typing$.sink.add(null);
172173
});
173174

174175
final submit = (String message) {
@@ -250,7 +251,7 @@ class _ChatState extends State<ChatPage> {
250251
return Expanded(
251252
child: NotificationListener<ScrollNotification>(
252253
onNotification: (notification) {
253-
scroll$.add(notification);
254+
scroll$.sink.add(notification);
254255
return true;
255256
},
256257
child: Consumer<MessageState>(builder: (_, state, __) {

lib/src/page/login_page.dart

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:provider/provider.dart';
44
import 'package:qiscus_chat_sample/src/state/app_state.dart';
5-
import 'package:qiscus_chat_sample/src/state/room_state.dart';
65

76
class LoginPage extends StatefulWidget {
87
@override
@@ -14,7 +13,6 @@ class _LoginState extends State<LoginPage> {
1413
var _appIdController = TextEditingController(text: 'sdksample');
1514
var _userIdController = TextEditingController(text: 'guest-1002');
1615
var _userKeyController = TextEditingController(text: 'passkey');
17-
var _targetController = TextEditingController(text: 'guest-1001');
1816

1917
var isLoggingIn = false;
2018

@@ -26,16 +24,18 @@ class _LoginState extends State<LoginPage> {
2624
@override
2725
Widget build(BuildContext context) {
2826
return Scaffold(
29-
body: DecoratedBox(
30-
decoration: BoxDecoration(
31-
image: DecorationImage(
32-
image: Image.asset('assets/login-background.png').image,
33-
fit: BoxFit.cover,
27+
body: SafeArea(
28+
child: DecoratedBox(
29+
decoration: BoxDecoration(
30+
image: DecorationImage(
31+
image: Image.asset('assets/login-background.png').image,
32+
fit: BoxFit.cover,
33+
),
34+
),
35+
child: Form(
36+
key: _loginFormKey,
37+
child: buildContainer(),
3438
),
35-
),
36-
child: Form(
37-
key: _loginFormKey,
38-
child: buildContainer(),
3939
),
4040
),
4141
);
@@ -67,21 +67,6 @@ class _LoginState extends State<LoginPage> {
6767
controller: _userKeyController,
6868
decoration: InputDecoration(labelText: 'User Key'),
6969
),
70-
TextFormField(
71-
autovalidate: true,
72-
validator: (text) {
73-
var noWhitespace = _noWhitespaceValidator(text);
74-
if (noWhitespace != null) {
75-
return noWhitespace;
76-
}
77-
if (text == _userIdController.text) {
78-
return 'One doesn\'t simply, text to yourself';
79-
}
80-
return null;
81-
},
82-
controller: _targetController,
83-
decoration: InputDecoration(labelText: 'Chat Target'),
84-
),
8570
Padding(
8671
padding: const EdgeInsets.only(top: 40.0),
8772
child: RaisedButton(
@@ -104,12 +89,10 @@ class _LoginState extends State<LoginPage> {
10489

10590
_doLogin() async {
10691
var appState = Provider.of<AppState>(context, listen: false);
107-
var roomState = Provider.of<RoomState>(context, listen: false);
10892
if (_loginFormKey.currentState.validate()) {
10993
var appId = _appIdController.text;
11094
var userId = _userIdController.text;
11195
var userKey = _userKeyController.text;
112-
var target = _targetController.text;
11396

11497
setState(() {
11598
isLoggingIn = true;

lib/src/state/room_state.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ class RoomState extends ChangeNotifier {
9999
Timer _timer;
100100
var unsubscribe = qiscus.onUserTyping((userId, roomId, isTyping) {
101101
if (_timer != null) _timer.cancel();
102-
_typing$.add(Typing(userId, roomId, isTyping));
102+
if (userId != appState.userId) {
103+
_typing$.add(Typing(userId, roomId, isTyping));
104+
}
103105
_timer = Timer(const Duration(seconds: 2), () {
104106
_typing$.add(Typing(userId, roomId, false));
107+
qiscus.publishTyping(roomId: roomId, isTyping: false);
105108
});
106109
});
107110
_typing$.onCancel = () => unsubscribe();
@@ -117,7 +120,6 @@ class RoomState extends ChangeNotifier {
117120
Stream<Online> get onPresence {
118121
var unsubscribe = qiscus.onUserOnlinePresence(
119122
(userId, isOnline, lastOnline) {
120-
print('on presence: $userId $isOnline $lastOnline');
121123
_online$.add(Online(userId, isOnline, lastOnline));
122124
},
123125
);

lib/src/widget/chat_bubble.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,4 @@ class ChatBubble extends StatelessWidget {
6666
),
6767
);
6868
}
69-
70-
String _getThumbnailUrl(String url) =>
71-
url.replaceAll(r'/upload/', '/upload/w_30,c_scale/');
7269
}

pubspec.lock

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ packages:
3636
url: "https://pub.dartlang.org"
3737
source: hosted
3838
version: "2.4.0"
39-
bloc:
40-
dependency: "direct main"
41-
description:
42-
name: bloc
43-
url: "https://pub.dartlang.org"
44-
source: hosted
45-
version: "3.0.0"
4639
boolean_selector:
4740
dependency: transitive
4841
description:
@@ -155,6 +148,13 @@ packages:
155148
url: "https://pub.dartlang.org"
156149
source: hosted
157150
version: "0.16.1"
151+
cuid:
152+
dependency: "direct main"
153+
description:
154+
name: cuid
155+
url: "https://pub.dartlang.org"
156+
source: hosted
157+
version: "0.1.2"
158158
cupertino_icons:
159159
dependency: "direct main"
160160
description:
@@ -230,34 +230,13 @@ packages:
230230
description: flutter
231231
source: sdk
232232
version: "0.0.0"
233-
flutter_bloc:
234-
dependency: "direct main"
235-
description:
236-
name: flutter_bloc
237-
url: "https://pub.dartlang.org"
238-
source: hosted
239-
version: "3.2.0"
240-
flutter_mobx:
241-
dependency: "direct main"
242-
description:
243-
name: flutter_mobx
244-
url: "https://pub.dartlang.org"
245-
source: hosted
246-
version: "1.0.1"
247233
flutter_plugin_android_lifecycle:
248234
dependency: transitive
249235
description:
250236
name: flutter_plugin_android_lifecycle
251237
url: "https://pub.dartlang.org"
252238
source: hosted
253239
version: "1.0.6"
254-
flutter_redux:
255-
dependency: "direct main"
256-
description:
257-
name: flutter_redux
258-
url: "https://pub.dartlang.org"
259-
source: hosted
260-
version: "0.6.0"
261240
flutter_test:
262241
dependency: "direct dev"
263242
description: flutter
@@ -389,20 +368,6 @@ packages:
389368
url: "https://pub.dartlang.org"
390369
source: hosted
391370
version: "0.9.6+3"
392-
mobx:
393-
dependency: "direct main"
394-
description:
395-
name: mobx
396-
url: "https://pub.dartlang.org"
397-
source: hosted
398-
version: "1.0.2+1"
399-
mobx_codegen:
400-
dependency: "direct dev"
401-
description:
402-
name: mobx_codegen
403-
url: "https://pub.dartlang.org"
404-
source: hosted
405-
version: "1.0.2"
406371
mqtt_client:
407372
dependency: transitive
408373
description:
@@ -504,11 +469,9 @@ packages:
504469
qiscus_chat_sdk:
505470
dependency: "direct main"
506471
description:
507-
path: "."
508-
ref: master
509-
resolved-ref: "4cdb999f1b701ad03e43941b18c67d687a957c5e"
510-
url: "git://github.com/qiscus/qiscus-chat-sdk-flutter.git"
511-
source: git
472+
path: "..\\qiscus-chat-sdk-flutter"
473+
relative: true
474+
source: path
512475
version: "0.1.0"
513476
quiver:
514477
dependency: transitive
@@ -517,20 +480,6 @@ packages:
517480
url: "https://pub.dartlang.org"
518481
source: hosted
519482
version: "2.0.5"
520-
redux:
521-
dependency: "direct main"
522-
description:
523-
name: redux
524-
url: "https://pub.dartlang.org"
525-
source: hosted
526-
version: "4.0.0"
527-
redux_thunk:
528-
dependency: "direct main"
529-
description:
530-
name: redux_thunk
531-
url: "https://pub.dartlang.org"
532-
source: hosted
533-
version: "0.3.0"
534483
retrofit:
535484
dependency: transitive
536485
description:

pubspec.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@ environment:
77

88
dependencies:
99
timeago: ^2.0.26
10-
bloc: ^3.0.0
11-
flutter_bloc: ^3.2.0
1210
provider: ^4.0.4
1311
async:
14-
mobx: ^1.0.2+1
15-
flutter_mobx: ^1.0.1
1612
fluttertoast: ^3.1.3
17-
flutter_redux: ^0.6.0
1813
file_picker: ^1.5.1
19-
redux: ^4.0.0
20-
redux_thunk: ^0.3.0
2114
freezed_annotation:
2215
fluro: ^1.6.1
2316
date_format: ^1.0.8
17+
cuid: ^0.1.2
2418
qiscus_chat_sdk:
25-
# path: ../qiscus-chat-sdk-flutter
26-
git:
27-
url: git://github.com/qiscus/qiscus-chat-sdk-flutter.git
28-
ref: master
19+
path: ../qiscus-chat-sdk-flutter
20+
# git:
21+
# url: git://github.com/qiscus/qiscus-chat-sdk-flutter.git
22+
# ref: master
2923
flutter:
3024
sdk: flutter
3125

@@ -34,7 +28,6 @@ dependencies:
3428
cupertino_icons: ^0.1.2
3529

3630
dev_dependencies:
37-
mobx_codegen: ^1.0.2
3831
build_runner:
3932
freezed:
4033
flutter_test:

0 commit comments

Comments
 (0)