Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #186 from 2rabs/feature/ui_create_entrance
Browse files Browse the repository at this point in the history
✨ 仮登録ページとコントローラーを作成
  • Loading branch information
tatsutakein authored May 13, 2023
2 parents fc4cd0f + 470f327 commit b1152c3
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 20 deletions.
14 changes: 14 additions & 0 deletions apps/frontend/lib/src/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class LoginRoute extends GoRouteData {
onLoginSucceeded: () {
const RootRoute().push(context);
},
goEntrancePage: () {
const EntrancePageRoute().push(context);
},
);
}

Expand All @@ -61,3 +64,14 @@ class ScheduleListRoute extends GoRouteData {
@override
build(BuildContext context, GoRouterState state) => const SchedulePage();
}

/// 仮登録ページルート
@TypedGoRoute<EntrancePageRoute>(
path: '/entrance',
)
class EntrancePageRoute extends GoRouteData {
const EntrancePageRoute();

@override
build(BuildContext context, GoRouterState state) => const EntrancePage();
}
22 changes: 22 additions & 0 deletions apps/frontend/lib/src/router/router.g.dart

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

2 changes: 1 addition & 1 deletion packages/core/data/lib/core_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export 'src/auth/fake_auth_repository.dart';
export 'src/di/data_provider.dart';
export 'src/member/member_repository.dart';
export 'src/schedule/schedule_repository.dart';
export 'src/participation/data_participation_repository.dart';
export 'src/participation/participation_repository.dart';
export 'src/entrance/entrance_repository.dart';
1 change: 1 addition & 0 deletions packages/core/styleguide/lib/src/icon/nito_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import 'package:flutter/material.dart';
class NitoIcons {
static const IconData email = Icons.email_outlined;
static const IconData password = Icons.password_outlined;
static const IconData name = Icons.person_outline;
}
7 changes: 5 additions & 2 deletions packages/feature/auth/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ class LoginPageTest extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return const MaterialApp(
home: LoginPage(),
return MaterialApp(
home: LoginPage(
onLoginSucceeded: () {},
goEntrancePage: () {},
),
);
}
}
1 change: 1 addition & 0 deletions packages/feature/auth/lib/feature_auth.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'src/login/login_page.dart';
export 'src/entrance/ui/entrance_page.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:core_data/core_data.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'entrance_form_controller.freezed.dart';
part 'entrance_form_controller.g.dart';

@freezed
class EntranceFormState with _$EntranceFormState {
factory EntranceFormState({
@Default(false) bool isLoading,
@Default(false) bool isSuccess,
@Default('') String errorMessage,
}) = _EntranceFormState;
}

@riverpod
class EntranceFormControl extends _$EntranceFormControl {
@override
EntranceFormState build() {
ref.onDispose(_dispose);
return EntranceFormState();
}

final emailController = TextEditingController();
final nicknameController = TextEditingController();

// 会員登録リクエストを送信する
Future<void> sendRequest() async {
// 送信中は、送信できないようにする
if (!state.isLoading) {
try {
state = state.copyWith(isLoading: true);
await ref.watch(entranceRepositoryProvider).register(
nicknameController.text,
emailController.text,
);
state = state.copyWith(isLoading: false, isSuccess: true);
} on Exception catch (e) {
state = state.copyWith(
isLoading: false,
errorMessage: e.toString(),
);
}
}
}
void _dispose() {
emailController.dispose();
nicknameController.dispose();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'entrance_form_controller.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

/// @nodoc
mixin _$EntranceFormState {
bool get isLoading => throw _privateConstructorUsedError;
bool get isSuccess => throw _privateConstructorUsedError;
String get errorMessage => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$EntranceFormStateCopyWith<EntranceFormState> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $EntranceFormStateCopyWith<$Res> {
factory $EntranceFormStateCopyWith(
EntranceFormState value, $Res Function(EntranceFormState) then) =
_$EntranceFormStateCopyWithImpl<$Res, EntranceFormState>;
@useResult
$Res call({bool isLoading, bool isSuccess, String errorMessage});
}

/// @nodoc
class _$EntranceFormStateCopyWithImpl<$Res, $Val extends EntranceFormState>
implements $EntranceFormStateCopyWith<$Res> {
_$EntranceFormStateCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? isLoading = null,
Object? isSuccess = null,
Object? errorMessage = null,
}) {
return _then(_value.copyWith(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isSuccess: null == isSuccess
? _value.isSuccess
: isSuccess // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: null == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}

/// @nodoc
abstract class _$$_EntranceFormStateCopyWith<$Res>
implements $EntranceFormStateCopyWith<$Res> {
factory _$$_EntranceFormStateCopyWith(_$_EntranceFormState value,
$Res Function(_$_EntranceFormState) then) =
__$$_EntranceFormStateCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool isLoading, bool isSuccess, String errorMessage});
}

/// @nodoc
class __$$_EntranceFormStateCopyWithImpl<$Res>
extends _$EntranceFormStateCopyWithImpl<$Res, _$_EntranceFormState>
implements _$$_EntranceFormStateCopyWith<$Res> {
__$$_EntranceFormStateCopyWithImpl(
_$_EntranceFormState _value, $Res Function(_$_EntranceFormState) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? isLoading = null,
Object? isSuccess = null,
Object? errorMessage = null,
}) {
return _then(_$_EntranceFormState(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isSuccess: null == isSuccess
? _value.isSuccess
: isSuccess // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: null == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
class _$_EntranceFormState implements _EntranceFormState {
_$_EntranceFormState(
{this.isLoading = false, this.isSuccess = false, this.errorMessage = ''});

@override
@JsonKey()
final bool isLoading;
@override
@JsonKey()
final bool isSuccess;
@override
@JsonKey()
final String errorMessage;

@override
String toString() {
return 'EntranceFormState(isLoading: $isLoading, isSuccess: $isSuccess, errorMessage: $errorMessage)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_EntranceFormState &&
(identical(other.isLoading, isLoading) ||
other.isLoading == isLoading) &&
(identical(other.isSuccess, isSuccess) ||
other.isSuccess == isSuccess) &&
(identical(other.errorMessage, errorMessage) ||
other.errorMessage == errorMessage));
}

@override
int get hashCode =>
Object.hash(runtimeType, isLoading, isSuccess, errorMessage);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_EntranceFormStateCopyWith<_$_EntranceFormState> get copyWith =>
__$$_EntranceFormStateCopyWithImpl<_$_EntranceFormState>(
this, _$identity);
}

abstract class _EntranceFormState implements EntranceFormState {
factory _EntranceFormState(
{final bool isLoading,
final bool isSuccess,
final String errorMessage}) = _$_EntranceFormState;

@override
bool get isLoading;
@override
bool get isSuccess;
@override
String get errorMessage;
@override
@JsonKey(ignore: true)
_$$_EntranceFormStateCopyWith<_$_EntranceFormState> get copyWith =>
throw _privateConstructorUsedError;
}

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

Loading

0 comments on commit b1152c3

Please sign in to comment.