Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Sara Savanovic Djordjevic
PROG2900
Commits
ec8eb361
Commit
ec8eb361
authored
11 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: search_bar.dart
parent
1e90cf64
No related branches found
Branches containing commit
No related tags found
1 merge request
!10
Clhp map
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/pages/default_page.dart
+0
-49
0 additions, 49 deletions
app/lib/pages/default_page.dart
app/lib/widgets/main_layout.dart
+3
-2
3 additions, 2 deletions
app/lib/widgets/main_layout.dart
app/lib/widgets/search_bar.dart
+44
-0
44 additions, 0 deletions
app/lib/widgets/search_bar.dart
with
47 additions
and
51 deletions
app/lib/pages/default_page.dart
+
0
−
49
View file @
ec8eb361
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'package:fuzzy/fuzzy.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'../consts.dart'
;
import
'../consts.dart'
;
...
@@ -26,26 +25,6 @@ class _DefaultPageState extends State<DefaultPage> {
...
@@ -26,26 +25,6 @@ class _DefaultPageState extends State<DefaultPage> {
late
Future
<
List
<
Measurement
>>
markerListFuture
;
late
Future
<
List
<
Measurement
>>
markerListFuture
;
late
Future
<
Uint8List
>
relationFuture
;
late
Future
<
Uint8List
>
relationFuture
;
late
List
<
String
>
testSearchNames
=
[
"Mjøsa"
,
"Bogstadsvannet"
,
"Einavatnet"
,
"Femsjøen"
,
"Femunden"
,
"Fjellsjøen"
,
"Gjende"
,
"Gjersjøen"
];
// Searching function for lake names using Fuzzy library
List
<
String
>
searchLakeNames
(
String
query
)
{
final
options
=
FuzzyOptions
(
threshold:
0.3
,
findAllMatches:
true
);
final
matcher
=
Fuzzy
(
testSearchNames
,
options:
options
);
final
results
=
matcher
.
search
(
query
);
// Extracting lake names from the results and casting them to strings
return
results
.
map
((
result
)
=
>
result
.
item
as
String
)
.
toList
();
}
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
...
@@ -142,33 +121,6 @@ class _DefaultPageState extends State<DefaultPage> {
...
@@ -142,33 +121,6 @@ class _DefaultPageState extends State<DefaultPage> {
body:
FutureBuilder
(
body:
FutureBuilder
(
future:
Future
.
wait
([
markerListFuture
,
relationFuture
]),
future:
Future
.
wait
([
markerListFuture
,
relationFuture
]),
builder:
(
BuildContext
context
,
AsyncSnapshot
<
List
<
dynamic
>>
snapshot
)
{
builder:
(
BuildContext
context
,
AsyncSnapshot
<
List
<
dynamic
>>
snapshot
)
{
// Display loading screen while app state is being set
if
(
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
Container
(
decoration:
const
BoxDecoration
(
// Loading screen
color:
darkestBlue
,
),
child:
Center
(
child:
Image
.
asset
(
'assets/icons/frozen.png'
,
// Loading screen icon
// Icon from: https://www.flaticon.com/free-icons/cold-water"
color:
lightBlue
,
width:
170
,
height:
170
,
),
),
);
}
else
if
(
snapshot
.
hasError
)
{
return
Center
(
child:
Text
(
'Error:
${snapshot.error}
'
));
}
else
{
// If no server connection, alert user upon completing build
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
if
(
!
serverConnection
&&
!
dialogShown
)
{
dialogShown
=
true
;
showConnectionMessage
();
}
});
List
<
Measurement
>
markerList
=
snapshot
.
data
!
[
0
]
as
List
<
Measurement
>;
List
<
Measurement
>
markerList
=
snapshot
.
data
!
[
0
]
as
List
<
Measurement
>;
Uint8List
relation
=
snapshot
.
data
!
[
1
]
as
Uint8List
;
Uint8List
relation
=
snapshot
.
data
!
[
1
]
as
Uint8List
;
...
@@ -185,7 +137,6 @@ class _DefaultPageState extends State<DefaultPage> {
...
@@ -185,7 +137,6 @@ class _DefaultPageState extends State<DefaultPage> {
),
),
);
);
}
}
},
),
),
),
),
);
);
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/main_layout.dart
+
3
−
2
View file @
ec8eb361
...
@@ -88,9 +88,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -88,9 +88,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
return
Column
(
return
Column
(
children:
[
children:
[
const
SizedBox
(
height:
contPadding
),
const
SizedBox
(
height:
contPadding
),
/*if (true)
NB: add search bar
/*if (true)
{
const SearchBar(),
const SearchBar(),
const SizedBox(height: contPadding),*/
const SizedBox(height: contPadding),
},*/
ClipRRect
(
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
20
),
borderRadius:
BorderRadius
.
circular
(
20
),
child:
Stack
(
// Stack of quick view, map layer, satellite layer, and buttons
child:
Stack
(
// Stack of quick view, map layer, satellite layer, and buttons
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/search_bar.dart
0 → 100644
+
44
−
0
View file @
ec8eb361
import
'package:flutter/material.dart'
;
import
'package:fuzzy/fuzzy.dart'
;
class
SearchBar
extends
StatelessWidget
{
late
List
<
String
>
testSearchNames
=
[
"Mjøsa"
,
"Bogstadsvannet"
,
"Einavatnet"
,
"Femsjøen"
,
"Femunden"
,
"Fjellsjøen"
,
"Gjende"
,
"Gjersjøen"
];
// Searching function for lake names using Fuzzy library
List
<
String
>
searchLakeNames
(
String
query
)
{
final
options
=
FuzzyOptions
(
threshold:
0.3
,
findAllMatches:
true
);
final
matcher
=
Fuzzy
(
testSearchNames
,
options:
options
);
final
results
=
matcher
.
search
(
query
);
// Extracting lake names from the results and casting them to strings
return
results
.
map
((
result
)
=
>
result
.
item
as
String
)
.
toList
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
child:
TextField
(
decoration:
InputDecoration
(
hintText:
'Search...'
,
filled:
true
,
fillColor:
Colors
.
white
,
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
10.0
),
),
),
onChanged:
(
value
)
{
searchLakeNames
(
value
);
},
),
);
}
}
\ No newline at end of file
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