Skip to content

Commit

Permalink
Merge pull request #248 from atsign-foundation/feature/enable-user-sh…
Browse files Browse the repository at this point in the history
…aring

Feature/enable user sharing
  • Loading branch information
sachins-geekyants authored Apr 28, 2023
2 parents 8638fe8 + f68db4f commit 6cd9f81
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,27 @@ class DesktopSettingsPage extends StatefulWidget {
}

class _DesktopSettingsPageState extends State<DesktopSettingsPage> {
bool enableShareStSign = false;
final KeyChainManager _keyChainManager = KeyChainManager.getInstance();

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

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

@override
Widget build(BuildContext context) {
final appTheme = AppTheme.of(context);
final isPrivateAccount =
Provider.of<UserProvider>(context).user?.allPrivate ?? false;
final isUpdating = Provider.of<SetPrivateState>(context).isLoading;

return Container(
width: DesktopDimens.sideMenuWidth,
color: appTheme.backgroundColor,
Expand All @@ -55,6 +70,23 @@ class _DesktopSettingsPageState extends State<DesktopSettingsPage> {
}
},
),
DesktopSettingSwitchWidget(
prefixIcon: Icons.share_outlined,
title: "Sharing atSign",
isOn: enableShareStSign,
isUpdating: false,
onChanged: (check) async {
if (check) {
_keyChainManager.enableUsingSharedStorage();
} else {
_keyChainManager.disableUsingSharedStorage();
}

setState(() {
enableShareStSign = check;
});
},
),
// DesktopSettingSwitchWidget(
// prefixIcon: Icons.remove_red_eye_rounded,
// title: "Exclude your @wavi from search results",
Expand Down
55 changes: 54 additions & 1 deletion lib/screens/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class _OptionsState extends State<Options> {
bool _allPrivate = false;
late User _user;
ThemeData? _themeData;
bool enableShareStSign = false;
final KeyChainManager _keyChainManager = KeyChainManager.getInstance();

@override
void initState() {
Expand All @@ -47,12 +49,17 @@ class _OptionsState extends State<Options> {
Color.fromARGB(255, 0, 183, 184);
follows_color_constants.ColorConstants.darkTheme = false;
//

getShareAtSign();
updateAllPrivateKey();
_getThemeData();
super.initState();
}

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

_getThemeData() async {
_themeData =
await Provider.of<ThemeProvider>(context, listen: false).getTheme();
Expand Down Expand Up @@ -94,6 +101,52 @@ class _OptionsState extends State<Options> {
),
SizedBox(height: 15.toHeight),
Divider(height: 1),
SizedBox(
height: 38,
width: SizeConfig().screenWidth,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0.0, 13.0, 0.0, 0.0),
child: Icon(Icons.share_outlined, size: 25),
),
Expanded(
child: Padding(
padding: EdgeInsets.fromLTRB(8.0, 15.0, 0.0, 0.0),
child: Text(
'Sharing atSign',
style: TextStyles.lightText(_themeData!.primaryColor),
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(8.0, 15.0, 0.0, 0.0),
child: Transform.scale(
alignment: Alignment.center,
scale: 0.7,
child: CupertinoSwitch(
activeColor: WaviColors.ColorConstants.black,
value: enableShareStSign,
onChanged: (value) async {
if (value) {
_keyChainManager.enableUsingSharedStorage();
} else {
_keyChainManager.disableUsingSharedStorage();
}

setState(() {
enableShareStSign = value;
});
},
),
),
),
],
),
),
SizedBox(height: 15.toHeight),
Divider(height: 1),
SizedBox(height: 15.toHeight),
InkWell(
onTap: () {
Expand Down
2 changes: 2 additions & 0 deletions lib/services/backend_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_contacts_flutter/utils/init_contacts_service.dart';
import 'package:at_onboarding_flutter/at_onboarding_flutter.dart';
import 'package:at_onboarding_flutter/services/onboarding_service.dart';
Expand Down Expand Up @@ -86,6 +87,7 @@ class BackendService {
).highlightColor ??
ColorConstants.green,
),
showPopupSharedStorage: true,
),
isSwitchingAtsign: isSwitchAccount,
atsign: atSign,
Expand Down
Loading

0 comments on commit 6cd9f81

Please sign in to comment.