Skip to content

Commit

Permalink
#59 백엔드 연결중
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieBread123 committed May 18, 2024
1 parent f8d5140 commit 206c165
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 159 deletions.
7 changes: 5 additions & 2 deletions frontend/lib/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Future<dynamic> contentCreate(
dynamic asId,
String isbn,
String booktitle,
String description,
String author,
String publisher,
String publishDate,
Expand All @@ -211,7 +212,6 @@ Future<dynamic> contentCreate(
var address;
// print(clubId);
if (clubId == null) {
print(clubId);
address = Uri.parse("$BASE_URL/content/create?");
} else {
address = Uri.parse("$BASE_URL/content/create?clubId=$clubId&asId=$asId");
Expand All @@ -226,6 +226,7 @@ Future<dynamic> contentCreate(
"addBookRequest": {
"isbn": isbn,
"title": booktitle,
"description": description,
"author": author,
"publisher": publisher,
"publishDate": publishDate,
Expand All @@ -239,7 +240,7 @@ Future<dynamic> contentCreate(
}),
);
final data = res.body;
// final data = json.decode(utf8.decode(res.bodyBytes));
//final data = json.decode(utf8.decode(res.bodyBytes));
print(data);
return data;
}
Expand Down Expand Up @@ -603,6 +604,7 @@ Future<String> addBookToLibrary(
String token,
String isbn,
String title,
String description,
String author,
String publisher,
String publishDate,
Expand All @@ -617,6 +619,7 @@ Future<String> addBookToLibrary(
body: json.encode({
"isbn": isbn,
"title": title,
"description": description,
"author": author,
"publisher": publisher,
"publishDate": publishDate,
Expand Down
4 changes: 1 addition & 3 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ final GoRouter router = GoRouter(
path: '/bookreport_viewing',
builder: (context, state) {
dynamic contentData = state.extra as dynamic;
return BookReportViewingScreen(
contentData: contentData,
);
return BookReportViewingScreen(contentData: contentData);
},
),
GoRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _BookReportViewingState extends State<BookReportViewingScreen> {
String _template = '';
String _writer = '';
String _title = '';
String _booktitle = '';
String _body = '';
String _author = "작가";
String _publisher = "출판사";
Expand All @@ -43,6 +44,7 @@ class _BookReportViewingState extends State<BookReportViewingScreen> {
if (_template == "독후감" || _template == "한줄평" || _template == "인용구") {
_body = content['body'];
_title = content['title'];
_booktitle = content['book']['title'];
} else {
_category = quizCategory(content['type']);
_answer = content['answer'];
Expand Down Expand Up @@ -131,6 +133,15 @@ class _BookReportViewingState extends State<BookReportViewingScreen> {
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text(_booktitle),
],
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
Expand Down
199 changes: 83 additions & 116 deletions frontend/lib/screens/home/bookreport/bookreport_writing_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _BookReportWritingState extends State<BookReportWritingScreen> {
bool _isKeyboardVisible = false;

// Variables to store user input
final TextEditingController _titleController = TextEditingController();
final TextEditingController _bookTitleController = TextEditingController();
DateTime _startDate = DateTime.now();
DateTime _endDate = DateTime.now();
Expand All @@ -51,6 +52,7 @@ class _BookReportWritingState extends State<BookReportWritingScreen> {
String _isbn = "";
String _publisherDate = "";
String _imageUrl = "";
String _description = "";

late final _KeyboardVisibilityObserverWrapper
_keyboardVisibilityObserverWrapper;
Expand Down Expand Up @@ -142,89 +144,24 @@ class _BookReportWritingState extends State<BookReportWritingScreen> {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
const Text('도서: '),
const Text('제목: '),
const SizedBox(width: 10),
Expanded(
child: SizedBox(
width: _screenWidth * 0.7,
child: TextField(
style: const TextStyle(fontSize: 14),
controller: _bookTitleController,
controller: _titleController,
decoration: const InputDecoration(
hintText: '도서를 입력하세요.',
hintText: '제목을 입력하세요.',
border: InputBorder.none,
),
textInputAction: TextInputAction.go,
onSubmitted: (value) async {
BookData =
await SearchBook(_bookTitleController.text);
showDialog(
// ignore: use_build_context_synchronously
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('도서 검색 결과'),
content: SingleChildScrollView(
child: Column(
children: [
for (int i = 0; i < BookData.length; i++)
searchutil.BookSearchListItem(
data: BookData[i],
type: "search",
clubId: 0,
onSelected: (selectedData) {
print(
'Selected Data: $selectedData');
_bookTitleController.text =
selectedData['title'];
setState(() {
_author = selectedData['author'];
_publisher =
selectedData['publisher'];
});
_isbn = selectedData['isbn'];
_publisherDate =
selectedData['pubdate'];
_imageUrl = selectedData['image'];
Navigator.of(context).pop();
},
),
],
),
),
);
},
);
},
),
),
),
],
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text('$_author | $_publisher',
style: const TextStyle(color: Colors.black)),
],
),
),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: const Color(0xFFA9AFB7),
),
),
),
),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
Expand Down Expand Up @@ -275,65 +212,94 @@ class _BookReportWritingState extends State<BookReportWritingScreen> {
],
),
),
const SizedBox(height: 20),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: const Color(0xFFA9AFB7),
),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
const Text('공개 여부: ', style: TextStyle(color: Colors.black)),
const SizedBox(width: 3),
GestureDetector(
onTap: () {
setState(() {
_isPublic = true;
});
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 0.5,
),
borderRadius: BorderRadius.circular(5),
color: _isPublic ? Colors.green : Colors.white,
),
padding: const EdgeInsets.symmetric(horizontal: 5),
child: const Text(
'공개',
style: TextStyle(
color: Colors.black,
),
),
),
),
const Text('도서: '),
const SizedBox(width: 10),
GestureDetector(
onTap: () {
setState(() {
_isPublic = false;
});
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 0.5,
),
borderRadius: BorderRadius.circular(5),
color: !_isPublic ? Colors.green : Colors.white,
),
padding: const EdgeInsets.symmetric(horizontal: 5),
child: const Text(
'비공개',
style: TextStyle(
color: Colors.black,
Expanded(
child: SizedBox(
width: _screenWidth * 0.7,
child: TextField(
style: const TextStyle(fontSize: 14),
controller: _bookTitleController,
decoration: const InputDecoration(
hintText: '도서를 입력하세요.',
border: InputBorder.none,
),
textInputAction: TextInputAction.go,
onSubmitted: (value) async {
BookData =
await SearchBook(_bookTitleController.text);
showDialog(
// ignore: use_build_context_synchronously
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('도서 검색 결과'),
content: SingleChildScrollView(
child: Column(
children: [
for (int i = 0; i < BookData.length; i++)
searchutil.BookSearchListItem(
data: BookData[i],
type: "search",
clubId: 0,
onSelected: (selectedData) {
print(
'Selected Data: $selectedData');
_bookTitleController.text =
selectedData['title'];
setState(() {
_author = selectedData['author'];
_publisher =
selectedData['publisher'];
});
_isbn = selectedData['isbn'];
_publisherDate =
selectedData['pubdate'];
_imageUrl = selectedData['image'];
_description =
selectedData['description'];
Navigator.of(context).pop();
},
),
],
),
),
);
},
);
},
),
),
),
],
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text('$_author | $_publisher',
style: const TextStyle(color: Colors.black)),
],
),
),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
Expand Down Expand Up @@ -378,12 +344,13 @@ class _BookReportWritingState extends State<BookReportWritingScreen> {
widget.asId,
_isbn,
_bookTitleController.text,
_description,
_author,
_publisher,
_publisherDate,
_imageUrl,
_template,
_bookTitleController.text,
_titleController.text,
_writingController.text,
_startDate.toString(),
_endDate.toString());
Expand Down
3 changes: 2 additions & 1 deletion frontend/lib/screens/home/mypage/makelibrary_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class _MakeLibraryScreenState extends State<MakeLibraryScreen> {
const SizedBox(width: 10),
Expanded(
child: SizedBox(
//width: _screenWidth * 0.7,
child: TextField(
style: const TextStyle(fontSize: 14),
controller: _bookTitleController,
Expand Down Expand Up @@ -150,6 +149,8 @@ class _MakeLibraryScreenState extends State<MakeLibraryScreen> {
_tempbookList = {
'isbn': selectedData['isbn'],
'title': selectedData['title'],
'description':
selectedData['description'],
'author': selectedData['author'],
'publisher':
selectedData['publisher'],
Expand Down
Loading

0 comments on commit 206c165

Please sign in to comment.