Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hoàng Văn Đạt
mypoint_flutter_app
Commits
38520c1e
Commit
38520c1e
authored
Sep 05, 2025
by
DatHV
Browse files
update seach top navi bar
parent
55151ba2
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/screen/location_address/location_address_screen.dart
View file @
38520c1e
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/resources/base_color.dart'
;
import
'../../widgets/custom_navigation_bar.dart'
;
import
'../../widgets/custom_navigation_bar.dart'
;
import
'location_address_viewmodel.dart'
;
import
'location_address_viewmodel.dart'
;
...
@@ -36,6 +37,7 @@ class LocationAddressScreen extends StatefulWidget {
...
@@ -36,6 +37,7 @@ class LocationAddressScreen extends StatefulWidget {
class
_LocationAddressScreenState
extends
State
<
LocationAddressScreen
>
{
class
_LocationAddressScreenState
extends
State
<
LocationAddressScreen
>
{
late
final
LocationAddressViewModel
viewModel
;
late
final
LocationAddressViewModel
viewModel
;
final
ScrollController
scrollController
=
ScrollController
();
final
ScrollController
scrollController
=
ScrollController
();
var
_title
=
"Địa chỉ"
;
@override
@override
void
initState
()
{
void
initState
()
{
...
@@ -48,14 +50,14 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
...
@@ -48,14 +50,14 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
type:
type
,
type:
type
,
provinceCode:
args
[
'provinceCode'
]
??
''
,
provinceCode:
args
[
'provinceCode'
]
??
''
,
));
));
_title
=
type
==
LocationAddressType
.
province
?
"Chọn Tỉnh/Thành phố"
:
"Chọn Quận/Huyện"
;
viewModel
.
selectedCode
.
value
=
selectedCode
;
viewModel
.
selectedCode
.
value
=
selectedCode
;
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
appBar:
CustomNavigationBar
(
title:
"Địa chỉ"
),
appBar:
CustomNavigationBar
(
title:
_title
),
// backgroundColor: Colors.transparent,
body:
SafeArea
(
body:
SafeArea
(
child:
Column
(
child:
Column
(
children:
[
children:
[
...
@@ -81,7 +83,6 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
...
@@ -81,7 +83,6 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
Expanded
(
Expanded
(
child:
Obx
(()
{
child:
Obx
(()
{
final
items
=
viewModel
.
displayItems
;
final
items
=
viewModel
.
displayItems
;
// Scroll đến vị trí selected sau khi hiển thị list
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
final
index
=
items
.
indexWhere
((
e
)
=>
e
.
code
==
viewModel
.
selectedCode
.
value
);
final
index
=
items
.
indexWhere
((
e
)
=>
e
.
code
==
viewModel
.
selectedCode
.
value
);
if
(
index
!=
-
1
&&
scrollController
.
hasClients
)
{
if
(
index
!=
-
1
&&
scrollController
.
hasClients
)
{
...
@@ -100,8 +101,8 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
...
@@ -100,8 +101,8 @@ class _LocationAddressScreenState extends State<LocationAddressScreen> {
final
item
=
items
[
index
];
final
item
=
items
[
index
];
final
isSelected
=
viewModel
.
selectedCode
.
value
==
item
.
code
;
final
isSelected
=
viewModel
.
selectedCode
.
value
==
item
.
code
;
return
ListTile
(
return
ListTile
(
title:
Text
(
item
.
name
??
''
,
style:
TextStyle
(
color:
isSelected
?
Color
s
.
blue
:
Colors
.
black87
)),
title:
Text
(
item
.
name
??
''
,
style:
TextStyle
(
color:
isSelected
?
Base
Color
.
primary500
:
Colors
.
black87
)),
trailing:
isSelected
?
const
Icon
(
Icons
.
check
,
color:
Color
s
.
blue
)
:
null
,
trailing:
isSelected
?
const
Icon
(
Icons
.
check
,
color:
Base
Color
.
primary500
)
:
null
,
onTap:
()
=>
viewModel
.
select
(
item
),
onTap:
()
=>
viewModel
.
select
(
item
),
);
);
},
},
...
...
lib/screen/personal/personal_edit_screen.dart
View file @
38520c1e
...
@@ -281,10 +281,10 @@ class _PersonalEditScreenState extends BaseState<PersonalEditScreen> with BasicS
...
@@ -281,10 +281,10 @@ class _PersonalEditScreenState extends BaseState<PersonalEditScreen> with BasicS
gender
.
display
,
gender
.
display
,
style:
TextStyle
(
style:
TextStyle
(
fontWeight:
isSelected
?
FontWeight
.
bold
:
FontWeight
.
normal
,
fontWeight:
isSelected
?
FontWeight
.
bold
:
FontWeight
.
normal
,
color:
isSelected
?
Color
s
.
blue
:
Colors
.
black
,
color:
isSelected
?
Base
Color
.
primary500
:
Colors
.
black
,
),
),
),
),
trailing:
isSelected
?
const
Icon
(
Icons
.
check
,
color:
Color
s
.
blue
)
:
null
,
trailing:
isSelected
?
const
Icon
(
Icons
.
check
,
color:
Base
Color
.
primary500
)
:
null
,
onTap:
()
{
onTap:
()
{
Navigator
.
of
(
context
).
pop
();
Navigator
.
of
(
context
).
pop
();
onSelected
(
gender
);
onSelected
(
gender
);
...
...
lib/widgets/custom_search_navigation_bar.dart
View file @
38520c1e
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'../screen/home/header_home_viewmodel.dart'
;
import
'back_button.dart'
;
import
'back_button.dart'
;
import
'image_loader.dart'
;
class
CustomSearchNavigationBar
extends
StatefulWidget
implements
PreferredSizeWidget
{
class
CustomSearchNavigationBar
extends
StatefulWidget
implements
PreferredSizeWidget
{
final
ValueChanged
<
String
>?
onSearchChanged
;
final
ValueChanged
<
String
>?
onSearchChanged
;
...
@@ -13,7 +15,7 @@ class CustomSearchNavigationBar extends StatefulWidget implements PreferredSizeW
...
@@ -13,7 +15,7 @@ class CustomSearchNavigationBar extends StatefulWidget implements PreferredSizeW
super
.
key
,
super
.
key
,
this
.
onSearchChanged
,
this
.
onSearchChanged
,
this
.
hintText
=
'Tìm kiếm...'
,
this
.
hintText
=
'Tìm kiếm...'
,
this
.
backgroundImage
=
"assets/images/bg_header_navi.png"
,
this
.
backgroundImage
,
//
= "assets/images/bg_header_navi.png",
this
.
showBackButton
=
true
,
this
.
showBackButton
=
true
,
this
.
rightButtons
=
const
[],
this
.
rightButtons
=
const
[],
});
});
...
@@ -27,6 +29,7 @@ class CustomSearchNavigationBar extends StatefulWidget implements PreferredSizeW
...
@@ -27,6 +29,7 @@ class CustomSearchNavigationBar extends StatefulWidget implements PreferredSizeW
class
_CustomSearchNavigationBarState
extends
State
<
CustomSearchNavigationBar
>
{
class
_CustomSearchNavigationBarState
extends
State
<
CustomSearchNavigationBar
>
{
final
TextEditingController
_controller
=
TextEditingController
();
final
TextEditingController
_controller
=
TextEditingController
();
final
_defaultBgImage
=
'assets/images/bg_header_navi.png'
;
@override
@override
void
dispose
()
{
void
dispose
()
{
...
@@ -36,82 +39,87 @@ class _CustomSearchNavigationBarState extends State<CustomSearchNavigationBar> {
...
@@ -36,82 +39,87 @@ class _CustomSearchNavigationBarState extends State<CustomSearchNavigationBar> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
double
statusBarHeight
=
MediaQuery
.
of
(
context
).
padding
.
top
;
if
(
widget
.
backgroundImage
!=
null
&&
widget
.
backgroundImage
!.
isNotEmpty
)
{
return
_buildAppBar
(
widget
.
backgroundImage
!,
context
);
}
final
theme
=
Get
.
find
<
HeaderThemeController
>();
return
Obx
(()
{
final
bg
=
theme
.
background
.
value
??
_defaultBgImage
;
return
_buildAppBar
(
bg
,
context
);
});
}
return
Container
(
Widget
_buildAppBar
(
String
bgImage
,
BuildContext
context
)
{
final
bool
isHttp
=
bgImage
.
startsWith
(
'http://'
)
||
bgImage
.
startsWith
(
'https://'
);
final
double
statusBarHeight
=
MediaQuery
.
of
(
context
).
padding
.
top
;
return
SizedBox
(
height:
statusBarHeight
+
kToolbarHeight
,
height:
statusBarHeight
+
kToolbarHeight
,
decoration:
BoxDecoration
(
// decoration: BoxDecoration(
image:
widget
.
backgroundImage
!=
null
// image:
?
DecorationImage
(
// widget.backgroundImage != null
image:
AssetImage
(
widget
.
backgroundImage
!),
// ? DecorationImage(image: AssetImage(widget.backgroundImage!), fit: BoxFit.cover)
fit:
BoxFit
.
cover
,
// : null,
)
// color: widget.backgroundImage == null ? Colors.white : null,
:
null
,
// ),
color:
widget
.
backgroundImage
==
null
?
Colors
.
white
:
null
,
child:
Stack
(
),
fit:
StackFit
.
expand
,
child:
SafeArea
(
children:
[
bottom:
false
,
if
(
bgImage
.
isNotEmpty
)
child:
Stack
(
isHttp
alignment:
Alignment
.
center
,
?
loadNetworkImage
(
url:
bgImage
,
fit:
BoxFit
.
cover
,
placeholderAsset:
_defaultBgImage
)
children:
[
:
Image
.
asset
(
_defaultBgImage
,
fit:
BoxFit
.
cover
),
Positioned
(
SafeArea
(
left:
widget
.
showBackButton
?
68
:
16
,
bottom:
false
,
right:
widget
.
rightButtons
.
isNotEmpty
?
60
:
16
,
child:
Stack
(
child:
Container
(
alignment:
Alignment
.
center
,
height:
36
,
children:
[
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8
),
Positioned
(
decoration:
BoxDecoration
(
left:
widget
.
showBackButton
?
68
:
16
,
color:
Colors
.
white
,
right:
widget
.
rightButtons
.
isNotEmpty
?
60
:
16
,
borderRadius:
BorderRadius
.
circular
(
12
),
child:
Container
(
),
height:
36
,
child:
Row
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8
),
children:
[
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
12
)),
const
Icon
(
Icons
.
search
,
size:
20
),
child:
Row
(
const
SizedBox
(
width:
4
),
children:
[
Expanded
(
const
Icon
(
Icons
.
search
,
size:
20
),
child:
TextField
(
const
SizedBox
(
width:
4
),
controller:
_controller
,
Expanded
(
onChanged:
(
value
)
{
child:
TextField
(
setState
(()
{});
// Update UI for suffix icon
controller:
_controller
,
widget
.
onSearchChanged
?.
call
(
value
);
onChanged:
(
value
)
{
},
setState
(()
{});
// Update UI for suffix icon
decoration:
InputDecoration
(
widget
.
onSearchChanged
?.
call
(
value
);
border:
InputBorder
.
none
,
},
hintText:
widget
.
hintText
,
decoration:
InputDecoration
(
isDense:
true
,
border:
InputBorder
.
none
,
contentPadding:
EdgeInsets
.
zero
,
hintText:
widget
.
hintText
,
isDense:
true
,
contentPadding:
EdgeInsets
.
zero
,
),
),
),
),
),
if
(
_controller
.
text
.
isNotEmpty
)
GestureDetector
(
onTap:
()
{
_controller
.
clear
();
widget
.
onSearchChanged
?.
call
(
''
);
setState
(()
{});
},
child:
const
Icon
(
Icons
.
close
,
size:
20
),
),
],
),
),
if
(
_controller
.
text
.
isNotEmpty
)
),
GestureDetector
(
onTap:
()
{
_controller
.
clear
();
widget
.
onSearchChanged
?.
call
(
''
);
setState
(()
{});
},
child:
const
Icon
(
Icons
.
close
,
size:
20
),
),
],
),
),
),
if
(
widget
.
showBackButton
)
Positioned
(
left:
12
,
child:
CustomBackButton
()),
if
(
widget
.
rightButtons
.
isNotEmpty
)
Positioned
(
right:
12
,
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
widget
.
rightButtons
)),
],
),
),
if
(
widget
.
showBackButton
)
),
Positioned
(
],
left:
12
,
child:
CustomBackButton
(),
),
if
(
widget
.
rightButtons
.
isNotEmpty
)
Positioned
(
right:
12
,
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
widget
.
rightButtons
,
),
),
],
),
),
),
);
);
}
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment