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

taxiDialog 리팩토링 #71

Merged
merged 22 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
Expand Down
7 changes: 7 additions & 0 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "package:dio/dio.dart";
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:taxiapp/utils/remoteConfigController.dart';

Expand All @@ -9,3 +10,9 @@ final BaseOptions connectionOptions = BaseOptions(
connectTimeout: Duration(seconds: 150),
receiveTimeout: Duration(seconds: 130),
);

const defaultDialogPadding = Padding(padding: EdgeInsets.all(15));

const defaultDialogButtonSize = Size(150, 45);

final defaultDialogButtonBorderRadius = BorderRadius.circular(12.0);
53 changes: 53 additions & 0 deletions lib/constants/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

//primaryColor 지정 (색상코드: #6E3647)
final Map<int, Color> primaryColor1 = {
50: const Color.fromRGBO(110, 54, 120, .1),
100: const Color.fromRGBO(110, 54, 120, .2),
200: const Color.fromRGBO(110, 54, 120, .3),
300: const Color.fromRGBO(110, 54, 120, .4),
400: const Color.fromRGBO(110, 54, 120, .5),
500: const Color.fromRGBO(110, 54, 120, .6),
600: const Color.fromRGBO(110, 54, 120, .7),
700: const Color.fromRGBO(110, 54, 120, .8),
800: const Color.fromRGBO(110, 54, 120, .9),
900: const Color.fromRGBO(110, 54, 120, 1),
};
MaterialColor taxiPrimaryColor = MaterialColor(0xFF6E3678, primaryColor1);

ThemeData buildTheme() {
final base = ThemeData(
primarySwatch: taxiPrimaryColor,
primaryColor: const Color(0xFF6E3678),
textTheme: TextTheme(
//Dialog 제목
titleMedium: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF323232),
fontSize: 22,
fontWeight: FontWeight.normal)),

//Dialog 상세 설명
bodySmall: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF888888),
fontSize: 12,
fontWeight: FontWeight.bold)),

//Dialog Elevated 버튼 텍스트
labelLarge: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFFEEEEEE),
fontSize: 13,
fontWeight: FontWeight.bold)),

//Dialog Elevated 버튼 텍스트
labelMedium: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFFC8C8C8),
fontSize: 13,
fontWeight: FontWeight.normal))),
);
return base;
}
7 changes: 3 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:taxiapp/utils/token.dart';
import 'package:taxiapp/views/taxiView.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:taxiapp/firebase_options.dart';
import 'constants/theme.dart';

late AndroidNotificationChannel channel;
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
Expand Down Expand Up @@ -82,11 +83,9 @@ class MyHome extends HookWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Taxi App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
theme: buildTheme(),
home: Container(
color: const Color(0xFF6E3647),
color: Theme.of(context).primaryColor,
child: Container(
color: Colors.white,
child: TaxiView(),
Expand Down
37 changes: 15 additions & 22 deletions lib/views/taxiDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:open_store/open_store.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:taxiapp/constants/constants.dart';

class TaxiDialog extends StatelessWidget {
late Set<Widget> boxContent;
Expand All @@ -20,37 +20,31 @@ class TaxiDialog extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: 350,
height: 165,
height: 172,
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(15)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Padding(padding: EdgeInsets.all(15)),
defaultDialogPadding,
...boxContent,
const Padding(
padding: EdgeInsets.all(15),
),
defaultDialogPadding,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0.5,
fixedSize: const Size(150, 45),
fixedSize: defaultDialogButtonSize,
backgroundColor: const Color(0xFFFAF8FB),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
borderRadius: defaultDialogButtonBorderRadius,
side: const BorderSide(color: Colors.white),
),
),
child: Text(leftButtonContent,
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFFC8C8C8),
fontSize: 13,
fontWeight: FontWeight.normal))),
style: Theme.of(context).textTheme.labelMedium),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 깔끔해지네요 ㅎ

onPressed: () async {
if (Platform.isIOS) {
exit(0);
Expand All @@ -63,29 +57,28 @@ class TaxiDialog extends StatelessWidget {
),
OutlinedButton(
style: ButtonStyle(
fixedSize: MaterialStateProperty.all(const Size(150, 45)),
fixedSize:
MaterialStateProperty.all(defaultDialogButtonSize),
backgroundColor: MaterialStateProperty.all<Color>(
const Color(0xFF6E3678)),
Theme.of(context).primaryColor),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
borderRadius: defaultDialogButtonBorderRadius,
side: const BorderSide(color: Colors.black),
),
),
),
child: Text(rightButtonContent,
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFFEEEEEE),
fontSize: 13,
fontWeight: FontWeight.bold))),
style: Theme.of(context).textTheme.labelLarge),
onPressed: () async {
OpenStore.instance.open(
androidAppBundleId: dotenv.get("ANDROID_APPID"),
appStoreId: dotenv.get("IOS_APPID"));
}),
],
)
),
//하단 패딩
const Padding(padding: EdgeInsets.only(bottom: 15)),
]),
);
}
Expand Down
69 changes: 26 additions & 43 deletions lib/views/taxiView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import 'dart:async';
import 'dart:io';

import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:package_info/package_info.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:taxiapp/utils/fcmToken.dart';
Expand Down Expand Up @@ -459,7 +456,7 @@ class TaxiView extends HookWidget {
}),
)),
isTimerUp.value && isLoaded.value && isFcmInit.value
? Stack()
? const Stack()
: Scaffold(
body: FadeTransition(opacity: animation, child: loadingView())),
isMustUpdate.value
Expand All @@ -471,38 +468,31 @@ class TaxiView extends HookWidget {
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: "새로운 ",
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF323232),
fontSize: 22,
fontWeight: FontWeight.bold)),
style: Theme.of(context).textTheme.titleMedium,
children: const <TextSpan>[
TextSpan(text: "버전"),
TextSpan(
text: "이 ",
style: TextStyle(fontWeight: FontWeight.normal)),
text: "새로운 버전",
style: TextStyle(fontWeight: FontWeight.bold),
),
TextSpan(text: "이 "),
TextSpan(
text: "출시",
style: TextStyle(color: Color(0xFF6E3678))),
TextSpan(
text: "되었습니다!",
style: TextStyle(fontWeight: FontWeight.normal))
style: TextStyle(
color: Color(
0xFF6E3678), // TODO: primaryColor로 지정
fontWeight: FontWeight.bold)),
TextSpan(text: "되었습니다!")
]),
),
Text("정상적인 사용을 위해 앱을 업데이트 해주세요.",
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF888888),
fontSize: 12,
fontWeight: FontWeight.bold))),
style: Theme.of(context).textTheme.bodySmall),
},
rightButtonContent: "업데이트 하러가기",
leftButtonContent: "앱 종료하기",
)),
)
: Stack(),
: const Stack(),
isServerError.value
? Container(
color: const Color(0x66C8C8C8),
Expand All @@ -512,39 +502,32 @@ class TaxiView extends HookWidget {
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: "서버",
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF323232),
fontSize: 22,
fontWeight: FontWeight.bold)),
style: Theme.of(context).textTheme.titleMedium,
children: const <TextSpan>[
TextSpan(text: "와의 "),
TextSpan(
text: "연결에 ",
style: TextStyle(fontWeight: FontWeight.normal)),
text: "서버와의 ",
style: TextStyle(fontWeight: FontWeight.bold),
),
TextSpan(text: "연결에 "),
TextSpan(
text: "실패",
style: TextStyle(color: Color(0xFF6E3678))),
TextSpan(
text: "했습니다.",
style: TextStyle(fontWeight: FontWeight.normal))
style: TextStyle(
color: Color(
0xFF6E3678), // TODO: primaryColor로 지정
fontWeight: FontWeight.bold)),
TextSpan(text: "했습니다.")
]),
),
Padding(padding: EdgeInsets.only(top: 5)),
const Padding(padding: EdgeInsets.only(top: 5)),
Text("일시적인 오류일 수 있습니다.",
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
textStyle: const TextStyle(
color: Color(0xFF888888),
fontSize: 12,
fontWeight: FontWeight.bold))),
style: Theme.of(context).textTheme.bodySmall),
},
rightButtonContent: "스토어로 가기",
leftButtonContent: "앱 종료하기",
)),
)
: Stack()
: const Stack()
]));
}

Expand Down