Skip to content

Commit

Permalink
Add search
Browse files Browse the repository at this point in the history
  • Loading branch information
harmlessman committed Jul 13, 2023
1 parent e056127 commit 5802efd
Showing 1 changed file with 117 additions and 8 deletions.
125 changes: 117 additions & 8 deletions lib/pages/search_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
import 'package:child_movie/db/movie_database.dart';
import 'package:child_movie/utils/preview_movies.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SearchPage extends StatefulWidget {
const SearchPage({super.key});
Expand All @@ -8,19 +11,125 @@ class SearchPage extends StatefulWidget {
}

class _SearchPageState extends State<SearchPage> {
List<Widget> searchResult = [];
TextEditingController inputController = TextEditingController();

MovieDatabase db = MovieDatabase();

@override
Widget build(BuildContext context) {
db.openDB();
return Scaffold(
appBar: AppBar(
title: Text('설정'),
),
body: Center(
child: Text('Search Page',
style: TextStyle(
fontSize: 80,
fontWeight: FontWeight.bold,
)
backgroundColor: Colors.transparent,
elevation: 0.0,
iconTheme: IconThemeData(color: Colors.black87),
),
resizeToAvoidBottomInset: false,
body: Padding(
padding: EdgeInsets.only(left: 20.h, top: 40.h, right: 20.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"검색 페이지 입니다",
style: TextStyle(
decoration: TextDecoration.none,
color: Colors.black.withOpacity(0.77),
fontSize: 20.0.sp,
fontWeight: FontWeight.w600,
height: 1.2.h,
),
),
SizedBox(height: 10.h),
Text(
"영화 제목을 입력하세요",
style: TextStyle(
decoration: TextDecoration.none,
color: Colors.black,
fontSize: 35.0.h,
fontWeight: FontWeight.w600,
height: 1.2.h,
),
),
Container(
margin: EdgeInsets.symmetric(vertical: 30.h),
padding: EdgeInsets.symmetric(horizontal: 20.h, vertical: 16.h),
height: 70.h,
width: double.infinity,
decoration: BoxDecoration(
color: Color(0xFFF5F5F7),
borderRadius: BorderRadius.circular(40),
),
child: Row(
children: <Widget>[
Icon(Icons.search),
SizedBox(width: 20.w),
Expanded(
child: TextField(
onSubmitted: (v) async {
var data = await db.getMovieFromTitle(v);

setState(() {
searchResult = makePreviewWidgets(data, context);
});
},
controller: inputController,
decoration: InputDecoration(
hintText: "Search for movie",
hintStyle: TextStyle(
color: Color(0xFFA0A5BD),
fontSize: 18.sp,
),
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
),
),
)
],
),
),
Text(
"결과 개수 : ${searchResult.length}",
style: TextStyle(
decoration: TextDecoration.none,
color: Colors.black.withOpacity(0.77),
fontSize: 20.0.sp,
fontWeight: FontWeight.w600,
height: 1.2.h,
),
),
SizedBox(height: 30.h),
Expanded(
child: (searchResult.length > 0)
? ListView(
children: searchResult,
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.search,
size: 100.h,
),
SizedBox(
height: 20.h,
),
Align(
child: Text(
'검색 결과가 없습니다.',
style: TextStyle(
fontSize: 30.sp,
fontWeight: FontWeight.bold,
),
),
alignment: Alignment.center,
),
],
),
),
],
),
),
);
}
Expand Down

0 comments on commit 5802efd

Please sign in to comment.