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
86cbe631
Commit
86cbe631
authored
11 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: search bar, currently constant
parent
ec8eb361
No related branches found
No related tags found
1 merge request
!10
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/widgets/main_layout.dart
+55
-5
55 additions, 5 deletions
app/lib/widgets/main_layout.dart
app/lib/widgets/search_bar.dart
+4
-3
4 additions, 3 deletions
app/lib/widgets/search_bar.dart
with
59 additions
and
8 deletions
app/lib/widgets/main_layout.dart
+
55
−
5
View file @
86cbe631
import
'dart:typed_data'
;
import
'package:flutter_map/flutter_map.dart'
;
import
'package:fuzzy/fuzzy.dart'
;
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'satellite_layer.dart'
;
import
'osm_layer.dart'
;
import
'search_bar.dart'
;
import
'stat_charts.dart'
;
import
'../../consts.dart'
;
import
'choropleth_map.dart'
;
import
'../data_classes.dart'
;
import
'satellite_layer.dart'
;
import
'quick_view_chart.dart'
;
/// MapContainerWidget is the main widget that contains the map with all
...
...
@@ -88,10 +90,9 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
return
Column
(
children:
[
const
SizedBox
(
height:
contPadding
),
/*if (true) {
const SearchBar(),
const SizedBox(height: contPadding),
},*/
if
(
true
)
// NB temp always true
_SearchBar
(),
const
SizedBox
(
height:
contPadding
),
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
20
),
child:
Stack
(
// Stack of quick view, map layer, satellite layer, and buttons
...
...
@@ -269,4 +270,53 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
},
);
}
}
class _SearchBar extends StatelessWidget {
final width = 350.0; // NB pass value to class
final 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: SizedBox(
height: 35, // Adjust the height here
width: width,
child: TextField(
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
hintText: '
Search
...
',
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
),
),
onChanged: (value) {
searchLakeNames(value);
},
),
),
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/lib/widgets/search_bar.dart
+
4
−
3
View file @
86cbe631
import
'package:flutter/material.dart'
;
import
'package:fuzzy/fuzzy.dart'
;
class
SearchBar
extends
StatelessWidget
{
late
List
<
String
>
testSearchNames
=
[
/*
class _SearchBar extends StatelessWidget {
final List<String> testSearchNames = [
"Mjøsa",
"Bogstadsvannet",
"Einavatnet",
...
...
@@ -41,4 +42,4 @@ class SearchBar extends StatelessWidget {
),
);
}
}
\ No newline at end of file
}*/
\ 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