Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/avin/master' into dev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
obrasero committed Aug 9, 2021
2 parents 292589b + 023447a commit 4c1617e
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 138 deletions.
2 changes: 1 addition & 1 deletion lib/common/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Widget drawerWidget(BuildContext ctx) {
children: [
Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(top:15),
margin: const EdgeInsets.only(top:2),
height: MediaQuery.of(ctx).size.height * .3,
child: Center(
child: Consumer<Identities>(builder: (context, curr, _) {
Expand Down
22 changes: 12 additions & 10 deletions lib/provider/Idenity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Identities with ChangeNotifier {
setAuthToken(AuthToken authToken) async {
_authToken = authToken;
}

List<Identity> get ownIdentity => _ownidentities;
Identity _currentIdentity;
Identity get currentIdentity => _currentIdentity;
Expand Down Expand Up @@ -65,19 +66,20 @@ class Identities with ChangeNotifier {
}
}

Future<bool> updateIdentity(Identity id, RsGxsImage avatar) async {
Future<void> updateIdentity(Identity id, RsGxsImage avatar) async {
bool success = await updateApiIdentity(id, avatar, _authToken);
if (success) {
for (var i in _ownidentities) {
if (i.mId == id.mId) {
i = id;
break;
}

if (!success) throw "Try Again";

for (var i in _ownidentities) {
if (i.mId == id.mId) {
i = id;
break;
}
_currentIdentity = id;
_selected = _currentIdentity;
notifyListeners();
}
_currentIdentity = id;
_selected = _currentIdentity;
notifyListeners();
}

Future<void> callrequestIdentity(Identity unknownId) async {
Expand Down
21 changes: 9 additions & 12 deletions lib/provider/friend_location.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:retroshare/model/auth.dart';
import 'package:retroshare/model/http_exception.dart';
import 'package:retroshare/model/location.dart';
import 'package:retroshare/services/account.dart';
import 'package:retroshare/services/identity.dart';
Expand All @@ -19,17 +20,13 @@ class FriendLocations with ChangeNotifier {

Future<void> addFriendLocation(String name) async {
bool isAdded = false;
try {
if (name != null && name.length < 100)
isAdded = await parseShortInvite(name, _authToken);
else
isAdded = await addCert(name, _authToken);
if (isAdded) {
setAutoAddFriendIdsAsContact(true, _authToken);
fetchfriendLocation();
}
} catch (e) {
throw e;
}
if (name != null && name.length < 100)
isAdded = await parseShortInvite(name, _authToken);
else
isAdded = await addCert(name, _authToken);

if (!isAdded) throw HttpException("WRONG Certi");
setAutoAddFriendIdsAsContact(true, _authToken);
fetchfriendLocation();
}
}
18 changes: 14 additions & 4 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
Expand Down Expand Up @@ -210,10 +211,7 @@ Future<Location> getLocationsDetails(String peerId, AuthToken authToken) async {
);

if (response.statusCode == 200) {
print(response.body);
var det = json.decode(response.body)['det'];

await addFriend(peerId, det['gpg_id'], authToken);
return Location(
det['id'],
det['gpg_id'],
Expand All @@ -237,9 +235,21 @@ Future<bool> addFriend(String sslId, String gpgId, AuthToken authToken) async {
},
body: json.encode({'sslId': sslId, 'gpgId': gpgId}),
);

if (response.statusCode == 200) {
print(response.body);

} else {
throw Exception('Failed to load response');
}
}

Future<void> peerDetails(String sslId, AuthToken authToken) async {
final response = await http.post(
'http://localhost:9092/rsPeers/getPeerDetails',
headers: {
HttpHeaders.authorizationHeader:
'Basic ' + base64.encode(utf8.encode('$authToken'))
},
body: json.encode({'sslId': sslId}),
);
}
5 changes: 0 additions & 5 deletions lib/services/forum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Future<List<RsMsgMetaData>> getForumMsgMetaData(
final response = await rsApiCall(
'/rsGxsForums/getForumMsgMetaData', authToken,
params: {'forumId': forumId});
print(response);
if (response['retval'] != true) {
throw Exception('Could not retrieve messages metadata');
}
Expand Down Expand Up @@ -175,7 +174,3 @@ String publishTs(Map post) {
return pts;
}

/*Future<void> getForumServiceStatistics(AuthToken authToken) async {
final response = await rsApiCall('/rsGxsForums/subscribeToForum', authToken);
print(response);
}*/
6 changes: 1 addition & 5 deletions lib/services/identity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Future<bool> deleteIdentity(Identity identity, AuthToken authToken) async {
if (json.decode(response.body)['retval']) return true;
return false;
}

throw Exception('Failed to load response');
}

Expand Down Expand Up @@ -152,7 +152,6 @@ dynamic getAllIdentities(AuthToken authToken) async {

if (response.statusCode == 200) {
List<String> ids = [];
print(json.decode(response.body)['ids'].length);
json.decode(response.body)['ids'].forEach((id) {
ids.add(id['mGroupId']);
});
Expand Down Expand Up @@ -212,9 +211,6 @@ dynamic getAllIdentities(AuthToken authToken) async {
notContactIds.sort((id1, id2) {
return id1.name.compareTo(id2.name);
});
print("checks");
print(signedContactIds.length);
print(contactIds.length);
return Tuple3<List<Identity>, List<Identity>, List<Identity>>(
signedContactIds, contactIds, notContactIds);
}
Expand Down
31 changes: 19 additions & 12 deletions lib/ui/Qr_scanner_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:oktoast/oktoast.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -117,18 +116,26 @@ class _QRScannerState extends State<QRScanner>
try {
barcode = await scanner.scan();
if (barcode != null) {
Provider.of<FriendLocations>(context, listen: false)
.addFriendLocation(barcode).then((value) {
Fluttertoast.showToast(
msg: "Friend has been added",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
});
bool success = false;
await Provider.of<FriendLocations>(context, listen: false)
.addFriendLocation(barcode)
.then((value) {
setState(() {
_requestQR = false;
});
showToast('Friend has successfully added');
});
}
else {
showToast('An error occurred while adding your friend.');
}

}on HttpException catch(e){
setState(() {
_requestQR = false;
});
showToast('An error occurred while adding your friend.');

} catch (e) {
setState(() {
_requestQR = false;
Expand Down
29 changes: 11 additions & 18 deletions lib/ui/Update_idenity_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,17 @@ class _UpdateIdentityScreenState extends State<UpdateIdentityScreen> {

@override
Widget build(BuildContext context) {
// Request create identity
void _updateIdentity() async {
bool success = await Provider.of<Identities>(context, listen: false)
try{
await Provider.of<Identities>(context, listen: false)
.updateIdentity(
Identity(widget.curr.mId, widget.curr.signed, nameController.text,
_image?.base64String),
_image);
if (success)
Navigator.pop(context);
else {
setState(() {
_requestCreateIdentity = false;
});
_image)
.then((value) {
Navigator.pop(context);
});
}catch(e){
showDialog(
context: context,
builder: (BuildContext context) {
Expand All @@ -79,14 +77,9 @@ class _UpdateIdentityScreenState extends State<UpdateIdentityScreen> {
);
},
);
}
}

return WillPopScope(
onWillPop: () {
return Future.value(true);
},
child: Scaffold(
}}

return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
top: true,
Expand Down Expand Up @@ -338,7 +331,7 @@ class _UpdateIdentityScreenState extends State<UpdateIdentityScreen> {
],
),
),
),

);
}
}
57 changes: 19 additions & 38 deletions lib/ui/add_friend/add_friend_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:retroshare/common/styles.dart';
import 'package:retroshare/ui/add_friend/add_friend_text.dart';
import 'add_friends_utils.dart';

Expand All @@ -12,40 +11,24 @@ class _AddFriendScreenState extends State<AddFriendScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
body: SafeArea(
top: true,
bottom: true,
child: Column(children: <Widget>[
Container(
height: appBarHeight,
child: Row(
children: <Widget>[
Container(
width: personDelegateHeight,
child: Visibility(
child: IconButton(
icon: Icon(
Icons.arrow_back,
size: 25,
),
onPressed: () {
Navigator.pop(context);
},
),
),
),
Expanded(
child: Text(
'Add friend',
style: Theme.of(context).textTheme.body2,
),
),
],
),
),
Expanded(
resizeToAvoidBottomInset: false,
appBar: AppBar(
backgroundColor: Colors.black,
centerTitle: true,
title: Text(
"Add Friend",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
fontFamily: "Oxygen"),
),
automaticallyImplyLeading: true,
),
backgroundColor: Colors.white,
body: SafeArea(
top: true,
bottom: true,
child: Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
child: SingleChildScrollView(
Expand All @@ -60,8 +43,6 @@ class _AddFriendScreenState extends State<AddFriendScreen> {
],
),
),
))
])),
);
))));
}
}
Loading

1 comment on commit 4c1617e

@obrasero
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RetroShare#32#issuecomment-895562068

Please sign in to comment.