Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Jul 16, 2021
1 parent 8084015 commit 613461e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 54 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.8

- Update dependencies and example
- Fix scroll controller not attached warning. Thanks @fikretsengul for reporting the bug!
- Fix right margin on input's progress indicator

## 1.1.7

- Update dependencies
Expand Down
76 changes: 38 additions & 38 deletions doc/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:image_picker/image_picker.dart';
class _MyHomePageState extends State<MyHomePage> {
// ...
void _handleImageSelection() async {
final result = await ImagePicker().getImage(
final result = await ImagePicker().pickImage(
imageQuality: 70,
maxWidth: 1440,
source: ImageSource.gallery,
Expand All @@ -25,14 +25,13 @@ class _MyHomePageState extends State<MyHomePage> {
if (result != null) {
final bytes = await result.readAsBytes();
final image = await decodeImageFromList(bytes);
final name = result.path.split('/').last;
final message = types.ImageMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
height: image.height.toDouble(),
id: randomString(),
name: name,
name: result.name,
size: bytes.length,
uri: result.path,
width: image.width.toDouble(),
Expand Down Expand Up @@ -85,8 +84,8 @@ class _MyHomePageState extends State<MyHomePage> {
final message = types.FileMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
name: result.files.single.name,
id: randomString(),
name: result.files.single.name,
size: result.files.single.size,
uri: result.files.single.path ?? '',
);
Expand Down Expand Up @@ -227,39 +226,41 @@ class _MyHomePageState extends State<MyHomePage> {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: 144,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextButton(
onPressed: () {
Navigator.pop(context);
_handleImageSelection();
},
child: const Align(
alignment: Alignment.centerLeft,
child: Text('Photo'),
return SafeArea(
child: SizedBox(
height: 144,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextButton(
onPressed: () {
Navigator.pop(context);
_handleImageSelection();
},
child: const Align(
alignment: Alignment.centerLeft,
child: Text('Photo'),
),
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
_handleFileSelection();
},
child: const Align(
alignment: Alignment.centerLeft,
child: Text('File'),
TextButton(
onPressed: () {
Navigator.pop(context);
_handleFileSelection();
},
child: const Align(
alignment: Alignment.centerLeft,
child: Text('File'),
),
),
),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Align(
alignment: Alignment.centerLeft,
child: Text('Cancel'),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Align(
alignment: Alignment.centerLeft,
child: Text('Cancel'),
),
),
),
],
],
),
),
);
},
Expand All @@ -275,8 +276,8 @@ class _MyHomePageState extends State<MyHomePage> {
final message = types.FileMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
name: result.files.single.name,
id: randomString(),
name: result.files.single.name,
size: result.files.single.size,
uri: result.files.single.path ?? '',
);
Expand All @@ -286,7 +287,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
void _handleImageSelection() async {
final result = await ImagePicker().getImage(
final result = await ImagePicker().pickImage(
imageQuality: 70,
maxWidth: 1440,
source: ImageSource.gallery,
Expand All @@ -295,14 +296,13 @@ class _MyHomePageState extends State<MyHomePage> {
if (result != null) {
final bytes = await result.readAsBytes();
final image = await decodeImageFromList(bytes);
final name = result.path.split('/').last;
final message = types.ImageMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
height: image.height.toDouble(),
id: randomString(),
name: name,
name: result.name,
size: bytes.length,
uri: result.path,
width: image.width.toDouble(),
Expand Down
11 changes: 3 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,19 @@ class _ChatPageState extends State<ChatPage> {
final message = types.FileMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
name: result.files.single.name,
id: const Uuid().v4(),
mimeType: lookupMimeType(result.files.single.path ?? ''),
name: result.files.single.name,
size: result.files.single.size,
uri: result.files.single.path ?? '',
);

_addMessage(message);
} else {
// User canceled the picker
}
}

void _handleImageSelection() async {
final result = await ImagePicker().getImage(
final result = await ImagePicker().pickImage(
imageQuality: 70,
maxWidth: 1440,
source: ImageSource.gallery,
Expand All @@ -125,22 +123,19 @@ class _ChatPageState extends State<ChatPage> {
if (result != null) {
final bytes = await result.readAsBytes();
final image = await decodeImageFromList(bytes);
final name = result.path.split('/').last;

final message = types.ImageMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
height: image.height.toDouble(),
id: const Uuid().v4(),
name: name,
name: result.name,
size: bytes.length,
uri: result.path,
width: image.width.toDouble(),
);

_addMessage(message);
} else {
// User canceled the picker
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies:
file_picker: ^3.0.3
flutter_chat_ui:
path: ../
image_picker: ^0.8.1+3
image_picker: ^0.8.2
intl: ^0.17.0
mime: ^1.0.0
open_file: ^3.2.1
Expand Down
12 changes: 7 additions & 5 deletions lib/src/widgets/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ class _ChatListState extends State<ChatList>
// Delay to give some time for Flutter to calculate new
// size after new message was added
Future.delayed(const Duration(milliseconds: 100), () {
_scrollController.animateTo(
0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInQuad,
);
if (_scrollController.hasClients) {
_scrollController.animateTo(
0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInQuad,
);
}
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class _InputState extends State<Input> {

Widget _leftWidget() {
if (widget.isAttachmentUploading == true) {
return SizedBox(
return Container(
height: 24,
margin: const EdgeInsets.only(right: 16),
width: 24,
child: CircularProgressIndicator(
backgroundColor: Colors.transparent,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_chat_ui
description: >
Actively maintained, community-driven chat UI implementation with an
optional Firebase BaaS.
version: 1.1.7
version: 1.1.8
homepage: https://flyer.chat
repository: https://github.com/flyerhq/flutter_chat_ui

Expand Down

0 comments on commit 613461e

Please sign in to comment.