Skip to content

Commit

Permalink
feat(confirm layout): add confirm page, add navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
TriangleYJ committed Feb 25, 2022
1 parent bae78a2 commit d0b034d
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 28 deletions.
16 changes: 9 additions & 7 deletions lib/screens/main/friend_recommendation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ class _UserRecommendationScreenState extends State<UserRecommendationScreen> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Column(
children: [
const SizedBox(height: 60.0), // TODO: add filter button
UserProfileView(userProfile: userProfile),
const SizedBox(height: 30.0),
FriendDecisionButtons(callback: changeUserProfile),
],
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 60.0), // TODO: add filter button
UserProfileView(userProfile: userProfile),
const SizedBox(height: 30.0),
FriendDecisionButtons(callback: changeUserProfile),
],
),
),
);
}
Expand Down
17 changes: 10 additions & 7 deletions lib/screens/main/user_profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ class FriendPreference extends StatelessWidget {
const SizedBox(
width: 10.0,
),
Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8.0,
runSpacing: 4.0,
children: <Widget>[for (String p in preference) ColorChip(text: p)],
)
Container(
width: 200,
child: Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8.0,
runSpacing: 4.0,
children: <Widget>[for (String p in preference) ColorChip(text: p)],
),
),
],
);
}
Expand Down
72 changes: 72 additions & 0 deletions lib/screens/register/register_confirm.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:kai_friends_app/assets/constants.dart';
import 'package:kai_friends_app/main.dart';
import 'package:kai_friends_app/screens/main/sample_users.dart';
import 'package:kai_friends_app/screens/main/user.dart';
import 'package:kai_friends_app/screens/main/user_profile_view.dart';
import 'package:kai_friends_app/widgets/main_button.dart';

class RegisterConfirm extends StatelessWidget {
Map<String, dynamic> myInfo;
Map<String, Set<String>> friendInfo;

RegisterConfirm({Key? key, required this.myInfo, required this.friendInfo})
: super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 60.0),
UserProfileView(
userProfile: UserProfile(
profileImage: 'images/profile_picture.png',
// TODO: receive profile image from register_myinfo
major: majorList[myInfo["major"]],
year: myInfo["enterYear"],
selfIntroduction: myInfo["intro"],
//TODO
mentorPreference: [
...(friendInfo["mentor"]!.map((String x) => "멘토: " + x)),
...(friendInfo["mentee"]!.map((String x) => "멘티: " + x))
],
majorPreference: friendInfo["major"]!.toList(),
classPreference: friendInfo["class"]!.toList(),
interestPreference: friendInfo["interest"]!.toList(),
),
),
const SizedBox(height: 30.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconMainButton(
name: '수정',
f: () {
Navigator.pop(context);
},
icon: Icons.navigate_before,
),
IconMainButton(
name: '완료',
f: () {
print(myInfo);
print(friendInfo);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => KaiFriendsApp()),
(Route<dynamic> route) => false);
},
icon: Icons.navigate_next,
),
],
),
],
),
),
),
);
}
}
32 changes: 23 additions & 9 deletions lib/screens/register/register_friendinfo.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:kai_friends_app/screens/register/register_confirm.dart';
import 'package:kai_friends_app/widgets/input/chip_input_box.dart';
import 'package:kai_friends_app/widgets/main_button.dart';
import 'package:kai_friends_app/widgets/top_app_bar.dart';

class RegisterFriendInfoPage extends StatefulWidget {
const RegisterFriendInfoPage({Key? key}) : super(key: key);
final Map<String, dynamic> myInfo;

const RegisterFriendInfoPage({Key? key, required this.myInfo})
: super(key: key);

@override
State<RegisterFriendInfoPage> createState() => _RegisterFriendInfoPageState();
Expand Down Expand Up @@ -49,7 +53,7 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
ChipInputBox(
id: 'friend_major',
labelText: '친구의 과정 / 학과',
stateSetter: (Set<String> val){
stateSetter: (Set<String> val) {
friendMajorSelected = val;
},
),
Expand All @@ -61,7 +65,7 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
ChipInputBox(
id: 'friend_class',
labelText: '친구의 수업',
stateSetter: (Set<String> val){
stateSetter: (Set<String> val) {
friendClassSelected = val;
},
),
Expand All @@ -73,7 +77,7 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
ChipInputBox(
id: 'friend_interest',
labelText: '친구의 관심분야',
stateSetter: (Set<String> val){
stateSetter: (Set<String> val) {
friendInterestSelected = val;
},
),
Expand All @@ -85,7 +89,7 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
ChipInputBox(
id: 'friend_mentor',
labelText: '분야',
stateSetter: (Set<String> val){
stateSetter: (Set<String> val) {
friendMentorSelected = val;
},
),
Expand All @@ -97,7 +101,7 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
ChipInputBox(
id: 'friend_mentee',
labelText: '분야',
stateSetter: (Set<String> val){
stateSetter: (Set<String> val) {
friendMenteeSelected = val;
},
),
Expand All @@ -107,19 +111,29 @@ class _RegisterFriendInfoPageState extends State<RegisterFriendInfoPage> {
children: [
IconMainButton(
name: '수정',
f: () => {},
f: () {
Navigator.pop(context);
},
icon: Icons.navigate_before,
),
IconMainButton(
name: '미리보기',
f: () {
print({
Map<String, Set<String>> friendInfo = {
"major": friendMajorSelected,
"class": friendClassSelected,
"interest": friendInterestSelected,
"mentor": friendMentorSelected,
"mentee": friendMenteeSelected,
});
};
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RegisterConfirm(
myInfo: widget.myInfo,
friendInfo: friendInfo,
)),
);
},
icon: Icons.navigate_next,
),
Expand Down
10 changes: 7 additions & 3 deletions lib/screens/register/register_myinfo.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:kai_friends_app/screens/register/register_friendinfo.dart';
import 'package:kai_friends_app/widgets/input/chip_input_box.dart';
import 'package:kai_friends_app/widgets/input/dropdown_input_box.dart';
import 'package:kai_friends_app/widgets/input/input_box.dart';
Expand Down Expand Up @@ -128,8 +129,7 @@ class _RegisterMyInfoPageState extends State<RegisterMyInfoPage> {
name: '다음',
icon: Icons.navigate_next,
f: () {
//TODO: test form serializing
print({
Map<String, dynamic> myInfo = {
"gender": genderSelected,
"age": ageController.text,
"enterYear": enterYearController.text,
Expand All @@ -139,7 +139,11 @@ class _RegisterMyInfoPageState extends State<RegisterMyInfoPage> {
"clubs": clubSelected,
"classes": classSelected,
"intro": introController.text,
});
};
Navigator.push(
context,
MaterialPageRoute(builder: (context) => RegisterFriendInfoPage(myInfo: myInfo)),
);
},
),
const SizedBox(height: 20),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/color_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ColorChip extends StatelessWidget {
)
: null,
onDeleted: onDeleted != null
? () => onDeleted!(text ?? 'chip')
? () => onDeleted!(text)
: null, // TODO(fix): This code is buggy: chips must be in a set (no duplicates)
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/top_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TopAppBar extends StatelessWidget with PreferredSizeWidget {
actions: actions,
elevation: 0,
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:kai_friends_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
await tester.pumpWidget(KaiFriendsApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit d0b034d

Please sign in to comment.