Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vjrj
ginkgo
Commits
c345e286
Commit
c345e286
authored
10 months ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Allow to retrieve profiles with resizing avatars. Disable contact help
parent
3208f637
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/ui/ui_helpers.dart
+18
-9
18 additions, 9 deletions
lib/ui/ui_helpers.dart
with
18 additions
and
9 deletions
lib/ui/ui_helpers.dart
+
18
−
9
View file @
c345e286
...
...
@@ -68,12 +68,13 @@ void copyToClipboard(
const
Color
defAvatarBgColor
=
Colors
.
grey
;
const
Color
defAvatarColor
=
Colors
.
white
;
const
double
defAvatarSize
=
24
;
const
double
defAvatarStoreSize
=
44
;
const
double
defAvatarUiSize
=
24
;
Widget
avatar
(
Uint8List
?
rawAvatar
,
{
Color
color
=
defAvatarColor
,
Color
bgColor
=
defAvatarBgColor
,
double
avatarSize
=
defAvatarSize
})
{
double
avatarSize
=
defAvatar
Ui
Size
})
{
return
rawAvatar
!=
null
&&
rawAvatar
.
isNotEmpty
?
CircleAvatar
(
radius:
avatarSize
,
...
...
@@ -119,7 +120,7 @@ String humanizeContact(String publicAddress, Contact contact,
[
bool
addKey
=
false
,
bool
minimal
=
false
,
String
Function
(
String
s
)
trf
=
tr
])
{
if
(
extractPublicKey
(
contact
.
pubKey
)
==
extractPublicKey
(
publicAddress
))
{
if
(
isMe
(
contact
,
publicAddress
))
{
return
trf
(
'your_wallet'
);
}
else
{
final
String
pubKey
=
humanizePubKey
(
contact
.
pubKey
);
...
...
@@ -135,6 +136,9 @@ String humanizeContact(String publicAddress, Contact contact,
}
}
bool
isMe
(
Contact
contact
,
String
publicAddress
)
=
>
extractPublicKey
(
contact
.
pubKey
)
==
extractPublicKey
(
publicAddress
);
String
humanizePubKey
(
String
rawAddress
,
[
bool
minimal
=
false
])
{
final
String
address
=
extractPublicKey
(
rawAddress
);
return
minimal
...
...
@@ -247,16 +251,18 @@ double parseToDoubleLocalized(
String
localizeNumber
(
BuildContext
context
,
double
amount
)
=
>
NumberFormat
.
decimalPattern
(
eo
(
currentLocale
(
context
)))
.
format
(
amount
);
Future
<
Contact
>
contactFromResultSearch
(
Map
<
String
,
dynamic
>
record
)
async
{
Future
<
Contact
>
contactFromResultSearch
(
Map
<
String
,
dynamic
>
record
,
{
bool
resize
=
true
})
async
{
final
Map
<
String
,
dynamic
>
source
=
record
[
'_source'
]
as
Map
<
String
,
dynamic
>
;
final
Uint8List
?
avatarBase64
=
await
_getAvatarFromResults
(
source
)
;
final
Uint8List
?
avatarBase64
=
await
_getAvatarFromResults
(
source
,
resize
)
;
return
Contact
(
pubKey:
record
[
'_id'
]
as
String
,
name:
source
[
'title'
]
as
String
,
avatar:
avatarBase64
)
;
}
Future
<
Uint8List
?
>
_getAvatarFromResults
(
Map
<
String
,
dynamic
>
source
)
async
{
Future
<
Uint8List
?
>
_getAvatarFromResults
(
Map
<
String
,
dynamic
>
source
,
bool
resize
)
async
{
Uint8List
?
avatarBase64
;
if
(
source
[
'avatar'
]
!=
null
)
{
final
Map
<
String
,
dynamic
>
avatar
=
...
...
@@ -265,7 +271,8 @@ Future<Uint8List?> _getAvatarFromResults(Map<String, dynamic> source) async {
'data:
${avatar['_content_type']}
;base64,
${avatar['_content']}
'
)
;
}
if
(
avatarBase64
!=
null
&&
avatarBase64
.
isNotEmpty
)
{
final
Uint8List
?
avatarBase64resized
=
await
resizeAvatar
(
avatarBase64
);
final
Uint8List
?
avatarBase64resized
=
resize
?
await
resizeAvatar
(
avatarBase64
)
:
avatarBase64
;
return
avatarBase64resized
;
}
else
{
return
null
;
...
...
@@ -274,7 +281,7 @@ Future<Uint8List?> _getAvatarFromResults(Map<String, dynamic> source) async {
Future
<
Uint8List
?
>
resizeAvatar
(
Uint8List
avatarBase64
)
async
{
final
ByteData
?
bytes
=
await
resizeImage
(
avatarBase64
,
height:
defAvatarSize
.
toInt
()
*
2
);
await
resizeImage
(
avatarBase64
,
height:
defAvatarS
toreS
ize
.
toInt
()
*
2
);
return
bytes
!=
null
?
Uint8List
.
view
(
bytes
.
buffer
)
:
null
;
}
...
...
@@ -379,10 +386,12 @@ class _SlidableContactTile extends State<SlidableContactTile> {
@override
void
initState
()
{
super
.
initState
();
_start
();
// Disable for now
// _start();
}
// Based in https://github.com/letsar/flutter_slidable/issues/288
// ignore: unused_element
Future
<
void
>
_start
()
async
{
if
(
widget
.
index
==
0
&&
!
context
.
read
<
AppCubit
>()
.
wasTutorialShown
(
tutorialId
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment