diff --git a/packages/simplex_app/lib/app_routes.dart b/packages/simplex_app/lib/app_routes.dart index 070dc528e4..b57678b145 100644 --- a/packages/simplex_app/lib/app_routes.dart +++ b/packages/simplex_app/lib/app_routes.dart @@ -4,7 +4,9 @@ class AppRoutes { static const splash = '/splash'; static const intro = '/intro'; static const setupProfile = '/setupProfile'; + static const home = '/home'; static const addContact = '/addContact'; + static const addContactWeb = '/addContactWeb'; static const scanInvitation = '/ScanInvitation'; static const addGroup = '/addGroup'; } diff --git a/packages/simplex_app/lib/main.dart b/packages/simplex_app/lib/main.dart index 0ef1a665d9..e0861e8bd4 100644 --- a/packages/simplex_app/lib/main.dart +++ b/packages/simplex_app/lib/main.dart @@ -6,17 +6,21 @@ import 'package:simplex_chat/constants.dart'; import 'package:simplex_chat/custom_scroll_behavior.dart'; import 'package:simplex_chat/providers/drawer_providers.dart'; import 'package:simplex_chat/views/contacts/add_contact_view.dart'; +import 'package:simplex_chat/views/contacts/add_contact_web.dart'; import 'package:simplex_chat/views/group/add_group_view.dart'; +import 'package:simplex_chat/views/home/home_view.dart'; import 'package:simplex_chat/views/onboarding/intro_view.dart'; import 'package:simplex_chat/views/scan_invitation/scan_invitation_view.dart'; import 'package:simplex_chat/views/setup_profile_view.dart'; import 'package:simplex_chat/views/splash_screen.dart'; +import 'package:url_strategy/url_strategy.dart'; /// Basic Structure is setup on [Providers] /// Navigations are [namedRoutes] void main() { WidgetsFlutterBinding.ensureInitialized(); + setPathUrlStrategy(); runApp(const MyApp()); } @@ -50,7 +54,9 @@ class MyApp extends StatelessWidget { AppRoutes.splash: (_) => const SplashScreen(), AppRoutes.intro: (_) => const IntroView(), AppRoutes.setupProfile: (_) => const SetupProfileView(), + AppRoutes.home: (_) => const HomeView(), AppRoutes.addContact: (_) => const AddContactView(), + AppRoutes.addContactWeb: (_) => const AddContactWeb(), AppRoutes.scanInvitation: (_) => const ScanInvitationView(), AppRoutes.addGroup: (_) => const AddGroupView(), }, diff --git a/packages/simplex_app/lib/views/contacts/add_contact_web.dart b/packages/simplex_app/lib/views/contacts/add_contact_web.dart new file mode 100644 index 0000000000..b3953ca208 --- /dev/null +++ b/packages/simplex_app/lib/views/contacts/add_contact_web.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; +import 'package:qr_code_scanner/qr_code_scanner.dart'; + +class AddContactWeb extends StatefulWidget { + const AddContactWeb({Key? key}) : super(key: key); + + @override + _AddContactWebState createState() => _AddContactWebState(); +} + +class _AddContactWebState extends State { + bool? _dontShow = false; + + // alert dialgoue + void _initialWarning() { + showDialog( + context: context, + builder: (context) => StatefulBuilder( + builder: (context, setState) => AlertDialog( + title: const Text('Are you Sure?'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Your profile will be sent to your contact!'), + const SizedBox(height: 15.0), + Row( + children: [ + Checkbox( + value: _dontShow, + onChanged: (value) { + setState(() { + _dontShow = value; + }); + }), + const Text("Don't ask again") + ], + ), + ], + ), + actions: [ + InkWell( + onTap: () => Navigator.pop(context), + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Icon(Icons.check, color: Colors.green), + ), + ), + InkWell( + onTap: () => Navigator.pop(context), + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Icon(Icons.cancel_outlined, color: Colors.red), + ), + ) + ], + ), + ), + ); + } + + void _intiBox() { + Future.delayed(const Duration(seconds: 1), _initialWarning); + } + + @override + void initState() { + _intiBox(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: const Text('Add Contact'), + ), + body: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + Center( + child: GestureDetector( + onTap: () => Navigator.of(context).pop(true), + child: Container( + padding: const EdgeInsets.all(5.0), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.red, + width: 5.0, + ), + ), + child: Image.asset('assets/code.png')), + ), + ), + Positioned( + top: MediaQuery.of(context).size.height * 0.15, + left: MediaQuery.of(context).size.width * 0.41, + child: const Text( + 'Position QR Code within the frame.', + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 18.0, + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/packages/simplex_app/lib/views/contacts/conversations.dart b/packages/simplex_app/lib/views/contacts/conversations.dart index 2269ddd703..39d6cbf785 100644 --- a/packages/simplex_app/lib/views/contacts/conversations.dart +++ b/packages/simplex_app/lib/views/contacts/conversations.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:simplex_chat/animations/bottom_animation.dart'; @@ -32,6 +33,7 @@ class _ConversationsState extends State { // getting data from local storage FOR NOW!! void _getContacts() async { + debugPrint('Getting contacts!'); SharedPreferences prefs = await SharedPreferences.getInstance(); final String? _contacts = prefs.getString('contacts'); if (_contacts != null) { @@ -43,6 +45,7 @@ class _ConversationsState extends State { // getting data from local storage FOR NOW!! void _getGroups() async { + debugPrint('Getting groups!'); SharedPreferences prefs = await SharedPreferences.getInstance(); final String? _groups = prefs.getString('groups'); if (_groups != null) { @@ -55,6 +58,7 @@ class _ConversationsState extends State { } void _gettingGroupContactsChats() { + debugPrint('Merging!'); setState(() { _conversations = List.from(_contactsList); _conversations = _conversations + _groupList; @@ -188,8 +192,8 @@ class _ConversationsState extends State { _addNewMember(); } } else if (value == _options[1]) { - var newMember = - await Navigator.pushNamed(context, AppRoutes.addContact); + var newMember = await Navigator.pushNamed(context, + kIsWeb ? AppRoutes.addContactWeb : AppRoutes.addContact); newMember ??= false; if (newMember == true) { _addNewMember(); @@ -432,6 +436,7 @@ class _ConversationsState extends State { _getContacts(); _getGroups(); + const snackBar = SnackBar( backgroundColor: Colors.green, content: Text('New contacts loaded!'), diff --git a/packages/simplex_app/lib/views/home/home_view.dart b/packages/simplex_app/lib/views/home/home_view.dart index c64cd88dff..c747c7f7af 100644 --- a/packages/simplex_app/lib/views/home/home_view.dart +++ b/packages/simplex_app/lib/views/home/home_view.dart @@ -15,8 +15,7 @@ import 'package:simplex_chat/views/profile/profile_view.dart'; /// Generate [Fake Contacts] by tapping the [Bug Icon] class HomeView extends StatefulWidget { - final double maxSlide; - const HomeView({Key? key, required this.maxSlide}) : super(key: key); + const HomeView({Key? key}) : super(key: key); @override _HomeViewState createState() => _HomeViewState(); @@ -105,6 +104,7 @@ class _HomeViewState extends State { _drawerProviders.currentIndex = 0; }, child: CircleAvatar( + backgroundColor: Colors.white, backgroundImage: _photo!.isEmpty ? const AssetImage('assets/dp.png') as ImageProvider diff --git a/packages/simplex_app/lib/views/onboarding/intro_view.dart b/packages/simplex_app/lib/views/onboarding/intro_view.dart index aabd4ece32..edaa125f45 100644 --- a/packages/simplex_app/lib/views/onboarding/intro_view.dart +++ b/packages/simplex_app/lib/views/onboarding/intro_view.dart @@ -20,7 +20,7 @@ class IntroView extends StatelessWidget { 'assets/logo.svg', height: 80.0, ), - const SizedBox(height: 50.0), + SizedBox(height: MediaQuery.of(context).size.height * 0.05), const Text( 'Complete your profile to begin using SimpleX. Your profile is local to your device and will help identify you to your connections.', style: kMediumHeadingStyle, diff --git a/packages/simplex_app/lib/views/profile/profile_view.dart b/packages/simplex_app/lib/views/profile/profile_view.dart index c72cdcf973..918c81c045 100644 --- a/packages/simplex_app/lib/views/profile/profile_view.dart +++ b/packages/simplex_app/lib/views/profile/profile_view.dart @@ -85,10 +85,12 @@ class _ProfileViewState extends State { children: [ _photo != '' ? CircleAvatar( + backgroundColor: Colors.white, radius: 100.0, backgroundImage: FileImage(File(_photo!)), ) : const CircleAvatar( + backgroundColor: Colors.white, radius: 100.0, backgroundImage: AssetImage('assets/dp.png'), ), diff --git a/packages/simplex_app/lib/views/setup_profile_view.dart b/packages/simplex_app/lib/views/setup_profile_view.dart index 6e8763d808..508bd5577d 100644 --- a/packages/simplex_app/lib/views/setup_profile_view.dart +++ b/packages/simplex_app/lib/views/setup_profile_view.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:simplex_chat/app_routes.dart'; import 'package:simplex_chat/constants.dart'; import 'package:simplex_chat/views/home/home_view.dart'; import 'package:simplex_chat/widgets/custom_text_field.dart'; @@ -62,10 +63,12 @@ class _SetupProfileViewState extends State { children: [ _imageUploaded ? CircleAvatar( + backgroundColor: Colors.white, radius: 100.0, backgroundImage: FileImage(image!), ) : const CircleAvatar( + backgroundColor: Colors.white, radius: 100.0, backgroundImage: AssetImage('assets/dp.png'), ), @@ -141,14 +144,7 @@ class _SetupProfileViewState extends State { await _createProfile(); - await Navigator.push( - context, - MaterialPageRoute( - builder: (_) => HomeView( - maxSlide: MediaQuery.of(context).size.width * 0.82, - ), - ), - ); + await Navigator.pushNamed(context, AppRoutes.home); _displayNameController.clear(); _fullNameController.clear(); diff --git a/packages/simplex_app/pubspec.lock b/packages/simplex_app/pubspec.lock index 178881eaa9..4a987f9a8e 100644 --- a/packages/simplex_app/pubspec.lock +++ b/packages/simplex_app/pubspec.lock @@ -434,6 +434,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_strategy: + dependency: "direct dev" + description: + name: url_strategy + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" vector_math: dependency: transitive description: diff --git a/packages/simplex_app/pubspec.yaml b/packages/simplex_app/pubspec.yaml index 924e171962..0be2710fcb 100644 --- a/packages/simplex_app/pubspec.yaml +++ b/packages/simplex_app/pubspec.yaml @@ -64,6 +64,7 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^1.0.0 flutter_launcher_icons: ^0.9.2 + url_strategy: ^0.2.0 flutter_icons: image_path: "assets/x.png"