Skip to content

Commit

Permalink
(#42) Code refactoring
Browse files Browse the repository at this point in the history
- add some comments
- create AppTextField for reuse
- remove not used code
  • Loading branch information
giantsol committed Oct 10, 2019
1 parent 5fa4bdb commit 6c9e295
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 237 deletions.
3 changes: 1 addition & 2 deletions ios/Flutter/flutter_export_environment.sh
Expand Up @@ -2,10 +2,9 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/kakao/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/kakao/apps/Blue-Diary"
export "FLUTTER_TARGET=/Users/kakao/apps/Blue-Diary/lib/Main.dart"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/kakao/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "TRACK_WIDGET_CREATION=true"
4 changes: 1 addition & 3 deletions lib/Delegators.dart
Expand Up @@ -26,6 +26,4 @@ abstract class WeekBlocDelegator implements
ShowBottomSheetDelegator,
SetCurrentDrawerChildScreenItemDelegator,
ShowSnackBarDelegator,
SettingsChangedListenerDelegator {

}
SettingsChangedListenerDelegator { }
35 changes: 0 additions & 35 deletions lib/Localization.dart
Expand Up @@ -16,38 +16,29 @@ class AppLocalizations {
static const UNLOCK_FAIL = "unlockFail";
static const PASSWORD_CHANGED = "passwordChanged";
static const PASSWORD_UNCHANGED = "passwordUnchanged";

static const CANCEL = "cancel";
static const OK = "ok";
static const ADD = "add";
static const MODIFY = "modify";
static const CREATE = "new";

static const NO_TODOS = "noToDos";

static const CATEGORY = "category";
static const REMOVE_CATEGORY = "removeCategory";
static const REMOVE_CATEGORY_BODY = "removeCategoryBody";
static const CATEGORY_NONE = "categoryNone";

static const ADD_TASK = "addTask";
static const MODIFY_TASK = "modifyTask";

static const CHOOSE_PHOTO = "choosePhoto";

static const DRAWER_RECORD = "drawerRecord";
static const DRAWER_SETTINGS = "drawerSettings";
static const DRAWER_ABOUT = "drawerAbout";

static const SETTINGS = "settings";
static const SETTINGS_GENERAL = "settingsGeneral";
static const SETTINGS_DEFAULT_LOCK = "settingsDefaultLock";
static const SETTINGS_RESET_PASSWORD = "settingsResetPassword";
static const SETTINGS_RECOVERY_EMAIL = "settingsRecoveryEmail";
static const NO_RECOVERY_EMAIL = "noRecoveryEmail";

static const INVALID_EMAIL = "invalidEmail";

static const SEND_TEMP_PASSWORD = "sendTempPassword";
static const CONFIRM_SEND_TEMP_PASSWORD = "confirmSendTempPassword";
static const CONFIRM_SEND_TEMP_PASSWORD_BODY = "confirmSendTempPasswordBody";
Expand Down Expand Up @@ -75,38 +66,29 @@ class AppLocalizations {
UNLOCK_FAIL: 'Failed to unlock',
PASSWORD_CHANGED: 'Password changed!',
PASSWORD_UNCHANGED: 'Password not changed',

CANCEL: 'Cancel',
OK: 'Ok',
ADD: 'Add',
MODIFY: 'Modify',
CREATE: 'Create',

NO_TODOS: 'No TODO yet!',

CATEGORY: 'Category',
REMOVE_CATEGORY: 'Remove Category',
REMOVE_CATEGORY_BODY: 'Are you sure you want to remove this category?',
CATEGORY_NONE: 'None',

ADD_TASK: 'Add Task',
MODIFY_TASK: 'Modify Task',

CHOOSE_PHOTO: 'Choose Photo',

DRAWER_RECORD: 'Record',
DRAWER_SETTINGS: 'Settings',
DRAWER_ABOUT: 'About',

SETTINGS: 'Settings',
SETTINGS_GENERAL: 'General',
SETTINGS_DEFAULT_LOCK: 'Lock By Default',
SETTINGS_RESET_PASSWORD: 'Reset Password',
SETTINGS_RECOVERY_EMAIL: 'Recovery Email',
NO_RECOVERY_EMAIL: 'Please write your recovery email first',

INVALID_EMAIL: 'Invalid Email',

SEND_TEMP_PASSWORD: 'Send Temporary Password',
CONFIRM_SEND_TEMP_PASSWORD: 'Send Temporary Password',
CONFIRM_SEND_TEMP_PASSWORD_BODY: 'Your previous password will be overriden by temporary password, and will be sent to your recovery email.',
Expand All @@ -129,38 +111,29 @@ class AppLocalizations {
UNLOCK_FAIL: '잠금해제에 실패하였습니다',
PASSWORD_CHANGED: '비밀번호가 변경되었습니다!',
PASSWORD_UNCHANGED: '비밀번호가 변경되지 않았습니다.',

CANCEL: '취소',
OK: '확인',
ADD: '추가',
MODIFY: '수정',
CREATE: '생성',

NO_TODOS: '기록이 없습니다',

CATEGORY: '카테고리',
REMOVE_CATEGORY: '카테고리 삭제',
REMOVE_CATEGORY_BODY: '이 카테고리를 삭제하시겠습니까?',
CATEGORY_NONE: '없음',

ADD_TASK: '작업 추가',
MODIFY_TASK: '작업 수정',

CHOOSE_PHOTO: '사진 선택',

DRAWER_RECORD: '기록',
DRAWER_SETTINGS: '설정',
DRAWER_ABOUT: 'About',

SETTINGS: '설정',
SETTINGS_GENERAL: '일반',
SETTINGS_DEFAULT_LOCK: '디폴트로 잠금',
SETTINGS_RESET_PASSWORD: '비밀번호 재설정',
SETTINGS_RECOVERY_EMAIL: '복원 이메일',
NO_RECOVERY_EMAIL: '복원 이메일을 먼저 작성해주세요',

INVALID_EMAIL: '올바른 이메일 형식이 아닙니다',

SEND_TEMP_PASSWORD: '임시 비밀번호 발송',
CONFIRM_SEND_TEMP_PASSWORD: '임시 비밀번호 발송',
CONFIRM_SEND_TEMP_PASSWORD_BODY: '기존의 비밀번호가 임시 비밀번호로 바뀌고, 임시 비밀번호가 복원 이메일로 전송됩니다.',
Expand Down Expand Up @@ -188,34 +161,26 @@ class AppLocalizations {
String get unlockFail => _localizedValues[locale.languageCode][UNLOCK_FAIL];
String get passwordChanged => _localizedValues[locale.languageCode][PASSWORD_CHANGED];
String get passwordUnchanged => _localizedValues[locale.languageCode][PASSWORD_UNCHANGED];

String get cancel => _localizedValues[locale.languageCode][CANCEL];
String get ok => _localizedValues[locale.languageCode][OK];
String get add => _localizedValues[locale.languageCode][ADD];
String get modify => _localizedValues[locale.languageCode][MODIFY];
String get create => _localizedValues[locale.languageCode][CREATE];

String get noToDos => _localizedValues[locale.languageCode][NO_TODOS];

String get category => _localizedValues[locale.languageCode][CATEGORY];
String get removeCategory => _localizedValues[locale.languageCode][REMOVE_CATEGORY];
String get removeCategoryBody => _localizedValues[locale.languageCode][REMOVE_CATEGORY_BODY];
String get categoryNone => _localizedValues[locale.languageCode][CATEGORY_NONE];

String get addTask => _localizedValues[locale.languageCode][ADD_TASK];
String get modifyTask => _localizedValues[locale.languageCode][MODIFY_TASK];

String get choosePhoto => _localizedValues[locale.languageCode][CHOOSE_PHOTO];

String get settings => _localizedValues[locale.languageCode][SETTINGS];
String get settingsGeneral => _localizedValues[locale.languageCode][SETTINGS_GENERAL];
String get settingsDefaultLock => _localizedValues[locale.languageCode][SETTINGS_DEFAULT_LOCK];
String get settingsResetPassword => _localizedValues[locale.languageCode][SETTINGS_RESET_PASSWORD];
String get settingsRecoveryEmail => _localizedValues[locale.languageCode][SETTINGS_RECOVERY_EMAIL];
String get noRecoveryEmail => _localizedValues[locale.languageCode][NO_RECOVERY_EMAIL];

String get invalidEmail => _localizedValues[locale.languageCode][INVALID_EMAIL];

String get sendTempPassword => _localizedValues[locale.languageCode][SEND_TEMP_PASSWORD];
String get confirmSendTempPassword => _localizedValues[locale.languageCode][CONFIRM_SEND_TEMP_PASSWORD];
String get confirmSendTempPasswordBody => _localizedValues[locale.languageCode][CONFIRM_SEND_TEMP_PASSWORD_BODY];
Expand Down
4 changes: 3 additions & 1 deletion lib/presentation/App.dart
Expand Up @@ -8,7 +8,7 @@ import 'package:todo_app/Dependencies.dart';
import 'package:todo_app/Localization.dart';
import 'package:todo_app/presentation/home/HomeScreen.dart';

// 앱 프로세스에 상주하는 static dependency injection
// static dependency injection
Dependencies _sharedDependencies;
Dependencies get dependencies => _sharedDependencies;

Expand All @@ -30,6 +30,7 @@ class App extends StatelessWidget {
primaryColorDark: AppColors.PRIMARY_DARK,
accentColor: AppColors.SECONDARY,
splashColor: AppColors.RIPPLE,
// issue: https://github.com/giantsol/Blue-Diary/issues/44
textTheme: TextTheme(
subhead: TextStyle(
textBaseline: TextBaseline.alphabetic
Expand All @@ -46,6 +47,7 @@ class App extends StatelessWidget {
const Locale('ko'),
],
builder: (context, widget) {
// do NOT show red error screen in production build although there's an error
if (kReleaseMode) {
ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
return Container();
Expand Down
24 changes: 19 additions & 5 deletions lib/presentation/day/DayScreen.dart
Expand Up @@ -13,8 +13,7 @@ import 'package:todo_app/domain/entity/DayMemo.dart';
import 'package:todo_app/domain/entity/ToDoRecord.dart';
import 'package:todo_app/presentation/day/DayBloc.dart';
import 'package:todo_app/presentation/day/DayState.dart';
import 'package:todo_app/presentation/widgets/DayMemoTextField.dart';
import 'package:todo_app/presentation/widgets/ToDoEditorTextField.dart';
import 'package:todo_app/presentation/widgets/AppTextField.dart';

class DayScreen extends StatefulWidget {
final DateTime date;
Expand Down Expand Up @@ -292,10 +291,15 @@ class _DayMemo extends StatelessWidget {
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 12),
child: SizedBox(
height: 93,
child: DayMemoTextField(
child: AppTextField(
text: dayMemo.text,
textSize: 12,
textColor: AppColors.TEXT_WHITE,
hintText: dayMemo.hint,
hintTextSize: 12,
hintColor: AppColors.TEXT_WHITE_DARK,
onChanged: (s) => bloc.onDayMemoTextChanged(s),
maxLines: null,
),
),
) : const SizedBox.shrink(),
Expand Down Expand Up @@ -694,10 +698,15 @@ class _ToDoEditor extends StatelessWidget {
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 15),
child: ToDoEditorTextField(
child: AppTextField(
text: toDo.text,
textSize: 14,
textColor: AppColors.TEXT_BLACK,
hintText: editingToDoRecord.isDraft ? AppLocalizations.of(context).addTask : AppLocalizations.of(context).modifyTask ,
hintTextSize: 14,
hintColor: AppColors.TEXT_BLACK_LIGHT,
onChanged: (s) => bloc.onEditingToDoTextChanged(s),
autoFocus: true,
),
),
),
Expand Down Expand Up @@ -942,10 +951,15 @@ class _CategoryEditor extends StatelessWidget {
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 14),
child: ToDoEditorTextField(
child: AppTextField(
text: category.name,
textSize: 14,
textColor: AppColors.TEXT_BLACK,
hintText: AppLocalizations.of(context).category,
hintTextSize: 14,
hintColor: AppColors.TEXT_BLACK_LIGHT,
onChanged: (s) => bloc.onEditingCategoryTextChanged(s),
autoFocus: true,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/home/HomeBloc.dart
Expand Up @@ -47,7 +47,7 @@ class HomeBloc {
}

void onMenuIconClicked(ScaffoldState scaffoldState) {
scaffoldState?.openEndDrawer();
scaffoldState.openEndDrawer();
}

void setCurrentDrawerChildScreenItem(String key) {
Expand Down
5 changes: 1 addition & 4 deletions lib/presentation/home/HomeScreen.dart
Expand Up @@ -54,7 +54,6 @@ class _HomeScreenState extends State<HomeScreen> implements WeekBlocDelegator {
),
_SideMenuIcon(
bloc: _bloc,
scaffoldState: _scaffoldKey.currentState,
),
],
),
Expand Down Expand Up @@ -120,11 +119,9 @@ class _ChildScreen extends StatelessWidget {

class _SideMenuIcon extends StatelessWidget {
final HomeBloc bloc;
final ScaffoldState scaffoldState;

_SideMenuIcon({
@required this.bloc,
@required this.scaffoldState,
});

@override
Expand All @@ -139,7 +136,7 @@ class _SideMenuIcon extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15),
child: Image.asset('assets/ic_side_menu.png'),
),
onTap: () => bloc.onMenuIconClicked(scaffoldState),
onTap: () => bloc.onMenuIconClicked(Scaffold.of(context)),
),
),
);
Expand Down
9 changes: 7 additions & 2 deletions lib/presentation/week/WeekScreen.dart
Expand Up @@ -9,7 +9,7 @@ import 'package:todo_app/domain/entity/DayRecord.dart';
import 'package:todo_app/domain/entity/WeekRecord.dart';
import 'package:todo_app/presentation/week/WeekBloc.dart';
import 'package:todo_app/presentation/week/WeekState.dart';
import 'package:todo_app/presentation/widgets/CheckPointTextField.dart';
import 'package:todo_app/presentation/widgets/AppTextField.dart';

class WeekScreen extends StatefulWidget {
final WeekBlocDelegator weekBlocDelegator;
Expand Down Expand Up @@ -409,11 +409,16 @@ class _CheckPointItem extends StatelessWidget {
constraints: BoxConstraints(minHeight: 30,),
child: Container(
alignment: Alignment.center,
child: CheckPointTextField(
child: AppTextField(
focusNode: focusNodeProvider(checkPoint.key),
text: checkPoint.text,
textSize: 12,
textColor: AppColors.TEXT_WHITE,
hintText: checkPoint.hint,
hintTextSize: 12,
hintColor: AppColors.TEXT_WHITE_DARK,
onChanged: (s) => bloc.onCheckPointTextChanged(weekRecord, checkPoint, s),
maxLines: 2,
),
),
),
Expand Down

0 comments on commit 6c9e295

Please sign in to comment.