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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vjrj
ginkgo
Commits
b2394253
Commit
b2394253
authored
2 years ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Contacts page refactor
parent
285c1f9d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/ui/widgets/third_screen/contacts_page.dart
+113
-115
113 additions, 115 deletions
lib/ui/widgets/third_screen/contacts_page.dart
with
113 additions
and
115 deletions
lib/ui/widgets/third_screen/contacts_page.dart
+
113
−
115
View file @
b2394253
...
@@ -8,7 +8,6 @@ import 'package:share_plus/share_plus.dart';
...
@@ -8,7 +8,6 @@ import 'package:share_plus/share_plus.dart';
import
'../../../cubit/bottom_nav_cubit.dart'
;
import
'../../../cubit/bottom_nav_cubit.dart'
;
import
'../../../data/models/contact.dart'
;
import
'../../../data/models/contact.dart'
;
import
'../../../data/models/contact_cubit.dart'
;
import
'../../../data/models/contact_cubit.dart'
;
import
'../../../data/models/contact_state.dart'
;
import
'../../../data/models/payment_cubit.dart'
;
import
'../../../data/models/payment_cubit.dart'
;
import
'../../contacts_cache.dart'
;
import
'../../contacts_cache.dart'
;
import
'../../ui_helpers.dart'
;
import
'../../ui_helpers.dart'
;
...
@@ -24,13 +23,11 @@ class ContactsPage extends StatefulWidget {
...
@@ -24,13 +23,11 @@ class ContactsPage extends StatefulWidget {
class
_ContactsPageState
extends
State
<
ContactsPage
>
{
class
_ContactsPageState
extends
State
<
ContactsPage
>
{
final
TextEditingController
_searchController
=
TextEditingController
();
final
TextEditingController
_searchController
=
TextEditingController
();
late
ContactsCubit
_contactsCubit
;
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_contactsCubit
=
context
.
read
<
ContactsCubit
>();
context
.
read
<
ContactsCubit
>()
.
resetFilter
();
_contactsCubit
.
resetFilter
();
}
}
@override
@override
...
@@ -41,8 +38,7 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -41,8 +38,7 @@ class _ContactsPageState extends State<ContactsPage> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
BlocBuilder
<
ContactsCubit
,
ContactsState
>(
final
ContactsCubit
cubit
=
context
.
watch
<
ContactsCubit
>();
builder:
(
BuildContext
context
,
ContactsState
state
)
{
return
Padding
(
return
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16
),
child:
Column
(
child:
Column
(
...
@@ -55,18 +51,18 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -55,18 +51,18 @@ class _ContactsPageState extends State<ContactsPage> {
border:
const
OutlineInputBorder
(),
border:
const
OutlineInputBorder
(),
),
),
onChanged:
(
String
query
)
{
onChanged:
(
String
query
)
{
_
contactsCubit
.
filterContacts
(
query
);
cont
ext
.
read
<
Cont
actsCubit
>()
.
filterContacts
(
query
);
},
},
),
),
const
SizedBox
(
height:
20
),
const
SizedBox
(
height:
20
),
if
(
state
.
filteredContacts
.
isEmpty
)
if
(
cubit
.
state
.
filteredContacts
.
isEmpty
)
const
NoElements
(
text:
'no_contacts'
)
const
NoElements
(
text:
'no_contacts'
)
else
else
Expanded
(
Expanded
(
child:
ListView
.
builder
(
child:
ListView
.
builder
(
itemCount:
state
.
filteredContacts
.
length
,
itemCount:
cubit
.
state
.
filteredContacts
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
itemBuilder:
(
BuildContext
context
,
int
index
)
{
final
Contact
contact
=
state
.
filteredContacts
[
index
];
final
Contact
contact
=
cubit
.
state
.
filteredContacts
[
index
];
return
Slidable
(
return
Slidable
(
// Specify a key if the Slidable is dismissible.
// Specify a key if the Slidable is dismissible.
key:
ValueKey
<
int
>(
index
),
key:
ValueKey
<
int
>(
index
),
...
@@ -81,7 +77,9 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -81,7 +77,9 @@ class _ContactsPageState extends State<ContactsPage> {
// A SlidableAction can have an icon and/or a label.
// A SlidableAction can have an icon and/or a label.
SlidableAction
(
SlidableAction
(
onPressed:
(
BuildContext
c
)
{
onPressed:
(
BuildContext
c
)
{
_contactsCubit
.
removeContact
(
contact
);
context
.
read
<
ContactsCubit
>()
.
removeContact
(
contact
);
},
},
backgroundColor:
const
Color
(
0xFFFE4A49
),
backgroundColor:
const
Color
(
0xFFFE4A49
),
foregroundColor:
Colors
.
white
,
foregroundColor:
Colors
.
white
,
...
@@ -116,8 +114,7 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -116,8 +114,7 @@ class _ContactsPageState extends State<ContactsPage> {
content:
Text
(
tr
(
content:
Text
(
tr
(
'some_key_copied_to_clipboard'
)))));
'some_key_copied_to_clipboard'
)))));
},
},
backgroundColor:
backgroundColor:
Theme
.
of
(
context
)
.
primaryColorDark
,
Theme
.
of
(
context
)
.
primaryColorDark
,
foregroundColor:
Colors
.
white
,
foregroundColor:
Colors
.
white
,
icon:
Icons
.
copy
,
icon:
Icons
.
copy
,
label:
tr
(
'copy_contact_key'
),
label:
tr
(
'copy_contact_key'
),
...
@@ -141,7 +138,9 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -141,7 +138,9 @@ class _ContactsPageState extends State<ContactsPage> {
return
ContactEditDialog
(
return
ContactEditDialog
(
contact:
contact
,
contact:
contact
,
onSave:
(
Contact
c
)
{
onSave:
(
Contact
c
)
{
_contactsCubit
.
updateContact
(
c
);
context
.
read
<
ContactsCubit
>()
.
updateContact
(
c
);
ContactsCache
()
.
saveContact
(
c
);
ContactsCache
()
.
saveContact
(
c
);
});
});
},
},
...
@@ -158,7 +157,6 @@ class _ContactsPageState extends State<ContactsPage> {
...
@@ -158,7 +157,6 @@ class _ContactsPageState extends State<ContactsPage> {
const
BottomWidget
()
const
BottomWidget
()
],
],
));
));
});
}
}
void
onSent
(
BuildContext
c
,
Contact
contact
)
{
void
onSent
(
BuildContext
c
,
Contact
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