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

Add: pull to refresh 추가 #42

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e15a24f
Refactor: flutter notification version up
happycastle114 Mar 7, 2023
8d9b4fd
Merge branch 'main' into #34-add-push-navigation
happycastle114 Mar 21, 2023
a5d270b
Add: FCM message handler
happycastle114 Mar 21, 2023
42d7dbc
Add: Push Navigation
happycastle114 Mar 21, 2023
0fb8ef2
Fix: Init App Uri
happycastle114 Mar 21, 2023
7eae9f8
Try Fix Navigation
happycastle114 Mar 21, 2023
ff4b70e
Fix: 롤백
happycastle114 Mar 21, 2023
03f1d68
Refactor: Dream
happycastle114 Mar 21, 2023
3b800df
Add: Push State
happycastle114 Mar 21, 2023
9037678
Fix: fix state
happycastle114 Mar 21, 2023
e0d4c84
Refactor & Fix : inappwebview version up and state fix
happycastle114 Mar 21, 2023
096c215
Refactor&Fix&Add: handler 분리, foreground 상태 대응,
happycastle114 Mar 22, 2023
0e7b831
Fix: foreground 상태에서 onBackground 실행 문제 해결 / Firebase 14.1.0 이상 버전 발생 이슈
happycastle114 Mar 22, 2023
a17f3f1
Docs: messaging library version up
happycastle114 Mar 22, 2023
2f7b9ed
Fix: disable default notification system
happycastle114 Mar 22, 2023
650912a
Docs: add material library
happycastle114 Mar 28, 2023
05cd245
Fix: Virtual Keyboard Resize issue
happycastle114 Apr 3, 2023
8c4d21c
Refactor: remove unused libraries
happycastle114 Apr 3, 2023
edb96dd
Refactor: Remove and constants
happycastle114 Apr 3, 2023
ec93cae
Refactor: remove Unused imports and add pubspec.yaml
happycastle114 Apr 3, 2023
977257b
Refactor: Upgrade Libraries Version
happycastle114 Apr 4, 2023
f2212f1
Fix: Change Package Name
happycastle114 Apr 4, 2023
0851f02
Fix: Flutter InAppWebView Version Rollback to 5.x Because of iOS issue
happycastle114 Apr 4, 2023
47662ab
Refactor: Remove prints
happycastle114 Apr 4, 2023
3af5c84
Merge branch 'main' into #34-add-push-navigation
happycastle114 Apr 4, 2023
4d8f61b
Fix: Merge Error Fix
happycastle114 Apr 4, 2023
d9edea7
Add: pullToRefresh Controller
happycastle114 Apr 4, 2023
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
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ flutter {
}

dependencies {
implementation 'com.google.android.material:material:1.8.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -43,6 +46,7 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="org.sparcs.taxiapp" />
</intent-filter>
<intent-filter> <action android:name="FLUTTER_NOTIFICATION_CLICK" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>

</activity>
<!-- Don't delete the meta-data below.
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
running.

This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<style name="NormalTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
running.

This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<style name="NormalTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
10 changes: 6 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -216,6 +216,7 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -230,6 +231,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -339,7 +341,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -417,7 +419,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -466,7 +468,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@
</array>
</dict>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
6 changes: 3 additions & 3 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';

String address = dotenv.get("BACKEND_ADDRESS");

final BaseOptions ConnectionOptions = BaseOptions(
final BaseOptions connectionOptions = BaseOptions(
baseUrl: address,
connectTimeout: 15000,
receiveTimeout: 13000,
connectTimeout: Duration(seconds: 150),
receiveTimeout: Duration(seconds: 130),
);
68 changes: 13 additions & 55 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:taxiapp/utils/fcmToken.dart';
import 'package:taxiapp/utils/pushHandler.dart';
import 'package:taxiapp/utils/token.dart';
import 'package:taxiapp/views/taxiView.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
Expand All @@ -12,10 +14,10 @@ late AndroidNotificationChannel channel;
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

void main() async {
await dotenv.load(fileName: ".env");

WidgetsFlutterBinding.ensureInitialized();

await dotenv.load(fileName: ".env");

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Expand All @@ -27,30 +29,14 @@ void main() async {
importance: Importance.high,
);

var initializationSettingsAndroid =
const AndroidInitializationSettings('@mipmap/ic_launcher');

var initializationSettingsIOS = const IOSInitializationSettings(
requestAlertPermission: true,
requestBadgePermission: true,
requestSoundPermission: true,
);

flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);

var initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,
);

await flutterLocalNotificationsPlugin.initialize(
initializationSettings,
);
FirebaseMessaging.onBackgroundMessage(handleMessage);

await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
Expand All @@ -73,40 +59,10 @@ void main() async {

await FcmToken().init();

runApp(const MyApp());
}

class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
State<MyApp> createState() => _MyAppState();
runApp(MyHome());
}

class _MyAppState extends State<MyApp> {
@override
void initState() {
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
var androidNotiDetails = AndroidNotificationDetails(
channel.id, channel.name,
channelDescription: channel.description);

var iOSNotiDetails = const IOSNotificationDetails();

var details =
NotificationDetails(android: androidNotiDetails, iOS: iOSNotiDetails);

if (notification != null) {
flutterLocalNotificationsPlugin.show(notification.hashCode,
notification.title, notification.body, details);
}
});

super.initState();
}

class MyHome extends HookWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -115,10 +71,12 @@ class _MyAppState extends State<MyApp> {
primarySwatch: Colors.blue,
),
home: Container(
color: const Color(0xFF6E3647),
child: Container(
child: Container(color: Colors.white, child: TaxiView()),
)),
color: const Color(0xFF6E3647),
child: Container(
color: Colors.white,
child: TaxiView(),
),
),
);
}
}
2 changes: 1 addition & 1 deletion lib/utils/fcmToken.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FcmToken {

static FcmToken? _instance;

final Dio _dio = Dio(ConnectionOptions);
final Dio _dio = Dio(connectionOptions);

FcmToken._internal({required this.token});

Expand Down
51 changes: 51 additions & 0 deletions lib/utils/pushHandler.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:taxiapp/utils/fcmToken.dart';
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 'package:http/http.dart' as http;
import 'dart:typed_data';
import 'dart:math';

@pragma('vm:entry-point')
Future<void> handleMessage(RemoteMessage message) async {
var channel = const AndroidNotificationChannel(
'taxi_channel',
'taxi_notification',
description: 'This channel is used for taxi notifications',
importance: Importance.high,
);

var flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

ByteArrayAndroidBitmap? largeIcon;

if (message.data['icon'] != null) {
largeIcon = ByteArrayAndroidBitmap(
await _getByteArrayFromUrl(message.data['icon']),
);
}
var androidNotiDetails = AndroidNotificationDetails(channel.id, channel.name,
channelDescription: channel.description, largeIcon: largeIcon);

var iOSNotiDetails = const DarwinNotificationDetails();

var details =
NotificationDetails(android: androidNotiDetails, iOS: iOSNotiDetails);

if (message.data != null) {
flutterLocalNotificationsPlugin.show(Random().nextInt(100000000),
message.data['title'], message.data['body'], details,
payload: message.data['url']);
}
}

Future<Uint8List> _getByteArrayFromUrl(String url) async {
final http.Response response = await http.get(Uri.parse(url));
return response.bodyBytes;
}
4 changes: 2 additions & 2 deletions lib/utils/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Token {
static Token? _instance;
static final _storage = FlutterSecureStorage();

final Dio _dio = Dio(ConnectionOptions);
final Dio _dio = Dio(connectionOptions);
final CookieJar _cookieJar = CookieJar();

Token._internal({required this.accessToken, required this.refreshToken});
Expand Down Expand Up @@ -76,7 +76,7 @@ class Token {
}
if (response.statusCode == 200) {
List<Cookie> cookies = await _cookieJar.loadForRequest(
Uri.parse(ConnectionOptions.baseUrl + "auth/app/token/login"));
Uri.parse(connectionOptions.baseUrl + "auth/app/token/login"));
for (Cookie cookie in cookies) {
if (cookie.name == "connect.sid") {
return cookie.value;
Expand Down
15 changes: 8 additions & 7 deletions lib/views/loginView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoginView extends HookWidget {
final _url =
Uri.parse(_backUrl).replace(path: "api/auth/app/token/generate");

final callbackUrlScheme = "org.sparcs.taxi_app";
const callbackUrlScheme = "org.sparcs.taxiapp";

final result = await FlutterWebAuth.authenticate(
url: _url.toString(),
Expand All @@ -45,23 +45,24 @@ class LoginView extends HookWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image(image: AssetImage('assets/img/taxiLogoText.png'), height: 60),
Padding(padding: EdgeInsets.only(top: 15)),
const Image(
image: AssetImage('assets/img/taxiLogoText.png'), height: 60),
const Padding(padding: EdgeInsets.only(top: 15)),
OutlinedButton(
style: ButtonStyle(
fixedSize: MaterialStateProperty.all(Size(250, 45)),
fixedSize: MaterialStateProperty.all(const Size(250, 45)),
backgroundColor:
MaterialStateProperty.all<Color>(Color(0xFF6E3678)),
MaterialStateProperty.all<Color>(const Color(0xFF6E3678)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide(color: Colors.black),
side: const BorderSide(color: Colors.black),
),
),
),
child: Text("로그인",
style: GoogleFonts.roboto(
textStyle: TextStyle(
textStyle: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.bold))),
Expand Down
Loading