Skip to content

Commit d75d38d

Browse files
committed
feat: Set autocomplete textfield
1 parent ea01d19 commit d75d38d

File tree

15 files changed

+298
-44
lines changed

15 files changed

+298
-44
lines changed

ios/Flutter/Debug.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"

ios/Flutter/Release.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

ios/Podfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17+
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
22+
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
25+
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
30+
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
33+
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35+
end
36+
37+
post_install do |installer|
38+
installer.pods_project.targets.each do |target|
39+
flutter_additional_ios_build_settings(target)
40+
end
41+
end

ios/Podfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- Flutter (1.0.0)
3+
- flutter_keyboard_visibility (0.0.1):
4+
- Flutter
5+
6+
DEPENDENCIES:
7+
- Flutter (from `Flutter`)
8+
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
9+
10+
EXTERNAL SOURCES:
11+
Flutter:
12+
:path: Flutter
13+
flutter_keyboard_visibility:
14+
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
15+
16+
SPEC CHECKSUMS:
17+
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
18+
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
19+
20+
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
21+
22+
COCOAPODS: 1.10.1

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12+
5600880119B1B4DFE3DE8D78 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F83841EAB6A0ADDC5DC5E9C /* Pods_Runner.framework */; };
1213
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
1314
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1415
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
@@ -31,7 +32,10 @@
3132
/* Begin PBXFileReference section */
3233
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
3334
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
35+
1E0CDD1C3D4A7749A7625828 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3436
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
37+
47A10E171302B9DEAC12EF52 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
38+
6F83841EAB6A0ADDC5DC5E9C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3539
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
3640
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3741
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -42,19 +46,40 @@
4246
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4347
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4448
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
49+
F8F458BDBB8707B2238E69D4 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
4550
/* End PBXFileReference section */
4651

4752
/* Begin PBXFrameworksBuildPhase section */
4853
97C146EB1CF9000F007C117D /* Frameworks */ = {
4954
isa = PBXFrameworksBuildPhase;
5055
buildActionMask = 2147483647;
5156
files = (
57+
5600880119B1B4DFE3DE8D78 /* Pods_Runner.framework in Frameworks */,
5258
);
5359
runOnlyForDeploymentPostprocessing = 0;
5460
};
5561
/* End PBXFrameworksBuildPhase section */
5662

5763
/* Begin PBXGroup section */
64+
2C04983251F255E18896C7B7 /* Frameworks */ = {
65+
isa = PBXGroup;
66+
children = (
67+
6F83841EAB6A0ADDC5DC5E9C /* Pods_Runner.framework */,
68+
);
69+
name = Frameworks;
70+
sourceTree = "<group>";
71+
};
72+
3D635917B5855AAB82C29A31 /* Pods */ = {
73+
isa = PBXGroup;
74+
children = (
75+
47A10E171302B9DEAC12EF52 /* Pods-Runner.debug.xcconfig */,
76+
F8F458BDBB8707B2238E69D4 /* Pods-Runner.release.xcconfig */,
77+
1E0CDD1C3D4A7749A7625828 /* Pods-Runner.profile.xcconfig */,
78+
);
79+
name = Pods;
80+
path = Pods;
81+
sourceTree = "<group>";
82+
};
5883
9740EEB11CF90186004384FC /* Flutter */ = {
5984
isa = PBXGroup;
6085
children = (
@@ -72,6 +97,8 @@
7297
9740EEB11CF90186004384FC /* Flutter */,
7398
97C146F01CF9000F007C117D /* Runner */,
7499
97C146EF1CF9000F007C117D /* Products */,
100+
3D635917B5855AAB82C29A31 /* Pods */,
101+
2C04983251F255E18896C7B7 /* Frameworks */,
75102
);
76103
sourceTree = "<group>";
77104
};
@@ -105,12 +132,14 @@
105132
isa = PBXNativeTarget;
106133
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
107134
buildPhases = (
135+
D64D40B2834108EE7DD1FC89 /* [CP] Check Pods Manifest.lock */,
108136
9740EEB61CF901F6004384FC /* Run Script */,
109137
97C146EA1CF9000F007C117D /* Sources */,
110138
97C146EB1CF9000F007C117D /* Frameworks */,
111139
97C146EC1CF9000F007C117D /* Resources */,
112140
9705A1C41CF9048500538489 /* Embed Frameworks */,
113141
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142+
B9F6365EBEC885A04EA52960 /* [CP] Embed Pods Frameworks */,
114143
);
115144
buildRules = (
116145
);
@@ -197,6 +226,45 @@
197226
shellPath = /bin/sh;
198227
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
199228
};
229+
B9F6365EBEC885A04EA52960 /* [CP] Embed Pods Frameworks */ = {
230+
isa = PBXShellScriptBuildPhase;
231+
buildActionMask = 2147483647;
232+
files = (
233+
);
234+
inputFileListPaths = (
235+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
236+
);
237+
name = "[CP] Embed Pods Frameworks";
238+
outputFileListPaths = (
239+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
240+
);
241+
runOnlyForDeploymentPostprocessing = 0;
242+
shellPath = /bin/sh;
243+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
244+
showEnvVarsInLog = 0;
245+
};
246+
D64D40B2834108EE7DD1FC89 /* [CP] Check Pods Manifest.lock */ = {
247+
isa = PBXShellScriptBuildPhase;
248+
buildActionMask = 2147483647;
249+
files = (
250+
);
251+
inputFileListPaths = (
252+
);
253+
inputPaths = (
254+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
255+
"${PODS_ROOT}/Manifest.lock",
256+
);
257+
name = "[CP] Check Pods Manifest.lock";
258+
outputFileListPaths = (
259+
);
260+
outputPaths = (
261+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
262+
);
263+
runOnlyForDeploymentPostprocessing = 0;
264+
shellPath = /bin/sh;
265+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
266+
showEnvVarsInLog = 0;
267+
};
200268
/* End PBXShellScriptBuildPhase section */
201269

202270
/* Begin PBXSourcesBuildPhase section */

ios/Runner.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cubit/WeatherCubit.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter_bloc/flutter_bloc.dart';
22
import 'package:weatherbi/Cubit/WeatherRepository.dart';
33
import 'package:weatherbi/Cubit/WeatherState.dart';
4+
import 'package:weatherbi/Models/Weather.dart';
45

56
class WeatherCubit extends Cubit<WeatherState> {
67
IWeatherRepository _weatherRepository;
@@ -12,7 +13,12 @@ class WeatherCubit extends Cubit<WeatherState> {
1213
var res = await _weatherRepository.getWeather(city);
1314
emit(WeatherDone(res));
1415
} catch (e) {
15-
WeatherError(e);
16+
emit(WeatherError(e));
1617
}
1718
}
19+
20+
Future<List<Location>> getSuggestionandLoad(String word) async {
21+
List<Location> suggestions = word != null ? await _weatherRepository.getSuggestions(word) : [];
22+
return suggestions;
23+
}
1824
}

lib/Cubit/WeatherRepository.dart

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'dart:convert';
2-
32
import 'package:weatherbi/Models/Weather.dart';
43
import 'package:weatherbi/Utils/Constant.dart';
54
import 'package:http/http.dart' as http;
65

76
abstract class IWeatherRepository {
87
Future<Weather> getWeather(String city);
8+
Future<List<Location>> getSuggestions(String word);
99
}
1010

11+
// http://api.weatherapi.com/v1/search.json?key=4f969564b56c46c984f183131212603&q=London
1112
class WeatherRepository extends IWeatherRepository {
1213
@override
1314
Future<Weather> getWeather(String city) async {
@@ -19,7 +20,25 @@ class WeatherRepository extends IWeatherRepository {
1920
'days': '7',
2021
};
2122
Uri url = Uri.http(_baseUrl, _charactersPath, _queryParameters);
22-
var cevap = await http.get(url);
23-
return Weather.fromJson(jsonDecode(cevap.body));
23+
var response = await http.get(url);
24+
return Weather.fromJson(jsonDecode(response.body));
25+
}
26+
27+
@override
28+
Future<List<Location>> getSuggestions(String word) async {
29+
final String _baseUrl = 'api.weatherapi.com';
30+
final String _charactersPath = 'v1/search.json';
31+
final Map<String, String> _queryParameters = <String, String>{
32+
'key': Constant().apiKey,
33+
'q': '$word',
34+
};
35+
Uri url = Uri.http(_baseUrl, _charactersPath, _queryParameters);
36+
var response = await http.get(url);
37+
final List locations = json.decode(response.body);
38+
return locations.map((e) => Location.fromJson(e)).where((location) {
39+
final nameLower = location.name.toLowerCase();
40+
final queryLower = word.toLowerCase();
41+
return nameLower.contains(queryLower);
42+
}).toList();
2443
}
2544
}

lib/Pages/Details.dart

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,16 @@ class _DetailsState extends State<Details> {
5555
Text(
5656
state.weather.current.condition.text,
5757
style: Constant().mainTitle.copyWith(fontWeight: FontWeight.w300, fontSize: 64),
58+
textAlign: TextAlign.center,
5859
),
5960
Row(
6061
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
6162
children: [
62-
buildMiddleLeftDesign(state),
6363
Padding(
6464
padding: const EdgeInsets.only(top: 12),
65-
child: buildMiddleAllRight(topValue: 28, bottomValue: 17),
65+
child: buildMiddleLeftDesign(state),
6666
),
67-
],
68-
),
69-
Row(
70-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
71-
children: [
72-
buildMiddleAllRight(topValue: 28, bottomValue: "M", isSeen: false),
73-
buildMiddleAllRight(topValue: 28, bottomValue: "T", isSeen: false),
74-
buildMiddleAllRight(topValue: 28, bottomValue: "W", isSeen: false),
75-
buildMiddleAllRight(topValue: 28, bottomValue: "T", isSeen: false),
76-
buildMiddleAllRight(topValue: 28, bottomValue: "F", isSeen: false),
77-
buildMiddleAllRight(topValue: 28, bottomValue: "S", isSeen: false),
78-
buildMiddleAllRight(topValue: 28, bottomValue: "S", isSeen: false),
67+
// buildMiddleAllRight(topValue: 28, bottomValue: 17),
7968
],
8069
),
8170
],

0 commit comments

Comments
 (0)