diff --git a/android/app/build.gradle b/android/app/build.gradle index d9bb1e8..0fcff8c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -46,6 +46,12 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.3" + } compileSdkVersion flutter.compileSdkVersion compileOptions { @@ -98,5 +104,15 @@ flutter { } dependencies { + def composeBom = platform('androidx.compose:compose-bom:2023.01.00') + implementation composeBom + androidTestImplementation composeBom + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.activity:activity-compose:1.7.2' + implementation "androidx.appcompat:appcompat:1.6.1" + implementation "androidx.compose.ui:ui:1.4.3" + implementation "androidx.compose.runtime:runtime:1.4.3" + implementation "androidx.compose.material:material:1.4.3" + implementation "androidx.compose.ui:ui-tooling-preview:1.4.3" } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 029bd7b..dc51030 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,6 +2,10 @@ package="com.beside.moa"> + + @@ -39,7 +43,35 @@ android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + > + + + + + + + + + + + + + + + + + + + @@ -83,26 +115,7 @@ - - - - - - - - - - - - - - - diff --git a/android/app/src/main/kotlin/com/beside/moa/MainActivity.kt b/android/app/src/main/kotlin/com/beside/moa/MainActivity.kt index 3581f02..912abb1 100644 --- a/android/app/src/main/kotlin/com/beside/moa/MainActivity.kt +++ b/android/app/src/main/kotlin/com/beside/moa/MainActivity.kt @@ -2,14 +2,30 @@ package com.beside.moa import android.os.Bundle import io.flutter.embedding.android.FlutterActivity import android.content.Intent.FLAG_ACTIVITY_NEW_TASK +import androidx.annotation.NonNull +import io.flutter.FlutterInjector +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.embedding.engine.FlutterEngineCache +import io.flutter.embedding.engine.dart.DartExecutor +import io.flutter.embedding.engine.dart.DartExecutor.DartEntrypoint +import io.flutter.plugin.common.MethodChannel class MainActivity: FlutterActivity() { + private val CHANNEL = "com.beside.moa/share" + + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { + call, result -> + result.success("mainScreen") + } + } override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) if (intent.getIntExtra("org.chromium.chrome.extra.TASK_ID", -1) == this.taskId) { this.finish() intent.addFlags(FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } - super.onCreate(savedInstanceState) } } diff --git a/android/app/src/main/kotlin/com/beside/moa/share/ShareActivity.kt b/android/app/src/main/kotlin/com/beside/moa/share/ShareActivity.kt new file mode 100644 index 0000000..9130d69 --- /dev/null +++ b/android/app/src/main/kotlin/com/beside/moa/share/ShareActivity.kt @@ -0,0 +1,25 @@ +package com.beside.moa.share + +import android.os.Bundle +import androidx.annotation.NonNull +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.MethodChannel + + +class ShareActivity: FlutterActivity() { + private val CHANNEL = "com.beside.moa/share" + + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { + call, result -> + if(call.method == "shareSheet"){ + result.success("shareSheet") + } + else{ + result.success("") + } + } + } +} diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..492a955 --- /dev/null +++ b/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/flutter_view_layout.xml b/android/app/src/main/res/layout/flutter_view_layout.xml new file mode 100644 index 0000000..5a7410e --- /dev/null +++ b/android/app/src/main/res/layout/flutter_view_layout.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index e4a0133..f51e386 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -4,4 +4,5 @@ K10uUCEMBAnAY0ZtJMeo qtCW1qORKI Moa-app + Moa \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 0d1fa8f..8dfe68a 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -19,4 +19,19 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle index c50eda5..cc768cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.8.20' + ext.kotlin_version = '1.8.10' repositories { google() mavenCentral() diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e24fef9..749a043 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -10,10 +10,10 @@ PODS: - Firebase/Messaging (10.9.0): - Firebase/CoreOnly - FirebaseMessaging (~> 10.9.0) - - firebase_core (2.13.0): + - firebase_core (2.13.1): - Firebase/CoreOnly (= 10.9.0) - Flutter - - firebase_messaging (14.6.1): + - firebase_messaging (14.6.2): - Firebase/Messaging (= 10.9.0) - firebase_core - Flutter @@ -187,8 +187,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2 - firebase_core: fc68c0f9eec4e800b9418deff14a7e0a504016f3 - firebase_messaging: ffb4e7c95d4daca8cef4eca0283f0ddd2b365d40 + firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94 + firebase_messaging: 42912365e62efc1ea3e00724e5eecba6068ddb88 FirebaseCore: b68d3616526ec02e4d155166bbafb8eca64af557 FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index b85bf6c..00e30bf 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -4,10 +4,28 @@ import NaverThirdPartyLogin @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { + let flutterEngine = FlutterEngine(name: "my flutter engine") + override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + + // !! how to know ShareMedia url(CFBundleURLSchemes) + // flutterEngine.run();x + // let controller : FlutterViewController = window?.rootViewController as! FlutterViewController + // let shareChannel = FlutterMethodChannel(name: "com.beside.moa/share", + // binaryMessenger: controller.binaryMessenger) + // shareChannel.setMethodCallHandler({ + // (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in + // switch call.method { + // case "mainScreen": + // result("mainScreen") + // default: + // break + // } + // }) + GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Share Extension/ShareViewController.swift b/ios/Share Extension/ShareViewController.swift index e921ef9..bb85552 100644 --- a/ios/Share Extension/ShareViewController.swift +++ b/ios/Share Extension/ShareViewController.swift @@ -3,7 +3,7 @@ import Social import MobileCoreServices import Photos -class ShareViewController: SLComposeServiceViewController { +class ShareViewController: UIViewController { let hostAppBundleIdentifier = "com.beside.moa" let sharedKey = "ShareKey" var sharedMedia: [SharedMediaFile] = [] @@ -14,12 +14,21 @@ class ShareViewController: SLComposeServiceViewController { let urlContentType = kUTTypeURL as String let fileURLType = kUTTypeFileURL as String; - override func isContentValid() -> Bool { - return true - } +// override func isContentValid() -> Bool { +// return true +// } override func viewDidLoad() { super.viewDidLoad(); + // view.backgroundColor = .clear + + // let blurEffect = UIBlurEffect(style: .dark) + // let blurEffectView = UIVisualEffectView(effect: blurEffect) + // //always fill the view + // blurEffectView.frame = self.view.bounds + // blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + // view.insertSubview(blurEffectView, at: 0) } override func viewDidAppear(_ animated: Bool) { @@ -45,14 +54,14 @@ class ShareViewController: SLComposeServiceViewController { } } - override func didSelectPost() { - print("didSelectPost"); - } - - override func configurationItems() -> [Any]! { - // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. - return [] - } +// override func didSelectPost() { +// print("didSelectPost"); +// } +// +// override func configurationItems() -> [Any]! { +// // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. +// return [] +// } private func handleText (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { attachment.loadItem(forTypeIdentifier: textContentType, options: nil) { [weak self] data, error in @@ -331,4 +340,4 @@ extension Array { subscript (safe index: UInt) -> Element? { return Int(index) < count ? self[Int(index)] : nil } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index b01d477..268684b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ import 'package:moa_app/firebase_options.dart'; import 'package:moa_app/generated/l10n.dart'; import 'package:moa_app/providers/token_provider.dart'; import 'package:moa_app/utils/config.dart'; -import 'package:moa_app/utils/router_config.dart'; +import 'package:moa_app/utils/router_provider.dart'; import 'package:moa_app/utils/themes.dart'; import 'package:moa_app/utils/tools.dart'; @@ -62,9 +62,12 @@ void main() async { class MyApp extends HookConsumerWidget { const MyApp({super.key}); + static const platform = MethodChannel('com.beside.moa/share'); + @override Widget build(BuildContext context, WidgetRef ref) { var token = ref.watch(tokenStateProvider); + var isShareScreen = useState(false); useEffect(() { if (!token.isLoading) { @@ -79,6 +82,31 @@ class MyApp extends HookConsumerWidget { ); } + void getShare() async { + var result = await platform.invokeMethod('shareSheet'); + print('result:$result'); + if (result == 'shareSheet') { + isShareScreen.value = true; + return; + } + isShareScreen.value = false; + } + + useEffect(() { + // getShare(); + return null; + }, []); + + if (isShareScreen.value) { + return const MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + body: Center( + child: Text('ShareScreen'), + )), + ); + } + return GestureDetector( onTap: () => FocusManager.instance.primaryFocus?.unfocus(), child: MaterialApp.router( @@ -98,11 +126,7 @@ class MyApp extends HookConsumerWidget { Locale('en', 'US'), Locale('ko', 'KR'), ], - routerConfig: routerConfig( - (token.value != null && context.mounted) - ? GoRoutes.home.fullPath - : GoRoutes.signIn.fullPath, - ), + routerConfig: ref.watch(routeProvider), ), ); } diff --git a/lib/models/user_detail_model.dart b/lib/models/user_detail_model.dart deleted file mode 100644 index c036fbc..0000000 --- a/lib/models/user_detail_model.dart +++ /dev/null @@ -1,6 +0,0 @@ -class UserDetailModel { - UserDetailModel({this.name, this.email, this.isSelected = false}); - String? name; - String? email; - bool isSelected; -} diff --git a/lib/navigations/main_bottom_tab.dart b/lib/navigations/main_bottom_tab.dart index 88b3c53..556da5a 100644 --- a/lib/navigations/main_bottom_tab.dart +++ b/lib/navigations/main_bottom_tab.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:moa_app/constants/color_constants.dart'; -import 'package:moa_app/utils/router_config.dart'; +import 'package:moa_app/utils/router_provider.dart'; enum ScreenType { social, generalMeetings } @@ -36,39 +36,80 @@ class MainBottomTab extends HookWidget { return Scaffold( body: child, - bottomNavigationBar: BottomNavigationBar( - currentIndex: currentIndex.value, - type: BottomNavigationBarType.fixed, - selectedFontSize: 12, - unselectedFontSize: 12, - selectedItemColor: AppColors.primaryColor, - unselectedItemColor: AppColors.placeholder, - showSelectedLabels: true, - showUnselectedLabels: true, - iconSize: 24, - onTap: (index) => tap(context, index), - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: '홈', - tooltip: '홈', - ), - BottomNavigationBarItem( - icon: Icon(Icons.share), - label: '파일 공유', - tooltip: '파일 공유', - ), - BottomNavigationBarItem( - icon: Icon(Icons.lock), - label: '권한', - tooltip: '권한', - ), - BottomNavigationBarItem( - icon: Icon(Icons.person), - label: '프로필', - tooltip: '프로필', + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling, + floatingActionButton: SizedBox( + width: 60, + height: 60, + child: FloatingActionButton( + shape: const CircleBorder(), + //Floating action button on Scaffold + onPressed: () { + //code to execute on button press + }, + child: const Icon( + size: 30, + Icons.add, + ), //icon inside button + ), + ), + bottomNavigationBar: Container( + decoration: const BoxDecoration( + boxShadow: [ + BoxShadow( + offset: Offset(0, 25), + color: Color.fromRGBO(0, 0, 0, 0.25), + blurRadius: 40, + ), + ], + ), + child: BottomAppBar( + // color: Colors.green, + shape: const CircularNotchedRectangle(), + notchMargin: 5, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Bottom of the screen + IconButton( + iconSize: 28, + onPressed: () => tap(context, 0), + icon: const Icon(Icons.home), + color: currentIndex.value == 0 + ? AppColors.primaryColor + : AppColors.placeholder, + ), + IconButton( + iconSize: 28, + onPressed: () => tap(context, 1), + icon: const Icon(Icons.share), + color: currentIndex.value == 1 + ? AppColors.primaryColor + : AppColors.placeholder, + ), + IconButton( + iconSize: 28, + onPressed: () => tap(context, 2), + icon: const Icon(Icons.lock), + color: currentIndex.value == 2 + ? AppColors.primaryColor + : AppColors.placeholder, + ), + IconButton( + iconSize: 28, + onPressed: () => tap(context, 3), + icon: const Icon(Icons.person), + color: currentIndex.value == 3 + ? AppColors.primaryColor + : AppColors.placeholder, + ), + ], + ), ), - ], + ), ), ); } diff --git a/lib/providers/token_provider.dart b/lib/providers/token_provider.dart index 281a204..5d23ef7 100644 --- a/lib/providers/token_provider.dart +++ b/lib/providers/token_provider.dart @@ -1,5 +1,4 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:moa_app/models/user_model.dart'; import 'package:moa_app/repositories/token_repository.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -21,13 +20,6 @@ class TokenState extends _$TokenState { return null; } - Future?> getMe() async { - return null; - - // var user = UserRepository.instance.getMe(); - // return user; - } - Future removeToken() async { state = const AsyncValue.loading(); diff --git a/lib/screens/edit_profile.dart b/lib/screens/edit_profile.dart index 9d7f779..6a1fd23 100644 --- a/lib/screens/edit_profile.dart +++ b/lib/screens/edit_profile.dart @@ -2,10 +2,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:image_picker/image_picker.dart'; import 'package:moa_app/constants/file_constants.dart'; import 'package:moa_app/providers/token_provider.dart'; +import 'package:moa_app/utils/router_provider.dart'; import 'package:moa_app/widgets/alert_dialog.dart'; import 'package:moa_app/widgets/button.dart'; import 'package:moa_app/widgets/edit_text.dart'; @@ -76,6 +78,9 @@ class EditProfile extends HookConsumerWidget { context, onPress: () async { await ref.watch(tokenStateProvider.notifier).removeToken(); + if (context.mounted) { + context.go(GoRoutes.signIn.fullPath); + } }, showCancelButton: true, title: '로그아웃', diff --git a/lib/screens/file_sharing/file_sharing.dart b/lib/screens/file_sharing/file_sharing.dart index 534bf3a..5afb140 100644 --- a/lib/screens/file_sharing/file_sharing.dart +++ b/lib/screens/file_sharing/file_sharing.dart @@ -5,16 +5,20 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:moa_app/constants/app_constants.dart'; +import 'package:moa_app/providers/token_provider.dart'; import 'package:moa_app/screens/file_sharing/user_listing_screen.dart'; -import 'package:moa_app/utils/router_config.dart'; +import 'package:moa_app/utils/router_provider.dart'; +import 'package:moa_app/widgets/alert_dialog.dart'; +import 'package:moa_app/widgets/button.dart'; import 'package:receive_sharing_intent/receive_sharing_intent.dart'; -class FileSharing extends HookWidget { +class FileSharing extends HookConsumerWidget { const FileSharing({super.key}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { var text = useState(''); // var files = useState([]); @@ -93,6 +97,23 @@ class FileSharing extends HookWidget { ), body: Column( children: [ + Button( + text: '임시 로그아웃 버튼', + onPress: () { + alertDialog.confirm( + context, + onPress: () async { + await ref.watch(tokenStateProvider.notifier).removeToken(); + if (context.mounted) { + context.go(GoRoutes.signIn.fullPath); + } + }, + showCancelButton: true, + title: '로그아웃', + content: '로그아웃 하시겠습니까?', + ); + }, + ), text.value.isEmpty ? const Expanded(child: Center(child: Text('File Sharing'))) : UserListingScreen(text: text.value) diff --git a/lib/screens/sign_in.dart b/lib/screens/sign_in.dart index 8631d9f..6a30aa8 100644 --- a/lib/screens/sign_in.dart +++ b/lib/screens/sign_in.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:moa_app/constants/app_constants.dart'; import 'package:moa_app/constants/file_constants.dart'; @@ -10,6 +11,7 @@ import 'package:moa_app/models/user_model.dart'; import 'package:moa_app/providers/token_provider.dart'; import 'package:moa_app/repositories/auth_repository.dart'; import 'package:moa_app/utils/logger.dart'; +import 'package:moa_app/utils/router_provider.dart'; import 'package:moa_app/widgets/button.dart'; import 'package:moa_app/widgets/edit_text.dart'; import 'package:moa_app/widgets/loading_indicator.dart'; @@ -27,9 +29,10 @@ class SignIn extends HookConsumerWidget { void handleLogin(Function login) async { try { loading.value = true; + await login(); + await ref.watch(tokenStateProvider.notifier).addToken(); if (context.mounted) { - await login(); - await ref.watch(tokenStateProvider.notifier).addToken(); + context.go(GoRoutes.home.fullPath); } } catch (e) { logger.d(e); diff --git a/lib/services/fcm_service.dart b/lib/services/fcm_service.dart index 250ad2d..a9e1d9d 100644 --- a/lib/services/fcm_service.dart +++ b/lib/services/fcm_service.dart @@ -5,7 +5,7 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:go_router/go_router.dart'; import 'package:moa_app/utils/config.dart'; -import 'package:moa_app/utils/router_config.dart'; +import 'package:moa_app/utils/router_provider.dart'; import 'package:moa_app/utils/tools.dart'; class FcmService { diff --git a/lib/share_overlay.dart b/lib/share_overlay.dart new file mode 100644 index 0000000..56d09bf --- /dev/null +++ b/lib/share_overlay.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:moa_app/constants/text_style_constants.dart'; + +class ShareOverlay extends HookWidget { + const ShareOverlay({super.key}); + + @override + Widget build(BuildContext context) { + var count = useState(0); + + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + backgroundColor: Colors.green, + body: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const SizedBox(), + const Text( + '저장 폴더를 선택해주세요!', + style: TitleTextStyle(), + ), + + ElevatedButton( + style: ElevatedButton.styleFrom(backgroundColor: Colors.blue), + onPressed: () { + print('11'); + print('count.value:${count.value}'); + count.value++; + // SystemNavigator.pop(); + }, + child: const Icon( + Icons.close, + size: 24, + ), + ) + // IconButton( + // onPressed: () { + // SystemNavigator.pop(); + // }, + // icon: const Icon( + // Icons.close, + // size: 24, + // ), + // ) + ], + ), + Text( + '${count.value}', + style: const TitleTextStyle(), + ), + ], + ), + ), + ); + } +} diff --git a/lib/utils/general.dart b/lib/utils/general.dart index bf58233..febdc23 100644 --- a/lib/utils/general.dart +++ b/lib/utils/general.dart @@ -16,4 +16,42 @@ class General { enableDrag: false, ); } + + void showModalTopSheet(BuildContext context, Widget builder, + {Color? backgroundColor, double? height}) { + showGeneralDialog( + context: context, + barrierDismissible: true, + transitionDuration: const Duration(milliseconds: 500), + barrierLabel: MaterialLocalizations.of(context).dialogLabel, + barrierColor: Colors.black.withOpacity(0.5), + pageBuilder: (context, _, __) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: height, + width: MediaQuery.of(context).size.width, + child: Material( + color: backgroundColor ?? Colors.white, + child: builder, + ), + ), + ], + ); + }, + transitionBuilder: (context, animation, secondaryAnimation, child) { + return SlideTransition( + position: CurvedAnimation( + parent: animation, + curve: Curves.easeOut, + ).drive(Tween( + begin: const Offset(0, -1.0), + end: Offset.zero, + )), + child: child, + ); + }, + ); + } } diff --git a/lib/utils/router_config.dart b/lib/utils/router_config.dart deleted file mode 100644 index 840c7fc..0000000 --- a/lib/utils/router_config.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:moa_app/models/item_model.dart'; -import 'package:moa_app/navigations/main_bottom_tab.dart'; -import 'package:moa_app/screens/edit_profile.dart'; -import 'package:moa_app/screens/file_sharing/file_sharing.dart'; -import 'package:moa_app/screens/home.dart'; -import 'package:moa_app/screens/item_detail.dart'; -import 'package:moa_app/screens/permission_screen.dart'; -import 'package:moa_app/screens/result.dart'; -import 'package:moa_app/screens/sample.dart'; -import 'package:moa_app/screens/sign_in.dart'; -import 'package:moa_app/services/fcm_service.dart'; - -final _rootNavigatorKey = GlobalKey(); - -enum GoRoutes { - authSwitch, - signIn, - home, - permission, - fileSharing, - userListing, - itemDetail, - editProfile, - sample, - result -} - -CustomTransitionPage buildPageWithDefaultTransition({ - required BuildContext context, - required GoRouterState state, - required Widget child, -}) { - return CustomTransitionPage( - key: state.pageKey, - child: child, - transitionDuration: const Duration(milliseconds: 120), - transitionsBuilder: (context, animation, secondaryAnimation, child) => - FadeTransition(opacity: animation, child: child), - ); -} - -extension GoRoutesName on GoRoutes { - String get name => describeEnum(this); - - /// Convert to `lower-snake-case` format. - String get path { - var exp = RegExp(r'(?<=[a-z])[A-Z]'); - var result = - name.replaceAllMapped(exp, (m) => '-${m.group(0)}').toLowerCase(); - return result; - } - - /// Convert to `lower-snake-case` format with `/`. - String get fullPath { - var exp = RegExp(r'(?<=[a-z])[A-Z]'); - var result = - name.replaceAllMapped(exp, (m) => '-${m.group(0)}').toLowerCase(); - return '/$result'; - } -} - -GoRouter routerConfig([String? initialLocation]) => GoRouter( - navigatorKey: _rootNavigatorKey, - initialLocation: initialLocation ?? GoRoutes.home.fullPath, - routes: [ - ShellRoute( - builder: (context, state, child) { - // 알람 초기화 - /// 알람 권한 요청 - if (!kIsWeb && context.mounted) { - FcmService.instance.requestIosFirebaseMessaging(); - - FcmService.instance.foregroundMessageHandler(); - FcmService.instance.foregroundClickHandler(context); - FcmService.instance.setupInteractedMessage(context); - } - - return MainBottomTab(child: child); - }, - routes: [ - GoRoute( - name: GoRoutes.home.name, - path: GoRoutes.home.fullPath, - pageBuilder: (context, state) => - buildPageWithDefaultTransition( - context: context, - state: state, - child: const Home(), - ), - routes: [ - GoRoute( - name: GoRoutes.itemDetail.name, - path: ':id', - builder: (context, state) { - var item = state.extra as ItemModel; - return ItemDetail(item: item); - }, - ), - ], - ), - GoRoute( - name: GoRoutes.fileSharing.name, - path: GoRoutes.fileSharing.fullPath, - pageBuilder: (context, state) => - buildPageWithDefaultTransition( - context: context, - state: state, - child: const FileSharing(), - ), - ), - GoRoute( - name: GoRoutes.permission.name, - path: GoRoutes.permission.fullPath, - pageBuilder: (context, state) => - buildPageWithDefaultTransition( - context: context, - state: state, - child: const PermissionScreen(), - ), - ), - GoRoute( - name: GoRoutes.editProfile.name, - path: GoRoutes.editProfile.fullPath, - pageBuilder: (context, state) => - buildPageWithDefaultTransition( - context: context, - state: state, - child: const EditProfile(), - ), - ), - ], - ), - GoRoute( - name: GoRoutes.signIn.name, - path: GoRoutes.signIn.fullPath, - builder: (context, state) { - return const SignIn(); - }, - ), - GoRoute( - name: GoRoutes.sample.name, - path: GoRoutes.sample.fullPath, - builder: (context, state) { - return const Sample(); - }, - ), - GoRoute( - name: GoRoutes.result.name, - path: GoRoutes.result.fullPath, - builder: (context, state) { - return const Result(); - }, - ), - ], - ); diff --git a/lib/utils/router_provider.dart b/lib/utils/router_provider.dart new file mode 100644 index 0000000..da93e98 --- /dev/null +++ b/lib/utils/router_provider.dart @@ -0,0 +1,171 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:moa_app/models/item_model.dart'; +import 'package:moa_app/navigations/main_bottom_tab.dart'; +import 'package:moa_app/providers/token_provider.dart'; +import 'package:moa_app/screens/edit_profile.dart'; +import 'package:moa_app/screens/file_sharing/file_sharing.dart'; +import 'package:moa_app/screens/home.dart'; +import 'package:moa_app/screens/item_detail.dart'; +import 'package:moa_app/screens/permission_screen.dart'; +import 'package:moa_app/screens/result.dart'; +import 'package:moa_app/screens/sample.dart'; +import 'package:moa_app/screens/sign_in.dart'; +import 'package:moa_app/services/fcm_service.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +final _rootNavigatorKey = GlobalKey(); + +enum GoRoutes { + authSwitch, + signIn, + home, + permission, + fileSharing, + userListing, + itemDetail, + editProfile, + sample, + result +} + +CustomTransitionPage buildPageWithDefaultTransition({ + required BuildContext context, + required GoRouterState state, + required Widget child, +}) { + return CustomTransitionPage( + key: state.pageKey, + child: child, + transitionDuration: const Duration(milliseconds: 120), + transitionsBuilder: (context, animation, secondaryAnimation, child) => + FadeTransition(opacity: animation, child: child), + ); +} + +extension GoRoutesName on GoRoutes { + String get name => describeEnum(this); + + /// Convert to `lower-snake-case` format. + String get path { + var exp = RegExp(r'(?<=[a-z])[A-Z]'); + var result = + name.replaceAllMapped(exp, (m) => '-${m.group(0)}').toLowerCase(); + return result; + } + + /// Convert to `lower-snake-case` format with `/`. + String get fullPath { + var exp = RegExp(r'(?<=[a-z])[A-Z]'); + var result = + name.replaceAllMapped(exp, (m) => '-${m.group(0)}').toLowerCase(); + return '/$result'; + } +} + +final routeProvider = Provider((ref) { + return GoRouter( + navigatorKey: _rootNavigatorKey, + initialLocation: GoRoutes.home.fullPath, + redirect: (context, state) { + var token = ref.read(tokenStateProvider); + if (token.value == null) { + if (state.matchedLocation != GoRoutes.signIn.fullPath) { + return GoRoutes.signIn.fullPath; + } + } + return null; + }, + routes: [ + ShellRoute( + builder: (context, state, child) { + // 알람 초기화 + /// 알람 권한 요청 + if (!kIsWeb && context.mounted) { + FcmService.instance.requestIosFirebaseMessaging(); + + FcmService.instance.foregroundMessageHandler(); + FcmService.instance.foregroundClickHandler(context); + FcmService.instance.setupInteractedMessage(context); + } + + return MainBottomTab(child: child); + }, + routes: [ + GoRoute( + name: GoRoutes.home.name, + path: GoRoutes.home.fullPath, + pageBuilder: (context, state) => + buildPageWithDefaultTransition( + context: context, + state: state, + child: const Home(), + ), + routes: [ + GoRoute( + name: GoRoutes.itemDetail.name, + path: ':id', + builder: (context, state) { + var item = state.extra as ItemModel; + return ItemDetail(item: item); + }, + ), + ], + ), + GoRoute( + name: GoRoutes.fileSharing.name, + path: GoRoutes.fileSharing.fullPath, + pageBuilder: (context, state) => + buildPageWithDefaultTransition( + context: context, + state: state, + child: const FileSharing(), + ), + ), + GoRoute( + name: GoRoutes.permission.name, + path: GoRoutes.permission.fullPath, + pageBuilder: (context, state) => + buildPageWithDefaultTransition( + context: context, + state: state, + child: const PermissionScreen(), + ), + ), + GoRoute( + name: GoRoutes.editProfile.name, + path: GoRoutes.editProfile.fullPath, + pageBuilder: (context, state) => + buildPageWithDefaultTransition( + context: context, + state: state, + child: const EditProfile(), + ), + ), + ], + ), + GoRoute( + name: GoRoutes.signIn.name, + path: GoRoutes.signIn.fullPath, + builder: (context, state) { + return const SignIn(); + }, + ), + GoRoute( + name: GoRoutes.sample.name, + path: GoRoutes.sample.fullPath, + builder: (context, state) { + return const Sample(); + }, + ), + GoRoute( + name: GoRoutes.result.name, + path: GoRoutes.result.fullPath, + builder: (context, state) { + return const Result(); + }, + ), + ], + ); +}); diff --git a/lib/utils/themes.dart b/lib/utils/themes.dart index 3ab762b..9a6cc44 100644 --- a/lib/utils/themes.dart +++ b/lib/utils/themes.dart @@ -7,7 +7,7 @@ class Themes { Themes._(); static final light = ThemeData.light().copyWith( - useMaterial3: true, + // useMaterial3: true, primaryColor: AppColors.role.primary, scaffoldBackgroundColor: Colors.white, // bottomNavigationBarTheme: const BottomNavigationBarThemeData(), diff --git a/pubspec.lock b/pubspec.lock index 4c7d4f4..5ae188d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: _flutterfire_internals - sha256: "8eb354cb8ebed8a9fdf63699d15deff533bc133128898afaf754926b57d611b6" + sha256: "9ebe81588e666f7e2b21309f2b5653bd9642d7f27fd0a6894278d2ff40cb9481" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" analyzer: dependency: transitive description: @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: args - sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" asn1lib: dependency: transitive description: @@ -117,10 +117,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: "30859c90e9ddaccc484f56303931f477b1f1ba2bab74aa32ed5d6ce15870f8cf" + sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" url: "https://pub.dev" source: hosted - version: "7.2.8" + version: "7.2.10" built_collection: dependency: transitive description: @@ -133,10 +133,10 @@ packages: dependency: transitive description: name: built_value - sha256: "2f17434bd5d52a26762043d6b43bb53b3acd029b4d9071a329f46d67ef297e6d" + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted - version: "8.5.0" + version: "8.6.1" cached_network_image: dependency: "direct main" description: @@ -213,10 +213,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.0" collection: dependency: transitive description: @@ -261,10 +261,10 @@ packages: dependency: transitive description: name: csslib - sha256: b36c7f7e24c0bdf1bf9a3da461c837d1de64b9f8beb190c9011d8c72a3dfd745 + sha256: "831883fb353c8bdc1d71979e5b342c7d88acfbc643113c14ae51e2442ea0f20f" url: "https://pub.dev" source: hosted - version: "0.17.2" + version: "0.17.3" cupertino_icons: dependency: "direct main" description: @@ -317,10 +317,10 @@ packages: dependency: "direct main" description: name: dio - sha256: "347d56c26d63519552ef9a569f2a593dda99a81fdbdff13c584b7197cfe05059" + sha256: e44ce32c01f02c54a101551def8586f15d6189b4f999d4420aad38995ac62e6d url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "5.2.0" encrypt: dependency: transitive description: @@ -357,10 +357,10 @@ packages: dependency: "direct main" description: name: firebase_core - sha256: "250678b816279b3240c3a33e1f76bf712c00718f1fbeffc85873a5da8c077379" + sha256: e9b36b391690cf329c6fb1de220045e97c13784c303820cd33962319580a56c6 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.13.1" firebase_core_platform_interface: dependency: transitive description: @@ -381,26 +381,26 @@ packages: dependency: "direct main" description: name: firebase_messaging - sha256: "9cfe5c4560fb83393511ca7620f8fb3f22c9a80303052f10290e732fcfb801bd" + sha256: a01d7b9eb43a4bad54a411edb2b4124089d88eab029191893e83c39e18ab19f7 url: "https://pub.dev" source: hosted - version: "14.6.1" + version: "14.6.2" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface - sha256: "7e25cb71019ccef8b1fd7b37969af79f04c467974cce4dfc291fa36974edd7ba" + sha256: c2fef3e30fbfa3a71d74477df102d1c2f5aad860bb68bb4086b0af3b12abedf3 url: "https://pub.dev" source: hosted - version: "4.5.1" + version: "4.5.2" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web - sha256: "5d9840cc8126ea723b1bda901389cb542902f664f2653c16d4f8114e95f13cec" + sha256: "8d280f0110ca4946b9863e578b9879874066ac486ffa596a609aab329fb6fa7e" url: "https://pub.dev" source: hosted - version: "3.5.1" + version: "3.5.2" fixnum: dependency: transitive description: @@ -442,10 +442,10 @@ packages: dependency: "direct main" description: name: flutter_dotenv - sha256: d9283d92059a22e9834bc0a31336658ffba77089fb6f3cc36751f1fc7c6661a3 + sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77" url: "https://pub.dev" source: hosted - version: "5.0.2" + version: "5.1.0" flutter_driver: dependency: transitive description: flutter @@ -471,10 +471,10 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "12f8abacca8bf29c042ec50c554f967da4c6f88ec99fc215e0325e5b43a25188" + sha256: "812791d43ccfc1b443a0d39fa02a206fc228c597e28ff9337e09e3ca8d370391" url: "https://pub.dev" source: hosted - version: "14.1.0" + version: "14.1.1" flutter_local_notifications_linux: dependency: transitive description: @@ -500,10 +500,10 @@ packages: dependency: "direct main" description: name: flutter_native_splash - sha256: "02df24aec455c26428dadc637f20d4c548bda23ee2179479a8e8c39f1ecb75b3" + sha256: ba45d8cfbd778478a74696b012f33ffb6b1760c9bc531b21e2964444a4870dae url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.1" flutter_naver_login: dependency: "direct main" description: @@ -590,10 +590,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "2edb9ef971d0f803860ecd9084afd48c717d002141ad77b69be3e976bee7190e" + sha256: a9520490532087cf38bf3f7de478ab6ebeb5f68bb1eb2641546d92719b224445 url: "https://pub.dev" source: hosted - version: "2.3.4" + version: "2.3.5" freezed_annotation: dependency: "direct main" description: @@ -627,10 +627,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: b185cf91b5a6861f4c2a92ddaa65f8919909416ee033e00751f7c67ebee1588d + sha256: "00d1b67d6e9fa443331da229084dd3eb04407f5a2dff22940bd7bba6af5722c3" url: "https://pub.dev" source: hosted - version: "7.0.2" + version: "7.1.1" google_identity_services_web: dependency: transitive description: @@ -643,10 +643,10 @@ packages: dependency: "direct main" description: name: google_sign_in - sha256: "776a4c988dc179c3b8e9201de0ad61bf350a4e75d378ff9d94c76880378c7bca" + sha256: "03bdb90147f299b02165313fc0e93ae90e7532ae90cb611a655b8e17cd036a98" url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.1.3" google_sign_in_android: dependency: transitive description: @@ -667,26 +667,26 @@ packages: dependency: transitive description: name: google_sign_in_platform_interface - sha256: "95a9e0a8701b5485f2ca330fd1fc6f918f5ce088042ce1019c5e389d8574ae4c" + sha256: e69553c0fc6a76216e9d06a8c3767e291ad9be42171f879aab7ab708569d4393 url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" google_sign_in_web: dependency: transitive description: name: google_sign_in_web - sha256: "7e0ec507f4752383a6daa67d0cc775253cfc3b1d87907e7004e2c1b99c0a723f" + sha256: "7b154bc84da4c6a578072fc53c0a68ce3168beb39fab8235657d17c18ea12924" url: "https://pub.dev" source: hosted - version: "0.12.0" + version: "0.12.0+1" graphs: dependency: transitive description: name: graphs - sha256: "772db3d53d23361d4ffcf5a9bb091cf3ee9b22f2be52cd107cd7a2683a89ba0e" + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.1" hooks_riverpod: dependency: "direct main" description: @@ -755,10 +755,10 @@ packages: dependency: transitive description: name: image_picker_android - sha256: c2f3c66400649bd132f721c88218945d6406f693092b2f741b79ae9cdb046e59 + sha256: "3083c3a3245adf9f3eb7bacf0eaa6a1f087dd538fab73a13a2f7907602601692" url: "https://pub.dev" source: hosted - version: "0.8.6+16" + version: "0.8.6+19" image_picker_for_web: dependency: transitive description: @@ -856,26 +856,26 @@ packages: dependency: transitive description: name: lints - sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" logger: dependency: "direct main" description: name: logger - sha256: db2ff852ed77090ba9f62d3611e4208a3d11dfa35991a81ae724c113fcb3e3f7 + sha256: "7ad7215c15420a102ec687bb320a7312afd449bac63bfb1c60d9787c27b9767f" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" logging: dependency: transitive description: name: logging - sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" matcher: dependency: transitive description: @@ -912,10 +912,10 @@ packages: dependency: "direct dev" description: name: mockito - sha256: dd61809f04da1838a680926de50a9e87385c1de91c6579629c3d1723946e8059 + sha256: "8b46d7eb40abdda92d62edd01546051f0c27365e65608c284de336dccfef88cc" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.4.1" node_preamble: dependency: transitive description: @@ -976,10 +976,10 @@ packages: dependency: transitive description: name: path_provider_linux - sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1" + sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 url: "https://pub.dev" source: hosted - version: "2.1.10" + version: "2.1.11" path_provider_platform_interface: dependency: transitive description: @@ -1016,10 +1016,10 @@ packages: dependency: transitive description: name: permission_handler_android - sha256: d8cc6a62ded6d0f49c6eac337e080b066ee3bce4d405bd9439a61e1f1927bfe8 + sha256: f1044cf68ae3a56b31854b7b3e022d5a50dd78b5a28bba5287bcf1d9e3e62537 url: "https://pub.dev" source: hosted - version: "10.2.1" + version: "10.2.2" permission_handler_apple: dependency: transitive description: @@ -1461,10 +1461,10 @@ packages: dependency: transitive description: name: universal_io - sha256: "06866290206d196064fd61df4c7aea1ffe9a4e7c4ccaa8fcded42dd41948005d" + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.2" uuid: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e2107d9..849eea7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,7 +64,7 @@ dependencies: dio: ^5.1.2 flutter_secure_storage: ^8.0.0 firebase_core: ^2.13.0 - firebase_messaging: ^14.6.1 + firebase_messaging: ^14.6.2 flutter_local_notifications: ^14.1.0 dependency_overrides: diff --git a/test/test_utils.dart b/test/test_utils.dart index 2f768ff..8b13789 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -1,57 +1 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:moa_app/generated/l10n.dart'; -import 'package:moa_app/utils/router_config.dart'; -import 'package:moa_app/utils/themes.dart'; -import 'mocks/navigator_observer.mocks.dart'; - -enum Device { mobile, tablet, desktop } - -class TestUtils { - static MockNavigatorObserver observer = MockNavigatorObserver(); - static Widget buildMediaQueryTestableWidget( - {required Device device, required Widget child}) { - double setDeviceWidth() { - if (device == Device.mobile) { - return 412; - } else if (device == Device.tablet) { - return 900; - } - - return 1920; - } - - return MediaQuery( - data: MediaQueryData( - size: Size.fromWidth( - setDeviceWidth(), - ), - ), - child: MaterialApp( - home: child, - ), - ); - } - - static Widget makeTestableWidget({required String? child}) { - return ProviderScope( - child: MaterialApp.router( - debugShowCheckedModeBanner: false, - theme: Themes.light, - localizationsDelegates: const [ - S.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: const [ - Locale('en', 'US'), - Locale('ko', 'KR'), - ], - routerConfig: routerConfig(child), - ), - ); - } -} diff --git a/test/widgets/home_test.dart b/test/widgets/home_test.dart index bc6e12e..ab73b3a 100644 --- a/test/widgets/home_test.dart +++ b/test/widgets/home_test.dart @@ -1,61 +1 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:moa_app/repositories/non_member_repository.dart'; -import 'package:moa_app/utils/router_config.dart'; -import 'package:mockito/mockito.dart'; - -import '../test_utils.dart'; - -class MockUserRepository extends Mock implements NonMemberRepository {} - -extension PumpApp on WidgetTester { - Future pumpRealRouterApp( - String location, - Widget Function(Widget child) builder, { - bool isConnected = true, - }) { - // Logic to initialize my StateManagement with the - // value of isConnected - // ... - - return pumpWidget( - builder( - MaterialApp.router( - routeInformationParser: routerConfig(location).routeInformationParser, - routerDelegate: routerConfig(location).routerDelegate, - ), - ), - ); - } -} - -void main() { - testWidgets('Render authSwitch', (tester) async { - // await tester.pumpWidget(const ProviderScope(child: MyApp())); - - await tester.pumpRealRouterApp( - GoRoutes.authSwitch.fullPath, - (child) => child, - isConnected: false, - ); - - var mockUserRepository = MockUserRepository(); - when(mockUserRepository.getMe()).thenAnswer( - (_) => Future.value([]), - ); - expect(find.text('Home'), findsOneWidget); - }); - - // testWidgets('Counter increments smoke test', (tester) async { - // await tester.pumpWidget( - // TestUtils.makeTestableWidget(child: GoRoutes.home.fullPath)); - // await tester.pump(); - // }); - - testWidgets('Button is present and triggers navigation after tapped', - (tester) async { - await tester.pumpWidget( - TestUtils.makeTestableWidget(child: GoRoutes.signIn.fullPath)); - await tester.pump(); - }); -} +void main() {}