Skip to content

Commit

Permalink
Merge pull request #57 from GDSC-DGU/refactor/all
Browse files Browse the repository at this point in the history
♻️Refactor :  리펙토링 코드 1차 적용
  • Loading branch information
seochan99 authored May 2, 2024
2 parents eb0f5b3 + a17ece8 commit 2bf49d8
Show file tree
Hide file tree
Showing 59 changed files with 848 additions and 1,057 deletions.
6 changes: 6 additions & 0 deletions assets/icons/Group 8.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/TimeCircle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/book.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icons/done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions lib/bindings/language_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:earlips/viewModels/user/user_viewmodel.dart';
import 'package:get/get.dart';

class LanguageBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<UserViewModel>(() => UserViewModel());
}
}
2 changes: 2 additions & 0 deletions lib/bindings/root_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:get/get.dart';
import 'package:earlips/viewModels/home/home_viewmodel.dart';
import 'package:earlips/viewModels/root/root_viewmodel.dart';
import 'package:earlips/viewModels/study/study_viewmodel.dart';
import 'package:earlips/viewModels/realtime/real_create_viewmodel.dart';

class RootBinding extends Bindings {
@override
Expand All @@ -12,5 +13,6 @@ class RootBinding extends Bindings {
// ChildViewModel is singleton
Get.put(HomeViewModel());
Get.put(StudyViewModel());
Get.put(RealCreateViewModel());
}
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() async {
useOnlyLangCode: true,
supportedLocales: const [Locale('en'), Locale('ko')],
path: 'assets/translations',
fallbackLocale: const Locale('en'),
fallbackLocale: const Locale('ko'),
child: const MainApp(initialRoute: "/")));
}
22 changes: 7 additions & 15 deletions lib/main_app.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:earlips/languages.dart';
import 'package:earlips/utilities/style/color_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get/get.dart';
import 'package:earlips/bindings/root_binding.dart';
import 'views/root/root_screen.dart';
import 'utilities/app_routes.dart';

class MainApp extends StatelessWidget {
Expand All @@ -22,23 +21,16 @@ class MainApp extends StatelessWidget {
return GetMaterialApp(
title: "earlips",
translations: Languages(),
locale: Get.deviceLocale,
fallbackLocale: const Locale('en', 'US'),
locale: const Locale('ko', 'KR'),
fallbackLocale: const Locale('ko', 'KR'),
theme: ThemeData(
useMaterial3: true,
fontFamily: 'Pretendard',
colorSchemeSeed: Colors.blue,
scaffoldBackgroundColor: const Color(0xFFf6f6f8),
colorScheme: ColorSystem.createLightColorScheme(),
scaffoldBackgroundColor: ColorSystem.background, // More direct usage
),
initialRoute: Routes.HOME,
getPages: [
GetPage(
name: '/', page: () => const RootScreen(), binding: RootBinding()),
Routes.routes[1],
Routes.routes[2],
Routes.routes[3],
Routes.routes[4],
],
initialRoute: initialRoute,
getPages: Routes.routes,
);
}
}
10 changes: 9 additions & 1 deletion lib/utilities/app_routes.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// ignore_for_file: constant_identifier_names
import 'package:earlips/bindings/language_binding.dart';
import 'package:earlips/bindings/root_binding.dart';
import 'package:earlips/views/home/home_screen.dart';
import 'package:earlips/views/profile/profile_account/profile_account_screen.dart';
import 'package:earlips/views/profile/profile_language_setting/profile_language_setting.dart';
import 'package:earlips/views/profile/profile_screen.dart';
import 'package:earlips/views/root/root_screen.dart';
import 'package:earlips/views/study/study_main.dart';
import 'package:get/get.dart';

Expand All @@ -17,6 +20,11 @@ abstract class Routes {
static const STUDY = '/study';

static final routes = [
GetPage(
name: ROOT,
page: () => const RootScreen(),
binding: RootBinding(),
),
GetPage(
name: HOME,
page: () => HomeScreen(),
Expand All @@ -36,7 +44,7 @@ abstract class Routes {
GetPage(
name: PROFILE_LANGUAGE_SETTING,
page: () => const ProfileLanguageScreen(),
binding: LanguageBinding(),
),
// 다른 라우트들도 이곳에 추가할 수 있습니다.
];
}
4 changes: 2 additions & 2 deletions lib/utilities/base/supported_locale.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

const supportedLocale = [
Locale.fromSubtags(languageCode: 'ko'), // English
Locale.fromSubtags(languageCode: 'us'), // German
Locale.fromSubtags(languageCode: 'ko'), // korea
Locale.fromSubtags(languageCode: 'us'), // English
];
22 changes: 0 additions & 22 deletions lib/utilities/style/color_styles.dart

This file was deleted.

150 changes: 150 additions & 0 deletions lib/utilities/style/color_system.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import 'package:flutter/material.dart';

class ColorSystem {
// Tonal Palette
static const Map<int, Color> _tonalPalette = {
50: Color(0xFFE3F2FD),
100: Color(0xFFBBDEFB),
200: Color(0xFF90CAF9),
300: Color(0xFF64B5F6),
400: Color(0xFF42A0F2),
500: Color(0xFF1DA1FA),
600: Color(0xFF1A94E6),
700: Color(0xFF1887D2),
800: Color(0xFF157ABC),
900: Color(0xFF126E99),
};
static const Color main = Color(0xFF1DA1FA);
static const Color main2 = Color(0xFF1FA9DC);
static const Color sub1 = Color(0xFF5588FD);
static const Color sub2 = Color(0xFFC1D2FF);
static const Color sub3 = Color(0xFFF1F5FE);

// Basic Colors
static Color primary = _tonalPalette[500]!;

static Color secondary = _tonalPalette[200]!;
static Color tertiary = _tonalPalette[100]!;
static Color primaryVariant = _tonalPalette[600]!;
static Color secondaryVariant = _tonalPalette[300]!;
static Color tertiaryVariant = _tonalPalette[400]!;
static const Color surface = Colors.white;
static const Color onSurface = Colors.black;
static const Color error = Colors.red;

// Neutral Colors
static const Color background = Color(0xFFF0F4F8);
static const Color black = Color(0xFF151515);
static const Color gray6 = Color(0xFF464655);
static const Color gray5 = Color(0xFF626272);
static const Color gray4 = Color(0xFF90909F);
static const Color gray3 = Color(0xFFC6C6CF);
static const Color gray2 = Color(0xFFE9E9EE);
static const Color gray1 = Color(0xFFF5F5F9);
static const Color white = Color(0xFFFFFFFF);

// Semantic Colors
static const Color success = Color(0xFF63DC68);
static const Color warning = Color(0xFFFFC100);
static const Color info = Color(0xFF1DA1FA);
static const Color accent = Color(0xFFD81B60); // Example accent color

// Color Getters
static Color getFromTonalPalette(int index) {
return _tonalPalette[index] ?? Colors.transparent;
}

// Material 3 ColorScheme Creation
static ColorScheme createColorScheme({
required Brightness brightness,
Color? primary,
Color? primaryVariant,
Color? secondary,
Color? secondaryVariant,
Color? tertiary,
Color? tertiaryVariant,
Color? background,
Color? surface,
Color? onBackground,
Color? onSurface,
Color? error,
}) {
return ColorScheme(
primary: primary ?? ColorSystem.primary,
onPrimary: onSurface ?? ColorSystem.onSurface,
secondary: secondary ?? ColorSystem.secondary,
onSecondary: onSurface ?? ColorSystem.onSurface,
surface: surface ?? ColorSystem.surface,
onSurface: onSurface ?? ColorSystem.onSurface,
background: background ?? ColorSystem.background,
onBackground: onBackground ?? ColorSystem.onSurface,
error: error ?? ColorSystem.error,
onError: onSurface ?? ColorSystem.onSurface,
brightness: brightness,
);
}

static ColorScheme createLightColorScheme({
Color? primary,
Color? primaryVariant,
Color? secondary,
Color? secondaryVariant,
Color? tertiary,
Color? tertiaryVariant,
Color? background,
Color? surface,
Color? onBackground,
Color? onSurface,
Color? error,
}) {
return createColorScheme(
brightness: Brightness.light,
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
tertiary: tertiary,
tertiaryVariant: tertiaryVariant,
background: background,
surface: surface,
onBackground: onBackground,
onSurface: onSurface,
error: error,
);
}

// dark
static ColorScheme createDarkColorScheme({
Color? primary,
Color? primaryVariant,
Color? secondary,
Color? secondaryVariant,
Color? tertiary,
Color? tertiaryVariant,
Color? background,
Color? surface,
Color? onBackground,
Color? onSurface,
Color? error,
}) {
return createColorScheme(
brightness: Brightness.dark,
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
tertiary: tertiary,
tertiaryVariant: tertiaryVariant,
background: background,
surface: surface,
onBackground: onBackground,
onSurface: onSurface,
error: error,
);
}

// Generate ThemeData using ColorScheme
static ThemeData generateThemeFromColorScheme(ColorScheme colorScheme) {
return ThemeData.from(colorScheme: colorScheme);
}
}
51 changes: 51 additions & 0 deletions lib/utilities/style/font_system.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';

class FontSystem {
static const TextStyle semiBold24 = TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w600,
height: 28 / 24,
);

static const TextStyle semiBold20 = TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
height: 24 / 20,
);

static const TextStyle medium20 = TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
height: 24 / 20,
);

static const TextStyle semiBold16 = TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
height: 20 / 16,
);

static const TextStyle regular16 = TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w400,
height: 24 / 16,
);

static const TextStyle semiBold12 = TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w600,
height: 16 / 12,
);

static const TextStyle regular12 = TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
height: 16 / 12,
);

static const TextStyle regular10 = TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w400,
height: 12 / 10,
);
}
Loading

0 comments on commit 2bf49d8

Please sign in to comment.