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
Fred
ginkgo
Commits
5362986e
Commit
5362986e
authored
10 months ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Contact menu in contacts (allow to get profile of accounts, etc)
parent
3778e87b
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/widgets/first_screen/contact_search_page.dart
+117
-103
117 additions, 103 deletions
lib/ui/widgets/first_screen/contact_search_page.dart
with
117 additions
and
103 deletions
lib/ui/widgets/first_screen/contact_search_page.dart
+
117
−
103
View file @
5362986e
...
@@ -21,6 +21,8 @@ import '../../nfc_helper.dart';
...
@@ -21,6 +21,8 @@ import '../../nfc_helper.dart';
import
'../../qr_manager.dart'
;
import
'../../qr_manager.dart'
;
import
'../../ui_helpers.dart'
;
import
'../../ui_helpers.dart'
;
import
'../connectivity_widget_wrapper_wrapper.dart'
;
import
'../connectivity_widget_wrapper_wrapper.dart'
;
import
'../contact_menu.dart'
;
import
'../contacts_actions.dart'
;
import
'../custom_error_widget.dart'
;
import
'../custom_error_widget.dart'
;
import
'../loading_box.dart'
;
import
'../loading_box.dart'
;
import
'../third_screen/contacts_page.dart'
;
import
'../third_screen/contacts_page.dart'
;
...
@@ -88,8 +90,9 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -88,8 +90,9 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>)[
'hits'
]
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>)[
'hits'
]
as
Map
<
String
,
dynamic
>)[
'hits'
]
as
List
<
dynamic
>;
as
Map
<
String
,
dynamic
>)[
'hits'
]
as
List
<
dynamic
>;
for
(
final
dynamic
hit
in
hits
)
{
for
(
final
dynamic
hit
in
hits
)
{
final
Contact
c
=
final
Contact
c
=
await
contactFromResultSearch
(
await
contactFromResultSearch
(
hit
as
Map
<
String
,
dynamic
>);
hit
as
Map
<
String
,
dynamic
>,
);
logger
(
'Contact retrieved in c+ search
$c
'
);
logger
(
'Contact retrieved in c+ search
$c
'
);
ContactsCache
()
.
addContact
(
c
);
ContactsCache
()
.
addContact
(
c
);
setState
(()
{
setState
(()
{
...
@@ -103,7 +106,7 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -103,7 +106,7 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
if
(
isConnected
)
{
if
(
isConnected
)
{
if
(
_searchTerm
.
length
>
=
8
)
{
if
(
_searchTerm
.
length
>
=
8
)
{
// Only search wot if it's a long key
// Only search wot if it's a long key
final
List
<
Contact
>
wotResults
=
await
searchWotV
2
(
_searchTerm
);
final
List
<
Contact
>
wotResults
=
await
searchWotV
1
(
_searchTerm
);
// ignore: prefer_foreach
// ignore: prefer_foreach
for
(
final
Contact
c
in
wotResults
)
{
for
(
final
Contact
c
in
wotResults
)
{
ContactsCache
()
.
addContact
(
c
);
ContactsCache
()
.
addContact
(
c
);
...
@@ -114,8 +117,9 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -114,8 +117,9 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
await
ContactsCache
()
.
getContact
(
wotC
.
pubKey
);
await
ContactsCache
()
.
getContact
(
wotC
.
pubKey
);
if
(
cachedWotProfile
.
name
==
null
)
{
if
(
cachedWotProfile
.
name
==
null
)
{
// Users without c+ profile
// Users without c+ profile
final
Contact
cPlusProfile
=
final
Contact
cPlusProfile
=
await
getProfile
(
await
getProfile
(
cachedWotProfile
.
pubKey
,
true
);
cachedWotProfile
.
pubKey
,
onlyCPlusProfile:
true
);
ContactsCache
()
.
addContact
(
cPlusProfile
);
ContactsCache
()
.
addContact
(
cPlusProfile
);
}
}
}
}
...
@@ -154,9 +158,10 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -154,9 +158,10 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
final
bool
nft
=
hasNft
(
snapshot
);
final
bool
nft
=
hasNft
(
snapshot
);
final
PaymentCubit
paymentCubit
=
context
.
read
<
PaymentCubit
>();
final
PaymentCubit
paymentCubit
=
context
.
read
<
PaymentCubit
>();
final
bool
forPayment
=
widget
.
forPayment
;
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
Text
(
widget
.
forPayment
title:
Text
(
forPayment
?
tr
(
'search_user_title'
)
?
tr
(
'search_user_title'
)
:
tr
(
'search_user_title_in_contacts'
)),
:
tr
(
'search_user_title_in_contacts'
)),
backgroundColor:
Theme
.
of
(
context
)
.
colorScheme
.
primary
,
backgroundColor:
Theme
.
of
(
context
)
.
colorScheme
.
primary
,
...
@@ -205,102 +210,104 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -205,102 +210,104 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
)
)
],
],
),
),
body:
Padding
(
body:
Column
(
padding:
const
EdgeInsets
.
all
(
16.0
),
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
child:
Column
(
children:
<
Widget
>[
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
Padding
(
children:
<
Widget
>[
padding:
const
EdgeInsets
.
all
(
16.0
),
TextField
(
child:
TextField
(
controller:
_searchController
,
controller:
_searchController
,
focusNode:
_searchFocusNode
,
focusNode:
_searchFocusNode
,
decoration:
InputDecoration
(
decoration:
InputDecoration
(
filled:
true
,
filled:
true
,
labelText:
tr
(
'search_user'
),
labelText:
tr
(
'search_user'
),
helperText:
_searchTerm
.
isEmpty
helperText:
_searchTerm
.
isEmpty
?
tr
(
'search_user_hint'
)
?
forPayment
:
!
_isMultiSelect
&&
!
_isLoading
?
tr
(
'search_user_hint'
)
?
tr
(
'search_multiuser_hint'
)
:
tr
(
'search_user_hint_basic'
)
:
null
,
:
!
_isMultiSelect
&&
!
_isLoading
&&
forPayment
suffixIcon:
Row
(
?
tr
(
'search_multiuser_hint'
)
mainAxisAlignment:
MainAxisAlignment
.
end
,
:
null
,
mainAxisSize:
MainAxisSize
.
min
,
suffixIcon:
Row
(
children:
<
Widget
>[
mainAxisAlignment:
MainAxisAlignment
.
end
,
IconButton
(
mainAxisSize:
MainAxisSize
.
min
,
icon:
const
Icon
(
Icons
.
clear
),
children:
<
Widget
>[
onPressed:
()
{
IconButton
(
_searchController
.
clear
();
icon:
const
Icon
(
Icons
.
clear
),
_searchTerm
=
''
;
onPressed:
()
{
_previousSearchTerm
=
''
;
_searchController
.
clear
();
setState
(()
{
_searchTerm
=
''
;
_isLoading
=
false
;
_previousSearchTerm
=
''
;
_results
.
clear
();
setState
(()
{
});
_isLoading
=
false
;
},
_results
.
clear
();
),
});
IconButton
(
},
icon:
const
Icon
(
Icons
.
search
),
),
onPressed:
()
=
>
IconButton
(
_searchTerm
.
length
<
3
?
null
:
_search
(),
icon:
const
Icon
(
Icons
.
search
),
),
onPressed:
()
=
>
],
_searchTerm
.
length
<
3
?
null
:
_search
(),
),
],
),
),
),
),
onSubmitted:
(
_
)
{
onSubmitted:
(
_
)
{
_search
();
_search
();
},
},
onChanged:
(
String
value
)
{
onChanged:
(
String
value
)
{
if
(
value
.
length
<
_previousSearchTerm
.
length
&&
if
(
value
.
length
<
_previousSearchTerm
.
length
&&
value
.
length
<
3
)
{
value
.
length
<
3
)
{
_previousSearchTerm
=
value
;
setState
(()
{
_isLoading
=
false
;
});
return
;
}
_searchTerm
=
value
;
_previousSearchTerm
=
value
;
_previousSearchTerm
=
value
;
setState
(()
{
if
(
_searchTerm
.
length
>
=
3
)
{
_isLoading
=
false
;
setState
(()
{
});
_isLoading
=
true
;
return
;
});
}
EasyDebounce
.
debounce
(
_searchTerm
=
value
;
'profile_search_debouncer'
,
_previousSearchTerm
=
value
;
const
Duration
(
milliseconds:
500
),
if
(
_searchTerm
.
length
>
=
3
)
{
()
=
>
_search
());
setState
(()
{
}
_isLoading
=
true
;
},
});
)),
EasyDebounce
.
debounce
(
'profile_search_debouncer'
,
if
(
_isLoading
)
const
Duration
(
milliseconds:
500
),
()
=
>
_search
());
const
LoadingBox
(
simple:
false
)
}
else
if
(
_searchTerm
.
isNotEmpty
&&
},
_results
.
isEmpty
&&
),
_isLoading
)
if
(
_isLoading
)
const
NoElements
(
text:
'nothing_found'
)
const
LoadingBox
(
simple:
false
)
else
else
if
(
_searchTerm
.
isNotEmpty
&&
Expanded
(
_results
.
isEmpty
&&
child:
ListView
.
builder
(
_isLoading
)
itemCount:
_results
.
length
,
const
NoElements
(
text:
'nothing_found'
)
itemBuilder:
(
BuildContext
context
,
int
index
)
{
else
final
Contact
contact
=
_results
[
index
];
Expanded
(
return
FutureBuilder
<
Contact
>(
child:
ListView
.
builder
(
future:
_getAndReplaceContact
(
contact
),
itemCount:
_results
.
length
,
builder:
(
BuildContext
context
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
AsyncSnapshot
<
Contact
>
snapshot
)
{
final
Contact
contact
=
_results
[
index
];
Widget
widget
;
return
FutureBuilder
<
Contact
>(
if
(
snapshot
.
hasData
)
{
future:
_getAndReplaceContact
(
contact
),
widget
=
_buildItem
(
builder:
(
BuildContext
context
,
snapshot
.
data
!
,
index
,
context
);
AsyncSnapshot
<
Contact
>
snapshot
)
{
}
else
if
(
snapshot
.
hasError
)
{
Widget
widget
;
widget
=
CustomErrorWidget
(
snapshot
.
error
);
if
(
snapshot
.
hasData
)
{
}
else
{
widget
=
_buildItem
(
// Contact without wot
snapshot
.
data
!
,
index
,
context
);
widget
=
_buildItem
(
contact
,
index
,
context
);
}
else
if
(
snapshot
.
hasError
)
{
}
widget
=
CustomErrorWidget
(
snapshot
.
error
);
return
widget
;
}
else
{
});
// Contact without wot
}),
widget
=
)
_buildItem
(
contact
,
index
,
context
);
],
}
return
widget
;
});
}),
)
],
),
),
),
floatingActionButton:
floatingActionButton:
_isMultiSelect
?
_buildFloatingActionButtons
()
:
null
,
_isMultiSelect
?
_buildFloatingActionButtons
()
:
null
,
...
@@ -494,9 +501,16 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
...
@@ -494,9 +501,16 @@ class _ContactSearchPageState extends State<ContactSearchPage> {
},
},
trailing:
BlocBuilder
<
ContactsCubit
,
ContactsState
>(
trailing:
BlocBuilder
<
ContactsCubit
,
ContactsState
>(
builder:
(
BuildContext
context
,
ContactsState
state
)
{
builder:
(
BuildContext
context
,
ContactsState
state
)
{
return
ContactFavIcon
(
return
widget
.
forPayment
contact:
contact
,
?
ContactFavIcon
(
contactsCubit:
context
.
read
<
ContactsCubit
>());
contact:
contact
,
contactsCubit:
context
.
read
<
ContactsCubit
>())
:
ContactMenu
(
contact:
contact
,
onEdit:
()
=
>
onEditContact
(
context
,
contact
),
onSent:
()
=
>
onSentContact
(
context
,
contact
),
onCopy:
()
=
>
onShowContactQr
(
context
,
contact
),
onDelete:
()
=
>
onDeleteContact
(
context
,
contact
));
}),
}),
);
);
}
}
...
...
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