Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into #380-edit-design
  • Loading branch information
godeka committed May 29, 2024
2 parents b2e71e3 + d288e2d commit 567eae9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 39 deletions.
9 changes: 7 additions & 2 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,16 @@ class _MyHomePageState extends State<MyHomePage> {
// 로그인된 상태이면 - 유저 목록 post, sub 요청
if (userToken != null) {
// http post 요청
getAllUsers(userToken!, cafeList).then((value) {
getAllUsers(userToken!, cafeList, userProfile.userId!).then((value) {
allUsers.setAllUsers(value);

// 주변 모든 카페에 sub 요청
subCafeList(stompClient, cafeList, allUsers);
subCafeList(
stompClient: stompClient,
cafeList: cafeList,
allUsers: allUsers,
userId: userProfile.userId!,
);
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/lib/model/all_users_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class AllUsersModel extends ChangeNotifier {
}

void addUser(String cafeId, UserModel user) {
allUsers[cafeId]!.add(user);
// 중복 체크 후 추가
if (allUsers[cafeId]!.contains(user) == false) {
allUsers[cafeId]!.add(user);
}
notifyListeners();
}

Expand Down
32 changes: 14 additions & 18 deletions frontend/lib/screen/cafe_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class _CafeDetailsState extends State<CafeDetails>
String photoUrl = '';

late AutoOfflineService autoOfflineService;
late UserProfileModel userProfile;
late List<UserModel> userList;
late MyCafeModel myCafe;
late MatchingInfoModel matchingInfo;
Expand Down Expand Up @@ -153,7 +152,6 @@ class _CafeDetailsState extends State<CafeDetails>
autoOfflineService =
Provider.of<AutoOfflineService>(context, listen: false);
stompClient = Provider.of<StompClient>(context);
userProfile = Provider.of<UserProfileModel>(context);
userList = Provider.of<AllUsersModel>(context).getUserList(widget.cafeId);
myCafe = Provider.of<MyCafeModel>(context);
matchingInfo = Provider.of<MatchingInfoModel>(context);
Expand Down Expand Up @@ -230,20 +228,18 @@ class _CafeDetailsState extends State<CafeDetails>
ListView.builder(
itemCount: userList.length,
itemBuilder: (context, index) {
return (userList[index].userId == userProfile.userId)
? Container()
: UserItem(
type: "cafeUser",
userId: userList[index].userId,
nickname: userList[index].nickname,
company: userList[index].company,
position: userList[index].position,
introduction: userList[index].introduction,
rating: userList[index].rating,
matchId: '', // 안 쓰는 값이기에 초기값 넣어줌
logoUrl: '',
requestTypeId: 0, // 안 쓰는 값이기에 초기값 넣어줌
);
return UserItem(
type: "cafeUser",
userId: userList[index].userId,
nickname: userList[index].nickname,
company: userList[index].company,
position: userList[index].position,
introduction: userList[index].introduction,
rating: userList[index].rating,
matchId: '', // 안 쓰는 값이기에 초기값 넣어줌
logoUrl: '',
requestTypeId: 0, // 안 쓰는 값이기에 초기값 넣어줌
);
},
),
(myCafe.cafeId != null)
Expand Down Expand Up @@ -272,8 +268,8 @@ class _CafeDetailsState extends State<CafeDetails>
builder: (context) {
bool setOrChange = myCafe.cafeId == null ? true : false;
String content = setOrChange
? "${widget.cafeName}을(를) 위치로 표시하겠습니까?"
: "${widget.cafeName}을(를) 내 위치로 표시하도록 변경하겠습니까?";
? "${widget.cafeName}을(를) \n 위치로 표시하시겠습니까?"
: "${widget.cafeName}을(를) 내 위치로 \n표시하도록 변경하시겠습니까?";

return YesOrNoDialog(
content: content,
Expand Down
21 changes: 8 additions & 13 deletions frontend/lib/screen/coffeechat_req_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,15 @@ class _SentReqState extends State<SentReq> {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
return OneButtonDialog(
content:
const Text('제한 시간이 완료되었습니다.\n다시 매칭 요청을 진행해주세요.'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
setState(() {
_sendinfoFuture = sendinfo();
});
},
child: const Text('확인'),
),
],
'10분이 지나 요청이 자동으로 취소되었어요!\n다시 커피챗 요청을 진행해주세요.',
onFirstButtonClick: () {
Navigator.of(context).pop();
setState(() {
_sendinfoFuture = sendinfo();
});
},
);
},
);
Expand Down
8 changes: 5 additions & 3 deletions frontend/lib/service/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const storage = FlutterSecureStorage();

// 주변 카페에 있는 모든 유저 목록 받아오기 - http post 요청
Future<Map<String, List<UserModel>>> getAllUsers(
String userToken, List<String> cafeList) async {
String userToken, List<String> cafeList, int userId) async {
try {
final url = Uri.parse("$baseUrl/cafe/get-users");
final response = await http.post(
Expand All @@ -32,8 +32,10 @@ Future<Map<String, List<UserModel>>> getAllUsers(
jsonResult.forEach((cafe, userList) {
List<Map<String, dynamic>> userMapList =
userList.cast<Map<String, dynamic>>();
allUsers[cafe] =
userMapList.map((user) => UserModel.fromJson(user)).toList();
allUsers[cafe] = userMapList
.where((user) => user["userId"] != userId)
.map((user) => UserModel.fromJson(user))
.toList();
});

return allUsers;
Expand Down
13 changes: 11 additions & 2 deletions frontend/lib/service/stomp_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import 'package:frontend/widgets/dialog/one_button_dialog.dart';
import 'package:stomp_dart_client/stomp.dart';

// cafe list의 각 cafe에 sub 요청
void subCafeList(
StompClient stompClient, List<String> cafeList, AllUsersModel allUsers) {
void subCafeList({
required StompClient stompClient,
required List<String> cafeList,
required AllUsersModel allUsers,
required int userId,
}) {
if (!stompClient.connected) {
throw Exception("stompClient is not connected !!");
}
Expand All @@ -20,6 +24,11 @@ void subCafeList(
// sub 응답 처리
Map<String, dynamic> result = jsonDecode(frame.body!);

// 자기 자신에 대한 sub은 무시
if (result["userId"] == userId) {
return;
}

// 카페에 사용자 add
if (result["type"] == "add") {
print("add user in cafe $cafeId");
Expand Down
3 changes: 3 additions & 0 deletions frontend/lib/widgets/dialog/yn_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class YesOrNoDialog extends StatelessWidget {
final Function()? handleSecondClick;

const YesOrNoDialog({
super.key,
this.content = '',
this.firstButton,
this.secondButton,
Expand All @@ -25,9 +26,11 @@ class YesOrNoDialog extends StatelessWidget {
borderRadius: BorderRadius.circular(20),
),
child: Container(
constraints: const BoxConstraints(minHeight: 200),
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const SizedBox(
height: 15,
Expand Down

0 comments on commit 567eae9

Please sign in to comment.