diff --git a/lib/ui/change_identity_screen.dart b/lib/ui/change_identity_screen.dart index 44f515e..4d8e5fc 100644 --- a/lib/ui/change_identity_screen.dart +++ b/lib/ui/change_identity_screen.dart @@ -78,6 +78,7 @@ class _ChangeIdentityScreenState extends State { data: PersonDelegateData( name: idsTuple.item1[index].name, mId: idsTuple.item1[index].mId, + profileImage: idsTuple.item1[index].avatar, ), isSelectable: true, onPressed: () { diff --git a/lib/ui/create_identity_screen.dart b/lib/ui/create_identity_screen.dart index 153a742..0131839 100644 --- a/lib/ui/create_identity_screen.dart +++ b/lib/ui/create_identity_screen.dart @@ -3,6 +3,7 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:image_picker/image_picker.dart'; import 'dart:io'; +import 'dart:convert'; import 'package:retroshare/common/styles.dart'; import 'package:retroshare/common/bottom_bar.dart'; @@ -22,6 +23,8 @@ class CreateIdentityScreen extends StatefulWidget { class _CreateIdentityScreenState extends State { TextEditingController nameController = TextEditingController(); File _image; + String _imageBase64 = ''; + int _imageSize; @override void dispose() { @@ -34,6 +37,8 @@ class _CreateIdentityScreenState extends State { setState(() { _image = image; + _imageSize = image.readAsBytesSync().length; + _imageBase64 = base64.encode(image.readAsBytesSync()); }); } @@ -110,14 +115,24 @@ class _CreateIdentityScreenState extends State { child: Container( height: 300 * 0.7, width: 300 * 0.7, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 300 * 0.7 * 0.33), - image: DecorationImage( - fit: BoxFit.fitWidth, - image: _image == null - ? AssetImage('assets/profile.jpg') - : FileImage(_image), + decoration: _image == null + ? null + : BoxDecoration( + borderRadius: + BorderRadius.circular( + 300 * 0.7 * 0.33), + image: DecorationImage( + fit: BoxFit.fitWidth, + image: FileImage(_image), + ), + ), + child: Visibility( + visible: _imageBase64.isEmpty, + child: Center( + child: Icon( + Icons.person, + size: 300 * 0.7, + ), ), ), ), @@ -169,8 +184,8 @@ class _CreateIdentityScreenState extends State { height: 2 * appBarHeight / 3, child: FlatButton( onPressed: () async { - Identity id = await createIdentity( - Identity('', false, nameController.text)); + Identity id = await createIdentity(Identity( + '', false, nameController.text, _imageBase64), _imageSize); final store = StoreProvider.of(context); store.dispatch(ChangeCurrentIdentityAction(id)); diff --git a/pubspec.yaml b/pubspec.yaml index b74cb56..1263c68 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,6 +28,7 @@ dependencies: tuple: ^1.0.2 flutter_redux: ^0.5.3 + image_picker: ^0.6.0+20 sliding_up_panel: ^0.3.4 # Toast