From 7248e6096d2a9fbedccd9407695dea3ec397d44a Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Mon, 18 Oct 2021 22:11:31 +0500 Subject: [PATCH] fixed the responsive issues + other --- packages/simplex_app/ios/Runner/Info.plist | 4 ++ .../lib/views/contacts/conversations.dart | 18 +++-- .../views/conversation/conversation_view.dart | 2 +- .../group_detail_conversation.dart | 13 ++-- .../lib/views/group/add_group_view.dart | 31 +++++---- .../simplex_app/lib/views/home/drawer.dart | 65 +++++++++---------- .../simplex_app/lib/views/home/home_view.dart | 4 +- .../lib/views/profile/profile_view.dart | 16 +++-- .../scan_invitation/scan_invitation_view.dart | 39 +++++------ 9 files changed, 102 insertions(+), 90 deletions(-) diff --git a/packages/simplex_app/ios/Runner/Info.plist b/packages/simplex_app/ios/Runner/Info.plist index cea51340e..1b7dd33d1 100644 --- a/packages/simplex_app/ios/Runner/Info.plist +++ b/packages/simplex_app/ios/Runner/Info.plist @@ -2,6 +2,10 @@ + io.flutter.embedded_views_preview + + NSCameraUsageDescription + This app needs camera access to scan QR codes CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/packages/simplex_app/lib/views/contacts/conversations.dart b/packages/simplex_app/lib/views/contacts/conversations.dart index 0455372d7..9f354a678 100644 --- a/packages/simplex_app/lib/views/contacts/conversations.dart +++ b/packages/simplex_app/lib/views/contacts/conversations.dart @@ -180,17 +180,23 @@ class _ConversationsState extends State { offset: const Offset(-10, -155), onSelected: (value) async { if (value == _options[0]) { - await Navigator.pushNamed(context, AppRoutes.scanInvitation); + var newMember = + await Navigator.pushNamed(context, AppRoutes.scanInvitation); + newMember ??= false; + if (newMember == true) { + _addNewMember(); + } } else if (value == _options[1]) { - var value = + var newMember = await Navigator.pushNamed(context, AppRoutes.addContact); - value ??= false; - if (value == true) { + newMember ??= false; + if (newMember == true) { _addNewMember(); } } else { - var value = await Navigator.pushNamed(context, AppRoutes.addGroup); - if (value == true) { + var newGroup = + await Navigator.pushNamed(context, AppRoutes.addGroup); + if (newGroup == true) { _getGroups(); } } diff --git a/packages/simplex_app/lib/views/conversation/conversation_view.dart b/packages/simplex_app/lib/views/conversation/conversation_view.dart index 333bf698e..d1ce72b0d 100644 --- a/packages/simplex_app/lib/views/conversation/conversation_view.dart +++ b/packages/simplex_app/lib/views/conversation/conversation_view.dart @@ -121,7 +121,7 @@ class _ConversationViewState extends State { }); }, icon: const Icon( - Icons.message, + Icons.bug_report, ), ) ], diff --git a/packages/simplex_app/lib/views/conversation/group_detail_conversation.dart b/packages/simplex_app/lib/views/conversation/group_detail_conversation.dart index 8ba9f691c..ab55e2a8a 100644 --- a/packages/simplex_app/lib/views/conversation/group_detail_conversation.dart +++ b/packages/simplex_app/lib/views/conversation/group_detail_conversation.dart @@ -182,6 +182,7 @@ class _GroupDetailsConversationState extends State { } void _memberSettings(String contact) { + Size _size = MediaQuery.of(context).size; showDialog( context: context, builder: (context) => StatefulBuilder( @@ -192,7 +193,7 @@ class _GroupDetailsConversationState extends State { Row( mainAxisSize: MainAxisSize.min, children: [ - const Spacer(), + SizedBox(width: _size.width * 0.15), const Expanded(child: Text('Owner')), Radio( value: MemberSetting.owner, @@ -202,13 +203,13 @@ class _GroupDetailsConversationState extends State { _memberSetting = value!; }); }), - const Spacer(), + SizedBox(width: _size.width * 0.15), ], ), Row( mainAxisSize: MainAxisSize.min, children: [ - const Spacer(), + SizedBox(width: _size.width * 0.15), const Expanded(child: Text('Admin')), Radio( groupValue: _memberSetting, @@ -218,13 +219,13 @@ class _GroupDetailsConversationState extends State { _memberSetting = value!; }); }), - const Spacer(), + SizedBox(width: _size.width * 0.15), ], ), Row( mainAxisSize: MainAxisSize.min, children: [ - const Spacer(), + SizedBox(width: _size.width * 0.15), const Expanded(child: Text('Member')), Radio( groupValue: _memberSetting, @@ -234,7 +235,7 @@ class _GroupDetailsConversationState extends State { _memberSetting = value!; }); }), - const Spacer(), + SizedBox(width: _size.width * 0.15), ], ), const Divider(), diff --git a/packages/simplex_app/lib/views/group/add_group_view.dart b/packages/simplex_app/lib/views/group/add_group_view.dart index dc0d18955..c2d789f1c 100644 --- a/packages/simplex_app/lib/views/group/add_group_view.dart +++ b/packages/simplex_app/lib/views/group/add_group_view.dart @@ -77,6 +77,7 @@ class _AddGroupViewState extends State { @override Widget build(BuildContext context) { + Size _size = MediaQuery.of(context).size; return GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: Scaffold( @@ -94,7 +95,7 @@ class _AddGroupViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), Center( child: SizedBox( height: 180.0, @@ -103,13 +104,14 @@ class _AddGroupViewState extends State { children: [ _imageUploaded ? CircleAvatar( - radius: 100.0, + radius: _size.height * 0.12, backgroundImage: FileImage(File(_groupPhotoPath)), ) - : const CircleAvatar( - radius: 100.0, - backgroundImage: AssetImage('assets/dp.png'), + : CircleAvatar( + radius: _size.height * 0.12, + backgroundImage: + const AssetImage('assets/dp.png'), ), Positioned( right: 0, @@ -140,9 +142,9 @@ class _AddGroupViewState extends State { ), ), ), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.03), const Text('Group Name', style: kSmallHeadingStyle), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), CustomTextField( textEditingController: _displayNameController, textInputType: TextInputType.name, @@ -154,15 +156,15 @@ class _AddGroupViewState extends State { return null; }, ), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), const Text('Group Description', style: kSmallHeadingStyle), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), CustomTextField( textEditingController: _descController, textInputType: TextInputType.text, hintText: 'e.g Friends from UK', ), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), _members.isNotEmpty ? const Text('Members Added') : Container(), @@ -194,7 +196,8 @@ class _AddGroupViewState extends State { )), ) : Container(), - SizedBox(height: _members.isNotEmpty ? 10.0 : 0.0), + SizedBox( + height: _members.isNotEmpty ? _size.height * 0.012 : 0.0), ListTile( leading: const Icon(Icons.person_add), title: const Text('Add a member'), @@ -204,9 +207,9 @@ class _AddGroupViewState extends State { }); }, ), - SizedBox(height: _addMember ? 10.0 : 0.0), + SizedBox(height: _addMember ? _size.height * 0.012 : 0.0), _addMember ? const Text('Contacts Available') : Container(), - SizedBox(height: _addMember ? 10.0 : 0.0), + SizedBox(height: _addMember ? _size.height * 0.012 : 0.0), _addMember ? ListView( physics: const NeverScrollableScrollPhysics(), @@ -227,7 +230,7 @@ class _AddGroupViewState extends State { ), ) : Container(), - const Divider(height: 30.0), + Divider(height: _size.height * 0.035), ListTile( leading: CircleAvatar( backgroundImage: _userPhotoPath == '' diff --git a/packages/simplex_app/lib/views/home/drawer.dart b/packages/simplex_app/lib/views/home/drawer.dart index e59b82d66..24ed46210 100644 --- a/packages/simplex_app/lib/views/home/drawer.dart +++ b/packages/simplex_app/lib/views/home/drawer.dart @@ -10,41 +10,38 @@ class MyDrawer extends StatelessWidget { @override Widget build(BuildContext context) { final _drawerProviders = Provider.of(context); - return SizedBox( - width: MediaQuery.of(context).size.width * 0.82, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Builder(builder: (context) { - return Column( - children: [ - const SizedBox(height: 30.0), - SvgPicture.asset( - 'assets/logo.svg', - height: 55.0, + return Padding( + padding: const EdgeInsets.all(10.0), + child: Builder(builder: (context) { + return Column( + children: [ + const SizedBox(height: 30.0), + SvgPicture.asset( + 'assets/logo.svg', + height: 55.0, + ), + const Divider(height: 30.0), + ListTile( + leading: const Icon(Icons.insert_invitation), + title: const Text('Invitations'), + onTap: () { + _drawerProviders.currentIndex = 2; + Navigator.pop(context); + }, + ), + const Spacer(), + ListTile( + leading: const Icon(Icons.refresh), + title: const Text('Switch Profile'), + subtitle: const Text( + 'Not supported yet!', + style: TextStyle(fontStyle: FontStyle.italic), ), - const Divider(height: 30.0), - ListTile( - leading: const Icon(Icons.insert_invitation), - title: const Text('Invitations'), - onTap: () { - _drawerProviders.currentIndex = 2; - Navigator.pop(context); - }, - ), - const Spacer(), - ListTile( - leading: const Icon(Icons.refresh), - title: const Text('Switch Profile'), - subtitle: const Text( - 'Not supported yet!', - style: TextStyle(fontStyle: FontStyle.italic), - ), - onTap: () => _switchProfile(context), - ), - ], - ); - }), - ), + onTap: () => _switchProfile(context), + ), + ], + ); + }), ); } diff --git a/packages/simplex_app/lib/views/home/home_view.dart b/packages/simplex_app/lib/views/home/home_view.dart index 0e770e6d5..c64cd88df 100644 --- a/packages/simplex_app/lib/views/home/home_view.dart +++ b/packages/simplex_app/lib/views/home/home_view.dart @@ -53,9 +53,7 @@ class _HomeViewState extends State { return WillPopScope( onWillPop: _onWillPop, child: Scaffold( - drawer: const Drawer( - child: MyDrawer(), - ), + drawer: const Drawer(child: MyDrawer()), body: SafeArea( child: Builder(builder: (context) { return Stack( diff --git a/packages/simplex_app/lib/views/profile/profile_view.dart b/packages/simplex_app/lib/views/profile/profile_view.dart index f35f7b5dc..c72cdcf97 100644 --- a/packages/simplex_app/lib/views/profile/profile_view.dart +++ b/packages/simplex_app/lib/views/profile/profile_view.dart @@ -63,6 +63,7 @@ class _ProfileViewState extends State { @override Widget build(BuildContext context) { + Size _size = MediaQuery.of(context).size; return Scaffold( body: GestureDetector( onTap: () => FocusScope.of(context).unfocus(), @@ -75,7 +76,7 @@ class _ProfileViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const SizedBox(height: 30), + SizedBox(height: _size.height * 0.05), Center( child: SizedBox( height: 180.0, @@ -119,7 +120,7 @@ class _ProfileViewState extends State { ], ), )), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.035), const Text('Display Name', style: kSmallHeadingStyle), const SizedBox(height: 10.0), CustomTextField( @@ -133,15 +134,15 @@ class _ProfileViewState extends State { return null; }, ), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.035), const Text('Full Name', style: kSmallHeadingStyle), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.012), CustomTextField( textEditingController: _fullNameController, textInputType: TextInputType.name, hintText: 'e.g John Doe', ), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.035), const Text( 'Your display name is what your contact will know you :)', style: TextStyle(letterSpacing: 1.2), @@ -186,6 +187,7 @@ class _ProfileViewState extends State { } void _updateProfilePic() { + Size _size = MediaQuery.of(context).size; showModalBottomSheet( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( @@ -206,7 +208,7 @@ class _ProfileViewState extends State { height: 7.0, width: 50.0, ), - const SizedBox(height: 20.0), + SizedBox(height: _size.height * 0.025), const Align( alignment: Alignment.centerLeft, child: Text( @@ -214,7 +216,7 @@ class _ProfileViewState extends State { style: kHeadingStyle, ), ), - const SizedBox(height: 15.0), + SizedBox(height: _size.height * 0.015), Row( children: List.generate( 3, diff --git a/packages/simplex_app/lib/views/scan_invitation/scan_invitation_view.dart b/packages/simplex_app/lib/views/scan_invitation/scan_invitation_view.dart index 85870a1b8..454d94097 100644 --- a/packages/simplex_app/lib/views/scan_invitation/scan_invitation_view.dart +++ b/packages/simplex_app/lib/views/scan_invitation/scan_invitation_view.dart @@ -8,6 +8,7 @@ class ScanInvitationView extends StatelessWidget { @override Widget build(BuildContext context) { + Size _size = MediaQuery.of(context).size; return Scaffold( backgroundColor: Colors.white, appBar: AppBar( @@ -24,23 +25,23 @@ class ScanInvitationView extends StatelessWidget { style: kMediumHeadingStyle, textAlign: TextAlign.center, ), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.04), GestureDetector( onTap: () => _showConnection(context), child: Image.asset( 'assets/code.png', ), ), - const SizedBox(height: 25.0), + SizedBox(height: _size.height * 0.04), const Text( 'If you cannot share your QR Code, send the invitation via a trusted method.', style: kMediumHeadingStyle, textAlign: TextAlign.center, ), - const SizedBox(height: 30.0), + SizedBox(height: _size.height * 0.04), CustomButton( - width: 200.0, - height: 45.0, + width: _size.width * 0.5, + height: _size.height * 0.055, onPressed: _shareLink, color: kPrimaryColor, child: Row( @@ -63,29 +64,31 @@ class ScanInvitationView extends StatelessWidget { } void _showConnection(BuildContext context) { + Size _size = MediaQuery.of(context).size; showDialog( context: context, builder: (context) => AlertDialog( content: Column( mainAxisSize: MainAxisSize.min, children: [ - const CircleAvatar( - backgroundImage: AssetImage('assets/dp.png'), - radius: 70, + CircleAvatar( + backgroundImage: const AssetImage('assets/dp.png'), + radius: _size.height * 0.085, ), - const SizedBox(height: 30.0), + SizedBox(height: _size.height * 0.045), const Text( 'Bob wants to connect with you!', style: kMediumHeadingStyle, textAlign: TextAlign.center, ), - const SizedBox(height: 30.0), + SizedBox(height: _size.height * 0.045), CustomButton( - width: 200, - height: 40, + width: _size.width * 0.5, + height: _size.height * 0.055, onPressed: () { - int _count = 0; - Navigator.popUntil(context, (route) => _count++ >= 2); + // work around for now + Navigator.pop(context); + Navigator.of(context).pop(true); }, color: kPrimaryColor, child: const Text( @@ -93,10 +96,10 @@ class ScanInvitationView extends StatelessWidget { style: TextStyle(color: Colors.white), ), ), - const SizedBox(height: 10.0), + SizedBox(height: _size.height * 0.013), CustomButton( - width: 200, - height: 40, + width: _size.width * 0.5, + height: _size.height * 0.055, onPressed: () { int _count = 0; Navigator.popUntil(context, (route) => _count++ >= 2); @@ -107,8 +110,6 @@ class ScanInvitationView extends StatelessWidget { style: TextStyle(color: Colors.white), ), ), - const SizedBox(height: 20.0), - const Text('Invitation was sent HH:MM') ], ), ),