Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

参加者情報入力画面のロジックを書く #76

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/pages/input_participant_info/input_participant_info_page.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_state_notifier/flutter_state_notifier.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_controller.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_state.dart';
import 'package:morning_weakers/pages/input_participant_info/widgets/desired_occupation.dart';
import 'package:morning_weakers/pages/input_participant_info/widgets/schedule_candidate.dart';
import 'package:morning_weakers/pages/input_participant_info/widgets/working_days.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:morning_weakers/pages/input_participant_info/widgets/submit_btn.dart';

class InputParticipantInfoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
FirebaseUser userData;
print('input:$userData');
return Scaffold(
appBar: AppBar(
title: const Text('参加者情報入力'),
),
body: _inputParticipantInfo,
body: StateNotifierProvider<InputParticipantInfoController, InputParticipantInfoState>(
create: (_) => InputParticipantInfoController(),
child: _inputParticipantInfo,
),
);
}

Expand All @@ -29,7 +33,8 @@ class InputParticipantInfoPage extends StatelessWidget {
decoration: const InputDecoration(
labelText: '備考欄'
),
)
),
SubmitBtn(),
],
),
),
Expand Down
19 changes: 19 additions & 0 deletions lib/pages/input_participant_info/input_participant_info_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:morning_weakers/models/models.dart';
part 'input_participant_info_state.freezed.dart';
part 'input_participant_info_state.g.dart';

@freezed
abstract class InputParticipantInfoState with _$InputParticipantInfoState {
const factory InputParticipantInfoState({
// Participant Model
@JsonKey(name: 'desired_occupations') List<TechnicalStack> desiredOccupations,
@JsonKey(name: 'working_days') int workingDays,
String note,
// Questionnaire Model
@required @JsonKey(name: 'schedule_candidate') List<ScheduleCandidate> scheduleCandidates,
}) = _InputParticipantInfoState;

factory InputParticipantInfoState.fromJson(Map<String, dynamic> json) => _$InputParticipantInfoStateFromJson(json);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_controller.dart';

class DesiredOccupation extends StatelessWidget {
final List<String> desires = ['参加希望職種(第1希望)', '参加希望職種(第2希望)', '参加希望職種(第3希望)' ];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_controller.dart';

class ScheduleCandidate extends StatelessWidget {
final List<String> scheduleCandidates = [
Expand All @@ -19,7 +21,7 @@ class ScheduleCandidate extends StatelessWidget {
children: scheduleCandidates.map(
(scheduleCandidate) => CheckboxListTile(
value: false,
// onChanged: _handleCheckbox(),
// onChanged: context.read<InputParticipantInfoController>().setDesiredOccupationsState(value),
activeColor: Theme.of(context).primaryColor,
title: Text(scheduleCandidate),
),
Expand Down
15 changes: 15 additions & 0 deletions lib/pages/input_participant_info/widgets/submit_btn.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_controller.dart';

class SubmitBtn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlatButton(
child: const Text('OK'),
color: Theme.of(context).accentColor,
onPressed: () async {
await context.read<InputParticipantInfoController>().handlePostParticipantInfo();
});
}
}
4 changes: 3 additions & 1 deletion lib/pages/input_participant_info/widgets/working_days.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:morning_weakers/pages/input_participant_info/input_participant_info_controller.dart';

class WorkingDays extends StatelessWidget {
final List<String> workingDays = ['1', '2', '3', '4', '5'];
Expand All @@ -9,7 +11,7 @@ class WorkingDays extends StatelessWidget {
padding: const EdgeInsets.all(8),
child: Column(
children: <Widget>[
const Text('参加可能日程(複数選択可)'),
const Text('稼働可能日数(目安でOKです😃)'),
Column(
children: workingDays.map(
(workingDay) => ListTile(
Expand Down