diff --git a/android/local.properties b/android/local.properties index ec4fcf5..b7b8aeb 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,5 +1,5 @@ -sdk.dir=/Users/jisu/Library/Android/sdk -flutter.sdk=/Users/jisu/flutter +sdk.dir=/Users/parkjunseo/Library/Android/sdk +flutter.sdk=/Users/parkjunseo/Developer/flutter flutter.buildMode=debug flutter.versionName=1.0.0 flutter.versionCode=1 diff --git a/lib/page/detail_page/detailPage.dart b/lib/page/detail_page/detailPage.dart index 206c6fd..e9d463d 100644 --- a/lib/page/detail_page/detailPage.dart +++ b/lib/page/detail_page/detailPage.dart @@ -7,11 +7,10 @@ import 'package:cafegation/models/cafe.dart'; class detailPage extends StatefulWidget { const detailPage( - {Key? key, required this.cafeName, required this.likedStatus}) + {Key? key, required this.cafeName}) : super(key: key); final String cafeName; - final bool likedStatus; @override _detailPageState createState() => _detailPageState(); } diff --git a/lib/page/favorites_page/favorite_cafe_item.dart b/lib/page/favorites_page/favorite_cafe_item.dart index 79bfc41..87a84d9 100644 --- a/lib/page/favorites_page/favorite_cafe_item.dart +++ b/lib/page/favorites_page/favorite_cafe_item.dart @@ -27,7 +27,6 @@ class _FavoriteCafeItemState extends State { MaterialPageRoute( builder: (context) => detailPage( cafeName: widget.cafe.id, - likedStatus: true, )), ); }, diff --git a/lib/page/list_page/CafeItem.dart b/lib/page/list_page/CafeItem.dart index 0cc401b..93df61b 100644 --- a/lib/page/list_page/CafeItem.dart +++ b/lib/page/list_page/CafeItem.dart @@ -37,7 +37,6 @@ class _CafeItemState extends State { MaterialPageRoute( builder: (context) => detailPage( cafeName: widget.cafe.id, - likedStatus: state, )), ); }, diff --git a/lib/page/search_page/searchPage.dart b/lib/page/search_page/searchPage.dart index 32b958a..1979d94 100644 --- a/lib/page/search_page/searchPage.dart +++ b/lib/page/search_page/searchPage.dart @@ -1,6 +1,7 @@ import 'package:cafegation/constants/colors.dart'; import 'package:cafegation/page/favorites_page/favoritesPage.dart'; import 'package:cafegation/page/map_page/mapPage.dart'; +import 'package:cafegation/page/search_page/search_screen.dart'; import 'package:cafegation/page/search_page/searchbar.dart'; import 'package:cafegation/page/tag_page/tagPage.dart'; import 'package:flutter/material.dart'; @@ -24,7 +25,7 @@ class _searchPageState extends State { appBar: AppBar( backgroundColor: Colors.blue[200], shadowColor: Colors.blue[300], - title: Text('Search Page'), + title: Text('Main Page'), automaticallyImplyLeading: false, leading: const SizedBox( width: 100, @@ -46,7 +47,7 @@ class _searchPageState extends State { child: Column( children: [ SearchBar(), - SizedBox(height: 30), + SizedBox(height: 1), Container( width: MediaQuery.of(context).size.width * 0.9, height: MediaQuery.of(context).size.height * 0.09, @@ -58,7 +59,10 @@ class _searchPageState extends State { primary: Color(0xFF2C2E43), onPrimary: Colors.black), onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => KakaoMapTest())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => KakaoMapTest())); // _openKakaoMapScreen(context); }, child: Row(children: [ @@ -71,7 +75,11 @@ class _searchPageState extends State { ), Text( '내 주변 카페 찾기', - style: TextStyle(color: Colors.white, fontSize: 23.0, letterSpacing: 5.0, fontWeight: FontWeight.normal), + style: TextStyle( + color: Colors.white, + fontSize: 23.0, + letterSpacing: 5.0, + fontWeight: FontWeight.normal), ), ]), ), @@ -88,7 +96,10 @@ class _searchPageState extends State { primary: Color(0xFF2C2E43), onPrimary: Colors.black), onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => tagPage())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => tagPage())); }, child: Row(children: [ Icon( @@ -100,7 +111,11 @@ class _searchPageState extends State { ), Text( '카테고리별 카페 찾기', - style: TextStyle(color: Colors.white, fontSize: 23.0, letterSpacing: 5.0, fontWeight: FontWeight.normal), + style: TextStyle( + color: Colors.white, + fontSize: 23.0, + letterSpacing: 5.0, + fontWeight: FontWeight.normal), ), ]), ), @@ -117,7 +132,10 @@ class _searchPageState extends State { primary: Color(0xFF2C2E43), onPrimary: Colors.black), onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => favoritesPage())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => favoritesPage())); }, child: Row(children: [ Icon( @@ -129,7 +147,11 @@ class _searchPageState extends State { ), Text( '즐겨찾는 카페 찾기', - style: TextStyle(color: Colors.white, fontSize: 23.0, letterSpacing: 5.0, fontWeight: FontWeight.normal), + style: TextStyle( + color: Colors.white, + fontSize: 23.0, + letterSpacing: 5.0, + fontWeight: FontWeight.normal), ), ]), ), @@ -152,14 +174,17 @@ Future _openKakaoMapScreen(BuildContext context) async { // util.getKakaoMapURL(37.402056, 127.108212, name: 'Kakao 본사')); /// This is short form of the above comment - String url = await util.getMapScreenURL(37.5515814, 126.9227864, name: '홍익대학교'); + String url = + await util.getMapScreenURL(37.5515814, 126.9227864, name: '홍익대학교'); debugPrint('url : $url'); - Navigator.push(context, MaterialPageRoute(builder: (_) => KakaoMapScreen(url: url))); + Navigator.push( + context, MaterialPageRoute(builder: (_) => KakaoMapScreen(url: url))); } -Widget _testingCustomScript({required Size size, required BuildContext context}) { +Widget _testingCustomScript( + {required Size size, required BuildContext context}) { return KakaoMapView( width: size.width, height: 400, @@ -194,6 +219,7 @@ Widget _testingCustomScript({required Size size, required BuildContext context}) ''', onTapMarker: (message) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message.message))); + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text(message.message))); }); } diff --git a/lib/page/search_page/search_screen.dart b/lib/page/search_page/search_screen.dart new file mode 100644 index 0000000..04fa1d5 --- /dev/null +++ b/lib/page/search_page/search_screen.dart @@ -0,0 +1,162 @@ +import 'package:cafegation/models/cafe.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:cafegation/page/detail_page/detailPage.dart'; +import 'package:cafegation/services/database.dart'; +import 'package:cafegation/page/list_page/CafeItem.dart'; +import 'package:cafegation/services/auth.dart'; + +class SearchScreen extends StatefulWidget { + _SearchScreenState createState() => _SearchScreenState(); +} + +class _SearchScreenState extends State { + final TextEditingController _filter = TextEditingController(); + FocusNode focusNode = FocusNode(); + String _searchText = ""; + + _SearchScreenState() { + _filter.addListener(() { + setState(() { + _searchText = _filter.text; + }); + }); + } + + Widget _buildBody(BuildContext context) { + return StreamBuilder( + stream: FirebaseFirestore.instance.collection('cae').snapshots(), + builder: (context, snapshot) { + if (!snapshot.hasData) return LinearProgressIndicator(); + return _buildList(context, snapshot.data!.docs); + }, + ); + } + + Widget _buildList(BuildContext context, List snapshot) { + List searchResults = []; + for (DocumentSnapshot d in snapshot) { + final cafe = DataBaseService.instance.cafeBuilder(d); + if (cafe.name.toString().contains(_searchText)) { + searchResults.add(d); + } + } + return Expanded( + child: GridView.count( + crossAxisCount: 3, + childAspectRatio: 1 / 1.5, + padding: EdgeInsets.all(3), + children: searchResults + .map((data) => _buildListItem(context, data)) + .toList()), + ); + } + + Widget _buildListItem(BuildContext context, DocumentSnapshot data) { + final cafe = DataBaseService.instance.cafeBuilder(data); + + return InkWell( + child: Image.network(cafe.images), + // onTap: () { + // Navigator.of(context).push(MaterialPageRoute( + // fullscreenDialog: true, + // builder: (BuildContext context) { + // return detailPage(cafe: cafe); + // })); + // }, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => detailPage( + cafeName: cafe.id, + )), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Padding( + padding: EdgeInsets.all(30), + ), + Container( + color: Colors.black, + padding: EdgeInsets.fromLTRB(5, 10, 5, 10), + child: Row( + children: [ + Expanded( + flex: 6, + child: TextField( + focusNode: focusNode, + style: TextStyle( + fontSize: 15, + ), + autofocus: true, + controller: _filter, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + prefixIcon: Icon( + Icons.search, + color: Colors.black, + size: 20, + ), + suffixIcon: focusNode.hasFocus + ? IconButton( + icon: Icon( + Icons.cancel, + size: 20, + ), + onPressed: () { + setState(() { + _filter.clear(); + _searchText = ""; + }); + }, + ) + : Container(), + hintText: '검색', + labelStyle: TextStyle(color: Colors.white), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.all(Radius.circular(10))), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.all(Radius.circular(10))), + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.all(Radius.circular(10))), + ), + ), + ), + focusNode.hasFocus + ? Expanded( + child: TextButton( + child: Text('취소'), + onPressed: () { + setState(() { + _filter.clear(); + _searchText = ""; + focusNode.unfocus(); + }); + }, + ), + ) + : Expanded( + flex: 0, + child: Container(), + ) + ], + ), + ), + _buildBody(context) + ], + ), + ); + } +} diff --git a/lib/page/search_page/searchbar.dart b/lib/page/search_page/searchbar.dart index 2931aaa..792d602 100644 --- a/lib/page/search_page/searchbar.dart +++ b/lib/page/search_page/searchbar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:cafegation/page/search_page/search_screen.dart'; class SearchBar extends StatelessWidget { const SearchBar({ @@ -8,21 +9,39 @@ class SearchBar extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10), - padding: EdgeInsets.symmetric(horizontal: 30, vertical: 5), + alignment: Alignment(-1.0, 0.0), + margin: EdgeInsets.symmetric(vertical: 30, horizontal: 20), + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 6), decoration: BoxDecoration( - boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.5), - offset: Offset(0, 3))], + boxShadow: [ + BoxShadow(color: Colors.grey.withOpacity(0.5), offset: Offset(0, 3)) + ], color: Colors.white24, borderRadius: BorderRadius.circular(20), ), - child: TextField( - decoration: InputDecoration( - hintText: "카페 검색하기", - border: InputBorder.none, - icon: Icon(Icons.search), - iconColor: Colors.black + // child: TextField( + // decoration: InputDecoration( + // hintText: "카페 검색하기", + // border: InputBorder.none, + // icon: Icon(Icons.search), + // iconColor: Colors.black + // ), + // ), + // child: Scaffold(body: TabBarView(children: [SearchScreen(),])) + child: TextButton.icon( + label: Text( + '카페 검색하기', + style: TextStyle(fontSize: 19), ), + icon: Icon(Icons.search, size: 22), + style: TextButton.styleFrom( + primary: Colors.black54, + alignment: Alignment.centerLeft, + ), + onPressed: () { + Navigator.push( + context, MaterialPageRoute(builder: (context) => SearchScreen())); + }, ), ); } diff --git a/pubspec.lock b/pubspec.lock index 2068dc4..0cc86a1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,21 +42,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "3.1.5" + version: "3.4.6" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "5.4.10" + version: "5.7.3" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "2.6.5" + version: "2.8.6" collection: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" fake_async: dependency: transitive description: @@ -91,42 +91,42 @@ packages: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "3.3.4" + version: "3.4.2" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "6.1.9" + version: "6.3.2" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "3.3.5" + version: "4.0.0" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.10.6" + version: "1.21.1" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.5.1" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "1.7.2" flutter: dependency: "direct main" description: flutter @@ -145,14 +145,14 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.7" flutter_rating_bar: dependency: "direct main" description: name: flutter_rating_bar url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" flutter_spinkit: dependency: "direct main" description: @@ -176,70 +176,84 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "8.2.0" + version: "8.2.1" geolocator_android: dependency: transitive description: name: geolocator_android url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.1.8" geolocator_apple: dependency: transitive description: name: geolocator_apple url: "https://pub.dartlang.org" source: hosted - version: "2.1.1+1" + version: "2.2.1" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.4" + version: "4.0.6" geolocator_web: dependency: "direct main" description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.6" geolocator_windows: dependency: transitive description: name: geolocator_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.1" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.12" + google_maps_flutter_android: + dependency: transitive + description: + name: google_maps_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.10" + google_maps_flutter_ios: + dependency: transitive + description: + name: google_maps_flutter_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.11" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.2.2" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.4" + version: "0.13.5" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" intl: dependency: transitive description: @@ -274,7 +288,7 @@ packages: name: location url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" location_platform_interface: dependency: transitive description: @@ -337,7 +351,7 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "6.0.1" + version: "6.0.3" sky_engine: dependency: transitive description: flutter @@ -426,21 +440,35 @@ packages: name: webview_flutter_android url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.14" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.9.2" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview url: "https://pub.dartlang.org" source: hosted - version: "2.7.1" +<<<<<<< HEAD +<<<<<<< HEAD + version: "2.7.5" +sdks: + dart: ">=2.16.0 <3.0.0" + flutter: ">=2.8.0" +======= + version: "2.9.3" +sdks: + dart: ">=2.17.0 <3.0.0" + flutter: ">=3.0.0" +>>>>>>> bb9b173 (FEAT: create search page) +======= + version: "2.7.5" sdks: - dart: ">=2.15.1 <3.0.0" + dart: ">=2.16.0 <3.0.0" flutter: ">=2.8.0" +>>>>>>> 31a9305 (FIX: modify search bar design)