Skip to content

Commit

Permalink
✨ Update 발자국 포토맵 중간 저장
Browse files Browse the repository at this point in the history
포토맵 저장
포토맵 스냅샷 저장
히스토리 저장
히스토리 불러오기
장소 검색 api 추가

 related: #39
  • Loading branch information
Dev-inwoong committed Jun 11, 2024
1 parent 2fb069f commit 67e5552
Show file tree
Hide file tree
Showing 36 changed files with 1,930 additions and 596 deletions.
6 changes: 3 additions & 3 deletions lib/dao/diary_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<void> setDiarySequence(int sequence) async {
.set({'value': sequence});
}

Future<void> saveDiary(Diary diary) async {
Future<void> addDiary(Diary diary) async {
await FirebaseFirestore.instance.collection('DiaryData').add({
"diary_idx": diary.diaryIdx,
"diary_user_idx": diary.diaryUserIdx,
Expand Down Expand Up @@ -93,7 +93,7 @@ Future<void> uploadDiaryImage(XFile imageFile, String imageName) async {
.putFile(File(imageFile.path));
}

Future<Image> getDiaryImagePath(String path) async {
Future<Image> getDiaryImage(String path) async {
var imageURL =
await FirebaseStorage.instance.ref('image/diary/$path').getDownloadURL();
var image = Image.network(
Expand All @@ -118,7 +118,7 @@ Future<bool> isExistOnDate(DateTime date) async {
.collection('DiaryData')
.where('diary_date', isEqualTo: stringDate)
.get();
if (querySnapshot.docs.length > 0) {
if (querySnapshot.docs.isNotEmpty) {
return true;
} else {
return false;
Expand Down
68 changes: 68 additions & 0 deletions lib/dao/history_dao.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:woo_yeon_hi/model/history_model.dart';

Future<int> getHistorySequence() async {
var querySnapShot = await FirebaseFirestore.instance
.collection('Sequence')
.doc('HistorySequence')
.get();
var sequence = querySnapShot.data()!.values.first;
return sequence;
}

Future<void> setHistorySequence(int sequence) async {
await FirebaseFirestore.instance
.collection('Sequence')
.doc('HistorySequence')
.set({'value': sequence});
}

Future<void> addHistory(History history) async {
await FirebaseFirestore.instance.collection('HistoryData').add({
"history_idx" : history.historyIdx,
"history_map_idx" : history.historyMapIdx,
"history_place_name" : history.historyPlaceName,
"history_location" : history.historyLocation,
"history_user_idx" : history.historyUserIdx,
"history_title" : history.historyTitle,
"history_date" : history.historyDate,
"history_content" : history.historyContent,
"history_image" : history.historyImage,
"history_state" : history.historyState
});
}

Future<List<History>> getHistory(int userIdx, int mapIdx) async {
List<History> results = [];
var querySnapshot = await FirebaseFirestore.instance.collection('HistoryData')
.where('history_user_idx', isEqualTo: userIdx)
.where('history_map_idx', isEqualTo: mapIdx)
.get();

for(var doc in querySnapshot.docs){
results.add(History.fromData(doc.data()));
}
return results;
}

Future<void> uploadHistoryImage(XFile imageFile, String imageName) async {
await FirebaseStorage.instance
.ref('image/history/$imageName')
.putFile(File(imageFile.path));
}

Future<Image> getHistoryImage(String? path) async {
var imageURL =
await FirebaseStorage.instance.ref('image/history/$path').getDownloadURL();
var image = Image.network(
imageURL,
fit: BoxFit.cover,
);
return image;
}
85 changes: 85 additions & 0 deletions lib/dao/photo_map_dao.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@


import 'dart:typed_data';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:woo_yeon_hi/model/photo_map_model.dart';

Future<int> getPhotoMapSequence() async {
var querySnapShot = await FirebaseFirestore.instance
.collection('Sequence')
.doc('PhotoMapSequence')
.get();
var sequence = querySnapShot.data()!.values.first;
return sequence;
}

Future<void> setPhotoMapSequence(int sequence) async {
await FirebaseFirestore.instance
.collection('Sequence')
.doc('PhotoMapSequence')
.set({'value': sequence});
}

Future<void> addPhotoMap(PhotoMap photoMap) async {
await FirebaseFirestore.instance.collection('PhotoMapData').add({
"map_idx": photoMap.mapIdx,
"map_user_idx": photoMap.mapUserIdx,
"map_type": photoMap.mapType,
"map_name": photoMap.mapName,
"map_snapshot": photoMap.mapSnapshot,
"map_state": photoMap.mapState,
});
}

Future<List<PhotoMap>> getPhotoMap(int userIdx) async {
List<PhotoMap> results = [];
var querySnapshot = await FirebaseFirestore.instance.collection('PhotoMapData')
.where('map_user_idx', isEqualTo: userIdx)
.get();

for(var doc in querySnapshot.docs){
results.add(PhotoMap.fromData(doc.data()));
}
return results;
}

Future<void> uploadPhotoMapImage(Uint8List data, String imageName) async {
await FirebaseStorage.instance
.ref('image/photoMap/$imageName')
.putData(data);
}

Future<Image> getPhotoMapImage(String? path) async {
var imageURL =
await FirebaseStorage.instance.ref('image/photoMap/$path').getDownloadURL();
var image = Image.network(
imageURL,
fit: BoxFit.cover,
);
return image;
}

Future<void> changePhotoMapName(int idx, String newName) async {
var querySnapshot = await FirebaseFirestore.instance
.collection('PhotoMapData')
.where('map_idx', isEqualTo: idx)
.get();
var document = querySnapshot.docs.first;
document.reference.update({'map_name': newName});
}

Future<void> deletePhotoMap(int idx) async {
var querySnapshot = await FirebaseFirestore.instance
.collection('PhotoMapData')
.where('map_idx', isEqualTo: idx)
.get();
var document = querySnapshot.docs.first;
document.reference.delete();
}




54 changes: 52 additions & 2 deletions lib/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,56 @@ void dialogTitleWithContent(BuildContext context, String title, String content,
);
}

void dialogOnlyTitle(){

void dialogOnlyTitle(BuildContext context, String title,VoidCallback onCancle, VoidCallback onConfirm){
showDialog(
context: context,
builder: (context) {
return Dialog(
surfaceTintColor: ColorFamily.white,
backgroundColor: ColorFamily.white,
child: Wrap(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 30, 0, 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyleFamily.dialogButtonTextStyle,
),
const SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(
ColorFamily.gray)),
onPressed: onCancle,
child: const Text(
"취소",
style: TextStyleFamily.dialogButtonTextStyle,
)),
TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(
ColorFamily.gray)),
onPressed: onConfirm,
child: const Text(
"확인",
style:
TextStyleFamily.dialogButtonTextStyle_pink,
))
],
)
],
),
),
],
),
);
});
}
6 changes: 2 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import 'package:intl/date_symbol_data_local.dart';

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_naver_map/flutter_naver_map.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:woo_yeon_hi/model/user_model.dart';
import 'package:woo_yeon_hi/provider/user_provider.dart';
import 'package:woo_yeon_hi/routes/routes_generator.dart';
import 'package:woo_yeon_hi/screen/main_screen.dart';
import 'package:woo_yeon_hi/screen/register/register_screen.dart';
Expand All @@ -25,7 +23,7 @@ Future<void> main() async {
javaScriptAppKey: dotenv.env['KAKAO_JAVA_SCRIPT_APP_KEY'],
);
await NaverMapSdk.instance.initialize(
clientId: dotenv.env['NAVER_CLIENT_ID'],
clientId: dotenv.env['NAVER_MAP_CLIENT_ID'],
onAuthFailed: (ex){
print(ex);
}
Expand All @@ -35,7 +33,7 @@ Future<void> main() async {
);

// ko_KR 언어 설정을 위함
initializeDateFormatting().then((_) => runApp(const WooYeonHi()));
initializeDateFormatting().then((_) => runApp(const MainScreen(loginData: "loginData")));
}

class WooYeonHi extends StatefulWidget {
Expand Down
24 changes: 22 additions & 2 deletions lib/model/enums.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter_naver_map/flutter_naver_map.dart';

enum MapType {
KOREA_SEOUL(0, "서울", 'lib/assets/geojsons/korea_seoul.geojson'),
KOREA_FULL(1, "대한민국", 'lib/assets/geojsons/korea_full.geojson');
KOREA_SEOUL(0, "서울", 'lib/assets/images/korea_seoul.png',),
KOREA_FULL(1, "대한민국", 'lib/assets/images/korea_full.png');

final int type;
final String name;
Expand All @@ -19,6 +19,14 @@ enum MapType {
}
}

enum PhotoMapState{
STATE_NORMAL(0),
STATE_DELETE(1);

final int state; // 상태
const PhotoMapState(this.state);
}

enum OverlayInfo {
/// 서울 지도
KOREA_SEOUL(0, 37.5665, 126.9780, 9),
Expand Down Expand Up @@ -132,3 +140,15 @@ enum DiarySortState{
return result;
}
}

enum HistoryState{
STATE_NORMAL(0),
STATE_DELETE(1);

final int state; // 상태
const HistoryState(this.state);
}




40 changes: 40 additions & 0 deletions lib/model/history_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:cloud_firestore/cloud_firestore.dart';

class History {
int historyIdx; // 히스토리 번호
int historyMapIdx; // 포토맵 지도 번호
String historyPlaceName; // 히스토리 지명
GeoPoint historyLocation; // 히스토리 좌표
int historyUserIdx; // 히스토리 작성자 번호
String historyTitle; // 히스토리 제목
String historyDate; // 히스토리 작성일
String historyContent; // 히스토리 내용
List<dynamic> historyImage; // 히스토리 이미지 경로 배열
int historyState; // 히스토리 상태

History(
{required this.historyIdx,
required this.historyMapIdx,
required this.historyPlaceName,
required this.historyLocation,
required this.historyUserIdx,
required this.historyTitle,
required this.historyDate,
required this.historyContent,
required this.historyImage,
required this.historyState});

factory History.fromData(Map<String, dynamic> data) {
return History(
historyIdx: data['history_idx'],
historyMapIdx: data['history_map_idx'],
historyPlaceName: data['history_place_name'],
historyLocation: data['history_location'],
historyUserIdx: data['history_user_idx'],
historyTitle: data['history_title'],
historyDate: data['history_date'],
historyContent: data['history_content'],
historyImage: data['history_image'],
historyState: data['history_state']);
}
}
26 changes: 26 additions & 0 deletions lib/model/photo_map_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class PhotoMap{
int mapIdx; // 지도 번호
int mapUserIdx; // 지도 생성 유저 번호
int mapType; // 지도 유형
String mapName; // 지도 이름
String mapSnapshot; // 지도 사진 경로
int mapState; // 지도 상태

PhotoMap(
{required this.mapIdx,
required this.mapUserIdx,
required this.mapType,
required this.mapName,
required this.mapSnapshot,
required this.mapState});

factory PhotoMap.fromData(Map<String, dynamic> data){
return PhotoMap(
mapIdx: data['map_idx'],
mapUserIdx: data['map_user_idx'],
mapType: data['map_type'],
mapName: data['map_name'],
mapSnapshot: data['map_snapshot'],
mapState: data['map_state']);
}
}
2 changes: 2 additions & 0 deletions lib/model/place_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ class PlaceInfo {
required this.korNm,
});
}


Loading

0 comments on commit 67e5552

Please sign in to comment.