Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enable user sharing #248

Merged
merged 6 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ PODS:
- Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_qr_reader (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
Expand Down Expand Up @@ -124,6 +126,7 @@ DEPENDENCIES:
- flutter_image_compress (from `.symlinks/plugins/flutter_image_compress/ios`)
- flutter_keychain (from `.symlinks/plugins/flutter_keychain/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_qr_reader (from `.symlinks/plugins/flutter_qr_reader/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- open_file (from `.symlinks/plugins/open_file/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
Expand Down Expand Up @@ -177,6 +180,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_keychain/ios"
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_qr_reader:
:path: ".symlinks/plugins/flutter_qr_reader/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
open_file:
Expand Down
4 changes: 3 additions & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B1C35B7369486DE1AB7F3C72 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CEC2126E28ED3F5B003334BE /* RunnerDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerDebug.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -162,6 +163,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
CEC2126E28ED3F5B003334BE /* RunnerDebug.entitlements */,
0372945E251A082B0081BDCF /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
Expand Down Expand Up @@ -707,7 +709,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52;
Expand Down
14 changes: 14 additions & 0 deletions ios/Runner/RunnerDebug.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.atsign.atmosphere-pro</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)@atsigns:shared</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:typed_data';

import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_common_flutter/services/size_config.dart';
import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart';
import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart';
import 'package:atsign_atmosphere_pro/services/backend_service.dart';
Expand All @@ -9,10 +10,12 @@ import 'package:atsign_atmosphere_pro/services/navigation_service.dart';
import 'package:atsign_atmosphere_pro/utils/colors.dart';
import 'package:atsign_atmosphere_pro/utils/text_strings.dart';
import 'package:atsign_atmosphere_pro/utils/text_styles.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DesktopSwitchAtsign extends StatefulWidget {
String atsign;

DesktopSwitchAtsign({Key? key, required this.atsign}) : super(key: key);

@override
Expand All @@ -25,12 +28,15 @@ class _DesktopSwitchAtsignState extends State<DesktopSwitchAtsign> {
var atClientPrefernce;
AtClient atClient = AtClientManager.getInstance().atClient;
String? atsignName = '';
bool enableShareStSign = false;
final KeyChainManager _keyChainManager = KeyChainManager.getInstance();

@override
void initState() {
if (widget.atsign == atClient.getCurrentAtSign()) {
isCurrentAtsign = true;
}
getShareAtSign();
getAtsignDetails();
super.initState();
}
Expand All @@ -40,12 +46,20 @@ class _DesktopSwitchAtsignState extends State<DesktopSwitchAtsign> {
setState(() {});
}

void getShareAtSign() async {
enableShareStSign =
await _keyChainManager.isUsingSharedStorage() ?? false;
setState(() {});
}

@override
Widget build(BuildContext context) {
if (widget.atsign == TextStrings().addNewAtsign) {
return addNewContactRow();
} else if (widget.atsign == TextStrings().saveBackupKey) {
return saveBackupKeyRow();
} else if (widget.atsign == TextStrings().sharingAtSign) {
return sharingAtSignRow();
} else {
return _contactRow(widget.atsign, atsignName ?? '',
isCurrentAtsign: isCurrentAtsign);
Expand Down Expand Up @@ -182,4 +196,54 @@ class _DesktopSwitchAtsignState extends State<DesktopSwitchAtsign> {
],
);
}

Widget sharingAtSignRow() {
return Column(
children: [
Divider(height: 1),
SizedBox(
height: 50,
width: SizeConfig().screenWidth,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(Icons.share_outlined, size: 25),
SizedBox(width: 10),
Expanded(
child: Text(
'Sharing atSign',
softWrap: true,
style: TextStyle(
color: ColorConstants.fadedText,
letterSpacing: 0.1,
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
),
Transform.scale(
alignment: Alignment.center,
scale: 0.7,
child: CupertinoSwitch(
activeColor: ColorConstants.orangeColor,
value: enableShareStSign,
onChanged: (value) {
if (value) {
_keyChainManager.enableUsingSharedStorage();
} else {
_keyChainManager.disableUsingSharedStorage();
}

setState(() {
enableShareStSign = value;
});
},
),
),
],
),
),
],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class _DesktopWelcomeScreenStartState extends State<DesktopWelcomeScreenStart> {
popupMenuList.add(TextStrings()
.addNewAtsign); //to show add option in switch atsign drop down menu.
popupMenuList.add(TextStrings().saveBackupKey);
popupMenuList.add(TextStrings().sharingAtSign);
return popupMenuList;
}

Expand Down Expand Up @@ -172,10 +173,15 @@ class _DesktopWelcomeScreenStartState extends State<DesktopWelcomeScreenStart> {
getPopupMenuItem(List<String> list) {
List<PopupMenuItem<String>> menuItems = [];
list.forEach((element) {
menuItems.add(PopupMenuItem(
value: element,
child: DesktopSwitchAtsign(key: Key(element), atsign: element),
));
menuItems.add(
PopupMenuItem(
value: element,
child: DesktopSwitchAtsign(
key: Key(element),
atsign: element,
),
),
);
});

return menuItems;
Expand All @@ -198,6 +204,8 @@ class _DesktopWelcomeScreenStartState extends State<DesktopWelcomeScreenStart> {
BackupKeyWidget(
atsign: AtClientManager.getInstance().atClient.getCurrentAtSign()!,
).showBackupDialog(context);
} else if (selectedOption == TextStrings().sharingAtSign) {
return;
} else if (selectedOption !=
AtClientManager.getInstance().atClient.getCurrentAtSign()) {
await CustomOnboarding.onboard(
Expand Down
1 change: 1 addition & 0 deletions lib/screens/common_widgets/custom_onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CustomOnboarding {
domain: MixedConstants.ROOT_DOMAIN,
rootEnvironment: RootEnvironment.Production,
appAPIKey: MixedConstants.ONBOARD_API_KEY,
showPopupSharedStorage: true,
),
isSwitchingAtsign: !isInit,
atsign: atSign);
Expand Down
59 changes: 59 additions & 0 deletions lib/screens/common_widgets/side_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,24 @@ class _SideBarWidgetState extends State<SideBarWidget> {
buildNumber: 'Unknown',
);

bool enableShareStSign = false;
final KeyChainManager _keyChainManager = KeyChainManager.getInstance();

@override
void initState() {
getShareAtSign();
super.initState();

isExpanded = widget.isExpanded;
getAtsignDetails();
_initPackageInfo();
}

void getShareAtSign() async {
enableShareStSign = await _keyChainManager.isUsingSharedStorage() ?? false;
setState(() {});
}

Future<void> _initPackageInfo() async {
final PackageInfo info = await PackageInfo.fromPlatform();
if (mounted) {
Expand Down Expand Up @@ -358,6 +367,56 @@ class _SideBarWidgetState extends State<SideBarWidget> {
showIconOnly: !isExpanded,
),
SizedBox(height: isTablet ? 20.toHeight : 0),
SizedBox(
height: 50,
width: SizeConfig().screenWidth,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(
right: 10.toWidth,
),
child: Icon(
Icons.share_outlined,
size: 25,
color: ColorConstants.fadedText,
),
),
Expanded(
child: Text(
'Sharing atSign',
style: TextStyle(
color: ColorConstants.fadedText,
letterSpacing: 0.1,
fontSize: 13.toFont,
fontWeight: FontWeight.normal,
),
),
),
Transform.scale(
alignment: Alignment.center,
scale: 0.7,
child: CupertinoSwitch(
activeColor: ColorConstants.orangeColor,
value: enableShareStSign,
onChanged: (value) {
if (value) {
_keyChainManager.enableUsingSharedStorage();
} else {
_keyChainManager.disableUsingSharedStorage();
}

setState(() {
enableShareStSign = value;
});
},
),
),
],
),
),
SizedBox(height: isTablet ? 20.toHeight : 0),
InkWell(
onTap: () async {
CommonUtilityFunctions().showResetAtsignDialog();
Expand Down
2 changes: 2 additions & 0 deletions lib/services/backend_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ class BackendService {
domain: MixedConstants.ROOT_DOMAIN,
rootEnvironment: RootEnvironment.Production,
appAPIKey: MixedConstants.ONBOARD_API_KEY,
showPopupSharedStorage: true,
),
);
switch (result.status) {
Expand Down Expand Up @@ -489,6 +490,7 @@ class BackendService {
domain: MixedConstants.ROOT_DOMAIN,
rootEnvironment: RootEnvironment.Production,
appAPIKey: MixedConstants.ONBOARD_API_KEY,
showPopupSharedStorage: true,
),
isSwitchingAtsign: isSwitchAccount,
);
Expand Down
1 change: 1 addition & 0 deletions lib/utils/text_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class TextStrings {
// desktop text constants
String addNewAtsign = 'add_new_atsign';
String saveBackupKey = 'save_backup_key';
String sharingAtSign = 'sharing_at_sign';
String contactSelectionConfirmation =
'Your contact selection will be cleared if you leave this screen. Would you like to continue with your new action?';

Expand Down
Loading