create-flutterinit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +3 -0
- package/package.json +46 -0
- package/templates/base/.cursor/rules/flutter-project.mdc.hbs +132 -0
- package/templates/base/AGENTS.md.hbs +137 -0
- package/templates/base/DESIGN.md.hbs +149 -0
- package/templates/base/README.md.hbs +19 -0
- package/templates/base/SETUP.md.hbs +253 -0
- package/templates/base/analysis_options.yaml +88 -0
- package/templates/base/assets/.keep +1 -0
- package/templates/base/assets/icons/apple.svg +1 -0
- package/templates/base/assets/icons/facebook.svg +1 -0
- package/templates/base/assets/icons/google.svg +1 -0
- package/templates/base/assets/images/.gitkeep +0 -0
- package/templates/base/flutter_native_splash.yaml.hbs +8 -0
- package/templates/base/lib/main.dart.hbs +43 -0
- package/templates/base/lib/src/app.dart.hbs +105 -0
- package/templates/base/lib/src/config/app_config.dart.hbs +112 -0
- package/templates/base/lib/src/extensions/collection_extension.dart.hbs +55 -0
- package/templates/base/lib/src/extensions/context_extension.dart.hbs +167 -0
- package/templates/base/lib/src/extensions/date_time_extension.dart.hbs +40 -0
- package/templates/base/lib/src/extensions/extensions.dart.hbs +6 -0
- package/templates/base/lib/src/extensions/num_extension.dart.hbs +14 -0
- package/templates/base/lib/src/extensions/string_extension.dart.hbs +91 -0
- package/templates/base/lib/src/extensions/widget_extension.dart.hbs +47 -0
- package/templates/base/lib/src/imports/core_imports.dart.hbs +50 -0
- package/templates/base/lib/src/imports/imports.dart.hbs +2 -0
- package/templates/base/lib/src/imports/packages_imports.dart.hbs +110 -0
- package/templates/base/lib/src/routing/(isGetX)@app_bindings.dart.hbs +23 -0
- package/templates/base/lib/src/routing/app_router.dart.hbs +252 -0
- package/templates/base/lib/src/routing/app_routes.dart.hbs +46 -0
- package/templates/base/lib/src/routing/global_navigator.dart.hbs +15 -0
- package/templates/base/lib/src/services/auth_service.dart.hbs +78 -0
- package/templates/base/lib/src/services/copy_service.dart.hbs +16 -0
- package/templates/base/lib/src/services/internet_connection_service.dart.hbs +10 -0
- package/templates/base/lib/src/services/services.dart.hbs +45 -0
- package/templates/base/lib/src/shared/app_assets.dart.hbs +15 -0
- package/templates/base/lib/src/shared/enums/app_status.dart.hbs +40 -0
- package/templates/base/lib/src/shared/enums/button_enums.dart.hbs +22 -0
- package/templates/base/lib/src/shared/enums/enums.dart.hbs +3 -0
- package/templates/base/lib/src/shared/enums/snack_bar_type.dart.hbs +22 -0
- package/templates/base/lib/src/shared/helpers/format_number.dart.hbs +18 -0
- package/templates/base/lib/src/shared/helpers/imports.dart.hbs +3 -0
- package/templates/base/lib/src/shared/helpers/show_app_sheet.dart.hbs +42 -0
- package/templates/base/lib/src/shared/helpers/show_dialog.dart.hbs +49 -0
- package/templates/base/lib/src/shared/helpers/show_toast.dart.hbs +92 -0
- package/templates/base/lib/src/shared/hooks/hooks.dart.hbs +13 -0
- package/templates/base/lib/src/shared/hooks/use_copy.dart.hbs +41 -0
- package/templates/base/lib/src/shared/hooks/use_timer.dart.hbs +158 -0
- package/templates/base/lib/src/shared/shared.dart.hbs +12 -0
- package/templates/base/lib/src/shared/widgets/app_button.dart.hbs +144 -0
- package/templates/base/lib/src/shared/widgets/app_card.dart.hbs +126 -0
- package/templates/base/lib/src/shared/widgets/app_divider.dart.hbs +88 -0
- package/templates/base/lib/src/shared/widgets/app_empty_state.dart.hbs +73 -0
- package/templates/base/lib/src/shared/widgets/app_error_widget.dart.hbs +69 -0
- package/templates/base/lib/src/shared/widgets/app_icon.dart.hbs +25 -0
- package/templates/base/lib/src/shared/widgets/app_loading.dart.hbs +54 -0
- package/templates/base/lib/src/shared/widgets/app_text_field.dart.hbs +89 -0
- package/templates/base/lib/src/shared/widgets/app_top_bar.dart.hbs +105 -0
- package/templates/base/lib/src/shared/widgets/common_image.dart.hbs +120 -0
- package/templates/base/lib/src/shared/widgets/toast/imports.dart.hbs +4 -0
- package/templates/base/lib/src/shared/widgets/toast/raw_toast.dart.hbs +109 -0
- package/templates/base/lib/src/shared/widgets/toast/toast.dart.hbs +142 -0
- package/templates/base/lib/src/shared/widgets/toast/toast_card.dart.hbs +57 -0
- package/templates/base/lib/src/shared/widgets/widgets.dart.hbs +14 -0
- package/templates/base/lib/src/shared/wrappers/(isRiverpod,isProvider,isBloc,isGetX,isMobX)@state_wrapper.dart.hbs +51 -0
- package/templates/base/lib/src/shared/wrappers/(supportsLocalization)@localization_wrapper.dart.hbs +25 -0
- package/templates/base/lib/src/shared/wrappers/(usesScreenutil)@screen_util_wrapper.dart.hbs +27 -0
- package/templates/base/lib/src/shared/wrappers/(usesSkeletonizer)@skeleton_wrapper.dart.hbs +81 -0
- package/templates/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbs +258 -0
- package/templates/base/lib/src/shared/wrappers/wrappers.dart.hbs +15 -0
- package/templates/base/lib/src/theme/app_borders.dart.hbs +70 -0
- package/templates/base/lib/src/theme/app_curves.dart.hbs +69 -0
- package/templates/base/lib/src/theme/app_durations.dart.hbs +48 -0
- package/templates/base/lib/src/theme/app_shadows.dart.hbs +73 -0
- package/templates/base/lib/src/theme/app_spacing.dart.hbs +80 -0
- package/templates/base/lib/src/theme/color_schemes.dart.hbs +126 -0
- package/templates/base/lib/src/theme/text_theme.dart.hbs +167 -0
- package/templates/base/lib/src/theme/theme.dart.hbs +431 -0
- package/templates/base/lib/src/theme/theme_constants.dart.hbs +20 -0
- package/templates/base/lib/src/utils/app_utils.dart.hbs +46 -0
- package/templates/base/lib/src/utils/debouncer.dart.hbs +31 -0
- package/templates/base/lib/src/utils/error_handler.dart.hbs +14 -0
- package/templates/base/lib/src/utils/failure.dart.hbs +30 -0
- package/templates/base/lib/src/utils/input_formatters.dart.hbs +27 -0
- package/templates/base/lib/src/utils/logger.dart.hbs +37 -0
- package/templates/base/lib/src/utils/platform_info.dart.hbs +13 -0
- package/templates/base/lib/src/utils/task_runner.dart.hbs +42 -0
- package/templates/base/lib/src/utils/typedefs.dart.hbs +6 -0
- package/templates/base/lib/src/utils/utils.dart.hbs +9 -0
- package/templates/base/pubspec.yaml.hbs +256 -0
- package/templates/base/test/widget_test.dart.hbs +56 -0
- package/templates/overlays/architecture/clean/architecture.md +6 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/home/presentation/screens/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/onboarding/presentation/screens/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/architecture.md +5 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/home/presentation/screens/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/onboarding/presentation/screens/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/architecture.md +6 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/datasources/local/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/datasources/remote/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/usecases/auth/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isNoneState)@auth_view_model.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/widgets/.gitkeep +0 -0
- package/templates/overlays/architecture/mvc/architecture.md +5 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/services/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/services/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/architecture.md +6 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isBloc)@bloc/auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isBloc)@bloc/session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isGetX)@controllers/auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isGetX)@controllers/session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isMobX)@stores/auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isMobX)@stores/session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isNoneState)@view_models/auth_view_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isNoneState)@view_models/session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isProvider,isRiverpod)@providers/auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isProvider,isRiverpod)@providers/session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/backend/appwrite/lib/src/services/(usesAppwriteAuth)@auth_service.dart.hbs +101 -0
- package/templates/overlays/backend/custom/lib/src/services/auth_service.dart.hbs +158 -0
- package/templates/overlays/backend/firebase/lib/src/services/(usesFirebaseAuth)@auth_service.dart.hbs +96 -0
- package/templates/overlays/backend/supabase/lib/src/services/(usesSupabaseAuth)@auth_service.dart.hbs +97 -0
- package/templates/overlays/device/app_version_update/lib/src/services/(usesAppVersionUpdate)@version_update_service.dart.hbs +118 -0
- package/templates/overlays/device/device_info/lib/src/services/(usesDeviceInfoPlus)@device_info_service.dart.hbs +54 -0
- package/templates/overlays/extras/dotenv/.env.hbs +33 -0
- package/templates/overlays/extras/flavors/lib/src/flavors.dart.hbs +15 -0
- package/templates/overlays/extras/localization/assets/translations/en.json.hbs +47 -0
- package/templates/overlays/media/lib/src/services/(usesImagePicker,usesFilePicker)@media_service.dart.hbs +148 -0
- package/templates/overlays/networking/cached_image/lib/src/shared/widgets/app_cached_image.dart.hbs +160 -0
- package/templates/overlays/networking/dio/lib/src/services/(usesDio)@dio_service.dart.hbs +50 -0
- package/templates/overlays/networking/http/lib/src/services/(usesHttp)@http_service.dart.hbs +82 -0
- package/templates/overlays/storage/hive/lib/src/services/(usesHive)@hive_service.dart.hbs +59 -0
- package/templates/overlays/storage/secure_storage/lib/src/services/(usesSecureStorage)@secure_storage_service.dart.hbs +39 -0
- package/templates/overlays/storage/shared_preferences/lib/src/services/(usesSharedPreferences)@storage_service.dart.hbs +53 -0
- package/templates/overlays/utilities/geolocator/lib/src/services/(usesGeolocator)@location_service.dart.hbs +78 -0
- package/templates/overlays/utilities/path_provider/lib/src/services/(usesPathProvider)@path_service.dart.hbs +30 -0
- package/templates/overlays/utilities/permission_handler/lib/src/services/(usesPermissionHandler)@permission_service.dart.hbs +28 -0
- package/templates/overlays/utilities/permission_handler/lib/src/shared/hooks/use_permission.dart.hbs +44 -0
- package/templates/overlays/utilities/share_plus/lib/src/services/(usesSharePlus)@share_service.dart.hbs +22 -0
- package/templates/overlays/utilities/share_plus/lib/src/shared/hooks/use_share.dart.hbs +26 -0
- package/templates/overlays/utilities/url_launcher/lib/src/services/(usesUrlLauncher)@url_launcher_service.dart.hbs +37 -0
- package/templates/overlays/utilities/url_launcher/lib/src/shared/hooks/use_launch_url.dart.hbs +52 -0
- package/templates/partials/features/auth/auth_logic.hbs +611 -0
- package/templates/partials/features/auth/auth_repository.hbs +32 -0
- package/templates/partials/features/auth/auth_repository_impl.hbs +116 -0
- package/templates/partials/features/auth/forgot_password_screen.hbs +368 -0
- package/templates/partials/features/auth/login_screen.hbs +540 -0
- package/templates/partials/features/auth/session_provider.hbs +437 -0
- package/templates/partials/features/auth/signup_screen.hbs +511 -0
- package/templates/partials/features/auth/user_model.hbs +23 -0
- package/templates/partials/features/home/home_page.hbs +156 -0
- package/templates/partials/features/onboarding/onboarding_page.hbs +264 -0
- package/templates/partials/llm/add-feature-workflow.hbs +38 -0
- package/templates/partials/llm/architecture-rules.hbs +92 -0
- package/templates/partials/llm/backend-rules.hbs +30 -0
- package/templates/partials/llm/build-runner-note.hbs +15 -0
- package/templates/partials/llm/design-quick-ref.hbs +14 -0
- package/templates/partials/llm/design-quick-reference.hbs +14 -0
- package/templates/partials/llm/navigation-rules.hbs +27 -0
- package/templates/partials/llm/networking-rules.hbs +16 -0
- package/templates/partials/llm/packages-list.hbs +26 -0
- package/templates/partials/llm/services-conventions.hbs +20 -0
- package/templates/partials/llm/stack-summary.hbs +22 -0
- package/templates/partials/llm/state-management-rules.hbs +40 -0
- package/templates/partials/state_label.hbs +1 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import 'dart:ui';
|
|
2
|
+
import '../../imports/imports.dart';
|
|
3
|
+
|
|
4
|
+
/// Shows a premium custom dialog with optional backdrop blur.
|
|
5
|
+
///
|
|
6
|
+
/// This helper uses the [rootNavigatorKey] to display the dialog
|
|
7
|
+
/// without needing a local [BuildContext].
|
|
8
|
+
Future<T?> showAppDialog<T>({
|
|
9
|
+
required Widget child,
|
|
10
|
+
bool hasBlur = true,
|
|
11
|
+
double blurSigma = 5.0,
|
|
12
|
+
Color barrierColor = Colors.black26,
|
|
13
|
+
bool dismissible = true,
|
|
14
|
+
Duration duration = const Duration(milliseconds: 300),
|
|
15
|
+
}) {
|
|
16
|
+
final context = rootContext;
|
|
17
|
+
if (context == null) return Future.value(null);
|
|
18
|
+
|
|
19
|
+
return showGeneralDialog<T>(
|
|
20
|
+
context: context,
|
|
21
|
+
barrierColor: barrierColor,
|
|
22
|
+
barrierDismissible: dismissible,
|
|
23
|
+
barrierLabel: 'AppDialog',
|
|
24
|
+
transitionDuration: duration,
|
|
25
|
+
pageBuilder: (context, animation, secondaryAnimation) => child,
|
|
26
|
+
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
|
27
|
+
final curve = Curves.easeInOut.transform(animation.value);
|
|
28
|
+
return BackdropFilter(
|
|
29
|
+
filter: ImageFilter.blur(
|
|
30
|
+
sigmaX: hasBlur ? (blurSigma * animation.value) : 0,
|
|
31
|
+
sigmaY: hasBlur ? (blurSigma * animation.value) : 0,
|
|
32
|
+
),
|
|
33
|
+
child: Opacity(
|
|
34
|
+
opacity: animation.value,
|
|
35
|
+
child: Transform.scale(
|
|
36
|
+
scale: 0.9 + (0.1 * curve),
|
|
37
|
+
child: child,
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Alias for [showAppDialog] to maintain compatibility with custom references.
|
|
46
|
+
Future<T?> showCustomDialogue<T>({
|
|
47
|
+
required Widget child,
|
|
48
|
+
bool hasBlur = true,
|
|
49
|
+
}) => showAppDialog<T>(child: child, hasBlur: hasBlur);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import '../../imports/imports.dart';
|
|
2
|
+
|
|
3
|
+
void showToast(
|
|
4
|
+
BuildContext context, {
|
|
5
|
+
required String message,
|
|
6
|
+
String? status = 'success',
|
|
7
|
+
dynamic icon,
|
|
8
|
+
Duration? duration,
|
|
9
|
+
bool? autoDismiss,
|
|
10
|
+
}) {
|
|
11
|
+
final toastStatus = status ?? 'info';
|
|
12
|
+
final colorScheme = context.colors;
|
|
13
|
+
final appColors = context.appColors;
|
|
14
|
+
|
|
15
|
+
final (backgroundColor, foregroundColor, iconColor) = switch (toastStatus) {
|
|
16
|
+
'error' => (
|
|
17
|
+
colorScheme.errorContainer,
|
|
18
|
+
colorScheme.onErrorContainer,
|
|
19
|
+
colorScheme.error,
|
|
20
|
+
),
|
|
21
|
+
'success' => (
|
|
22
|
+
appColors.successContainer ?? appColors.success,
|
|
23
|
+
appColors.onSuccessContainer ?? appColors.onSuccess,
|
|
24
|
+
appColors.success,
|
|
25
|
+
),
|
|
26
|
+
'warning' => (
|
|
27
|
+
appColors.warningContainer ?? appColors.warning,
|
|
28
|
+
appColors.onWarningContainer ?? appColors.onWarning,
|
|
29
|
+
appColors.warning,
|
|
30
|
+
),
|
|
31
|
+
'info' => (
|
|
32
|
+
appColors.infoContainer ?? appColors.info,
|
|
33
|
+
appColors.onInfoContainer ?? appColors.onInfo,
|
|
34
|
+
appColors.info,
|
|
35
|
+
),
|
|
36
|
+
_ => (
|
|
37
|
+
context.theme.scaffoldBackgroundColor,
|
|
38
|
+
colorScheme.onSurface,
|
|
39
|
+
colorScheme.onSurfaceVariant,
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return ToastBar(
|
|
44
|
+
position: ToastPosition.top,
|
|
45
|
+
autoDismiss: autoDismiss ?? true,
|
|
46
|
+
toastDuration: duration ?? const Duration(seconds: 2),
|
|
47
|
+
animationDuration: const Duration(milliseconds: 150),
|
|
48
|
+
animationCurve: Curves.easeIn,
|
|
49
|
+
builder: (context) => ToastCard(
|
|
50
|
+
color: backgroundColor,
|
|
51
|
+
shadowColor: colorScheme.shadow.withValues(alpha: 0.05),
|
|
52
|
+
leading: AppIcon(
|
|
53
|
+
icon: icon ??
|
|
54
|
+
(toastStatus == 'success'
|
|
55
|
+
? {{#if flags.usesIconsaxPlus}}IconsaxPlusBold.tick_circle{{else if flags.usesFlutterRemix}}FlutterRemix.checkbox_circle_fill{{else if flags.usesHugeicons}}HugeIcons.strokeRoundedTickCircle{{else}}Icons.check_circle_outline{{/if}}
|
|
56
|
+
: toastStatus == 'error'
|
|
57
|
+
? {{#if flags.usesIconsaxPlus}}IconsaxPlusBold.danger{{else if flags.usesFlutterRemix}}FlutterRemix.error_warning_fill{{else if flags.usesHugeicons}}HugeIcons.strokeRoundedAlertCircle{{else}}Icons.error_outline{{/if}}
|
|
58
|
+
: {{#if flags.usesIconsaxPlus}}IconsaxPlusBold.info_circle{{else if flags.usesFlutterRemix}}FlutterRemix.information_fill{{else if flags.usesHugeicons}}HugeIcons.strokeRoundedInformationCircle{{else}}Icons.info_outline{{/if}}),
|
|
59
|
+
color: iconColor,
|
|
60
|
+
size: {{res 22 'sp' flags.usesScreenutil}},
|
|
61
|
+
),
|
|
62
|
+
title: Text(
|
|
63
|
+
message,
|
|
64
|
+
style: context.theme.textTheme.labelSmall!.copyWith(
|
|
65
|
+
fontWeight: FontWeight.w600,
|
|
66
|
+
fontSize: {{res 11 'sp' flags.usesScreenutil}},
|
|
67
|
+
color: foregroundColor,
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
).show(context);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void showGlobalToast({
|
|
75
|
+
required String message,
|
|
76
|
+
String? status = 'success',
|
|
77
|
+
dynamic icon,
|
|
78
|
+
Duration? duration,
|
|
79
|
+
bool? autoDismiss,
|
|
80
|
+
}) {
|
|
81
|
+
final ctx = rootContext;
|
|
82
|
+
if (ctx == null) return;
|
|
83
|
+
|
|
84
|
+
showToast(
|
|
85
|
+
ctx,
|
|
86
|
+
message: message,
|
|
87
|
+
status: status,
|
|
88
|
+
icon: icon,
|
|
89
|
+
duration: duration,
|
|
90
|
+
autoDismiss: autoDismiss,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
export 'use_copy.dart';
|
|
3
|
+
{{#if flags.usesSharePlus}}
|
|
4
|
+
export 'use_share.dart';
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if flags.usesPermissionHandler}}
|
|
7
|
+
export 'use_permission.dart';
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if flags.usesUrlLauncher}}
|
|
10
|
+
export 'use_launch_url.dart';
|
|
11
|
+
{{/if}}
|
|
12
|
+
export 'use_timer.dart';
|
|
13
|
+
{{/if}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
import '../../imports/imports.dart';
|
|
3
|
+
|
|
4
|
+
/// A hook to handle copying text to clipboard with state feedback.
|
|
5
|
+
(Future<void> Function(String), bool) useCopy() {
|
|
6
|
+
final hasCopied = useState(false);
|
|
7
|
+
|
|
8
|
+
Future<void> copyToClipboard(String text) async {
|
|
9
|
+
try {
|
|
10
|
+
hasCopied.value = true;
|
|
11
|
+
await Clipboard.setData(ClipboardData(text: text));
|
|
12
|
+
|
|
13
|
+
showGlobalToast(
|
|
14
|
+
message: 'Copied successfully',
|
|
15
|
+
status: 'success',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
await Future.delayed(
|
|
19
|
+
const Duration(seconds: 2),
|
|
20
|
+
() => hasCopied.value = false,
|
|
21
|
+
);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
AppLogger.error('Error copying to clipboard: $e');
|
|
24
|
+
hasCopied.value = false;
|
|
25
|
+
|
|
26
|
+
showGlobalToast(
|
|
27
|
+
message: 'Failed to copy',
|
|
28
|
+
status: 'error',
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
useEffect(() {
|
|
34
|
+
return () {
|
|
35
|
+
hasCopied.value = false;
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
return (copyToClipboard, hasCopied.value);
|
|
40
|
+
}
|
|
41
|
+
{{/if}}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
import 'dart:async';
|
|
3
|
+
import 'package:flutter/widgets.dart';
|
|
4
|
+
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
5
|
+
|
|
6
|
+
/// A lightweight immutable value representing the current time and time left.
|
|
7
|
+
class TimerTick {
|
|
8
|
+
const TimerTick({required this.now, required this.remaining});
|
|
9
|
+
|
|
10
|
+
final DateTime now;
|
|
11
|
+
final Duration remaining;
|
|
12
|
+
|
|
13
|
+
/// Convenience formatted remaining time as mm:ss.
|
|
14
|
+
String get remainingMmSs => formatMmSs(remaining);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Runs a countdown for [duration], invokes [onComplete] at the end, and
|
|
18
|
+
/// returns the current [TimerTick] containing `now` and `remaining`.
|
|
19
|
+
///
|
|
20
|
+
/// - Set [isActive] to false to stop the timer.
|
|
21
|
+
/// - Changing [duration], [isActive], [tick], or [onComplete] restarts logic.
|
|
22
|
+
/// - The timer is cancelled automatically on dispose.
|
|
23
|
+
TimerTick useTimer({
|
|
24
|
+
required Duration duration,
|
|
25
|
+
required VoidCallback onComplete,
|
|
26
|
+
bool isActive = true,
|
|
27
|
+
Duration tick = const Duration(seconds: 1),
|
|
28
|
+
bool autoStart = true,
|
|
29
|
+
}) =>
|
|
30
|
+
use(_TimerHook(
|
|
31
|
+
duration: duration,
|
|
32
|
+
onComplete: onComplete,
|
|
33
|
+
isActive: isActive,
|
|
34
|
+
tick: tick,
|
|
35
|
+
autoStart: autoStart,
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
class _TimerHook extends Hook<TimerTick> {
|
|
39
|
+
const _TimerHook({
|
|
40
|
+
required this.duration,
|
|
41
|
+
required this.onComplete,
|
|
42
|
+
required this.isActive,
|
|
43
|
+
required this.tick,
|
|
44
|
+
required this.autoStart,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
final Duration duration;
|
|
48
|
+
final VoidCallback onComplete;
|
|
49
|
+
final bool isActive;
|
|
50
|
+
final Duration tick;
|
|
51
|
+
final bool autoStart;
|
|
52
|
+
|
|
53
|
+
@override
|
|
54
|
+
HookState<TimerTick, _TimerHook> createState() => _TimerHookState();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class _TimerHookState extends HookState<TimerTick, _TimerHook> {
|
|
58
|
+
Timer? _timer;
|
|
59
|
+
late DateTime _now;
|
|
60
|
+
late Duration _remaining;
|
|
61
|
+
DateTime? startedAt;
|
|
62
|
+
int? _lastLoggedRemainingSecs;
|
|
63
|
+
late VoidCallback _onComplete;
|
|
64
|
+
|
|
65
|
+
@override
|
|
66
|
+
void initHook() {
|
|
67
|
+
super.initHook();
|
|
68
|
+
_now = DateTime.now();
|
|
69
|
+
_remaining = hook.duration;
|
|
70
|
+
_onComplete = hook.onComplete;
|
|
71
|
+
_lastLoggedRemainingSecs = _remaining.inSeconds;
|
|
72
|
+
|
|
73
|
+
if (hook.autoStart) {
|
|
74
|
+
_startOrStop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@override
|
|
79
|
+
void didUpdateHook(covariant _TimerHook oldHook) {
|
|
80
|
+
super.didUpdateHook(oldHook);
|
|
81
|
+
final shouldRestart = oldHook.duration != hook.duration ||
|
|
82
|
+
oldHook.isActive != hook.isActive ||
|
|
83
|
+
oldHook.tick != hook.tick;
|
|
84
|
+
// Always keep the latest completion callback without forcing a restart.
|
|
85
|
+
if (oldHook.onComplete != hook.onComplete) {
|
|
86
|
+
_onComplete = hook.onComplete;
|
|
87
|
+
}
|
|
88
|
+
if (shouldRestart) _startOrStop();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@override
|
|
92
|
+
TimerTick build(BuildContext context) =>
|
|
93
|
+
TimerTick(now: _now, remaining: _remaining);
|
|
94
|
+
|
|
95
|
+
void _startOrStop() {
|
|
96
|
+
_timer?.cancel();
|
|
97
|
+
startedAt = DateTime.now();
|
|
98
|
+
_now = startedAt!;
|
|
99
|
+
_remaining = hook.duration;
|
|
100
|
+
_lastLoggedRemainingSecs = _remaining.inSeconds;
|
|
101
|
+
if (!hook.isActive) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void handleTick() {
|
|
106
|
+
final current = DateTime.now();
|
|
107
|
+
final elapsed = current.difference(startedAt!);
|
|
108
|
+
final left = hook.duration - elapsed;
|
|
109
|
+
final leftSecs = left.inSeconds;
|
|
110
|
+
if (left <= Duration.zero) {
|
|
111
|
+
_now = current;
|
|
112
|
+
_remaining = Duration.zero;
|
|
113
|
+
_timer?.cancel();
|
|
114
|
+
|
|
115
|
+
if (context.mounted) _onComplete();
|
|
116
|
+
setState(() {});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
setState(() {
|
|
121
|
+
_now = current;
|
|
122
|
+
_remaining = left;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
if (_lastLoggedRemainingSecs != leftSecs) {
|
|
126
|
+
_lastLoggedRemainingSecs = leftSecs;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Fire an immediate tick so the UI reflects that the timer started
|
|
131
|
+
// without waiting for the first interval.
|
|
132
|
+
handleTick();
|
|
133
|
+
|
|
134
|
+
// Periodic updates to compute remaining and call completion.
|
|
135
|
+
_timer = Timer.periodic(hook.tick, (_) => handleTick());
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@override
|
|
139
|
+
void dispose() {
|
|
140
|
+
_timer?.cancel();
|
|
141
|
+
super.dispose();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// Formats a [Duration] adaptively as:
|
|
146
|
+
/// - H:MM:SS when hours > 0
|
|
147
|
+
/// - M:SS otherwise (including pure seconds)
|
|
148
|
+
String formatMmSs(Duration duration) {
|
|
149
|
+
final totalSeconds = duration.inSeconds < 0 ? 0 : duration.inSeconds;
|
|
150
|
+
final hours = totalSeconds ~/ 3600;
|
|
151
|
+
final minutes = (totalSeconds % 3600) ~/ 60;
|
|
152
|
+
final seconds = totalSeconds % 60;
|
|
153
|
+
if (hours > 0) {
|
|
154
|
+
return '$hours:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
|
|
155
|
+
}
|
|
156
|
+
return '$minutes:${seconds.toString().padLeft(2, '0')}';
|
|
157
|
+
}
|
|
158
|
+
{{/if}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export 'helpers/imports.dart';
|
|
2
|
+
export '../extensions/extensions.dart';
|
|
3
|
+
export '../utils/utils.dart';
|
|
4
|
+
|
|
5
|
+
export 'enums/enums.dart';
|
|
6
|
+
export 'widgets/widgets.dart';
|
|
7
|
+
export '../theme/theme_constants.dart';
|
|
8
|
+
export 'wrappers/wrappers.dart';
|
|
9
|
+
export 'app_assets.dart';
|
|
10
|
+
{{#if flags.usesFlutterHooks}}
|
|
11
|
+
export 'hooks/hooks.dart';
|
|
12
|
+
{{/if}}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import '../../imports/imports.dart';
|
|
2
|
+
|
|
3
|
+
/// A fully themed button supporting all [ButtonVariant]s and [ButtonSize]s.
|
|
4
|
+
///
|
|
5
|
+
/// Usage:
|
|
6
|
+
/// ```dart
|
|
7
|
+
/// AppButton(
|
|
8
|
+
/// label: 'Save',
|
|
9
|
+
/// onPressed: _save,
|
|
10
|
+
/// variant: ButtonVariant.primary,
|
|
11
|
+
/// size: ButtonSize.large,
|
|
12
|
+
/// isLoading: state.isLoading,
|
|
13
|
+
/// )
|
|
14
|
+
/// ```
|
|
15
|
+
class AppButton extends StatelessWidget {
|
|
16
|
+
const AppButton({
|
|
17
|
+
super.key,
|
|
18
|
+
required this.label,
|
|
19
|
+
this.onPressed,
|
|
20
|
+
this.variant = ButtonVariant.primary,
|
|
21
|
+
this.color,
|
|
22
|
+
this.textColor,
|
|
23
|
+
this.height = ButtonSize.medium,
|
|
24
|
+
this.width,
|
|
25
|
+
this.isLoading = false,
|
|
26
|
+
this.isFullWidth = false,
|
|
27
|
+
this.prefixIcon,
|
|
28
|
+
this.suffixIcon,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
final String label;
|
|
32
|
+
final VoidCallback? onPressed;
|
|
33
|
+
final ButtonVariant variant;
|
|
34
|
+
final Color? color;
|
|
35
|
+
final Color? textColor;
|
|
36
|
+
final ButtonSize height;
|
|
37
|
+
final ButtonSize? width;
|
|
38
|
+
final bool isLoading;
|
|
39
|
+
final bool isFullWidth;
|
|
40
|
+
final Widget? prefixIcon;
|
|
41
|
+
final Widget? suffixIcon;
|
|
42
|
+
|
|
43
|
+
@override
|
|
44
|
+
Widget build(BuildContext context) {
|
|
45
|
+
final cs = context.theme.colorScheme;
|
|
46
|
+
final appColors = context.theme.extension<AppColorsExtension>()!;
|
|
47
|
+
final isDisabled = onPressed == null || isLoading;
|
|
48
|
+
|
|
49
|
+
final double buttonHeight = switch (height) {
|
|
50
|
+
ButtonSize.small => {{res 36 'h' flags.usesScreenutil}},
|
|
51
|
+
ButtonSize.medium => {{res 48 'h' flags.usesScreenutil}},
|
|
52
|
+
ButtonSize.large => {{res 56 'h' flags.usesScreenutil}},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
final double? buttonWidth = switch (width) {
|
|
56
|
+
ButtonSize.small => {{res 100 'w' flags.usesScreenutil}},
|
|
57
|
+
ButtonSize.medium => {{res 150 'w' flags.usesScreenutil}},
|
|
58
|
+
ButtonSize.large => {{res 200 'w' flags.usesScreenutil}},
|
|
59
|
+
null => null,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
final double horizontalPadding = switch (height) {
|
|
63
|
+
ButtonSize.small => {{res 12 'w' flags.usesScreenutil}},
|
|
64
|
+
ButtonSize.medium => {{res 20 'w' flags.usesScreenutil}},
|
|
65
|
+
ButtonSize.large => {{res 28 'w' flags.usesScreenutil}},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
final double fontSize = switch (height) {
|
|
69
|
+
ButtonSize.small => {{res 12 'sp' flags.usesScreenutil}},
|
|
70
|
+
ButtonSize.medium => {{res 14 'sp' flags.usesScreenutil}},
|
|
71
|
+
ButtonSize.large => {{res 16 'sp' flags.usesScreenutil}},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
final (bg, fg, border) = switch (variant) {
|
|
75
|
+
ButtonVariant.primary => (color ?? cs.primary, color ?? cs.onPrimary, null),
|
|
76
|
+
ButtonVariant.secondary => (cs.secondaryContainer, cs.onSecondaryContainer, null),
|
|
77
|
+
ButtonVariant.outline => (Colors.transparent, cs.primary, BorderSide(color: cs.outline, width: 1.5)),
|
|
78
|
+
ButtonVariant.ghost => (Colors.transparent, cs.primary, null),
|
|
79
|
+
ButtonVariant.danger => (cs.error, cs.onError, null),
|
|
80
|
+
ButtonVariant.success => (appColors.success, appColors.onSuccess, null),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
final child = AnimatedSwitcher(
|
|
84
|
+
duration: AppDurations.fast,
|
|
85
|
+
switchInCurve: AppCurves.decelerate,
|
|
86
|
+
child: isLoading
|
|
87
|
+
? SizedBox(
|
|
88
|
+
key: const ValueKey('loader'),
|
|
89
|
+
width: {{res 20 'w' flags.usesScreenutil}},
|
|
90
|
+
height: {{res 20 'h' flags.usesScreenutil}},
|
|
91
|
+
child: CircularProgressIndicator(
|
|
92
|
+
strokeWidth: 2,
|
|
93
|
+
color: fg,
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
: Row(
|
|
97
|
+
key: const ValueKey('content'),
|
|
98
|
+
mainAxisSize: MainAxisSize.min,
|
|
99
|
+
children: [
|
|
100
|
+
if (prefixIcon != null) ...[
|
|
101
|
+
prefixIcon!,
|
|
102
|
+
{{#if flags.usesScreenutil}}SizedBox(width: 8.w){{else}}const SizedBox(width: 8){{/if}},
|
|
103
|
+
],
|
|
104
|
+
Text(
|
|
105
|
+
label,
|
|
106
|
+
style: TextStyle(
|
|
107
|
+
fontSize: fontSize,
|
|
108
|
+
fontWeight: FontWeight.w600,
|
|
109
|
+
color: isDisabled ? fg.withValues(alpha: 0.5) : textColor ?? fg,
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
if (suffixIcon != null) ...[
|
|
113
|
+
{{#if flags.usesScreenutil}}SizedBox(width: 8.w){{else}}const SizedBox(width: 8){{/if}},
|
|
114
|
+
suffixIcon!,
|
|
115
|
+
],
|
|
116
|
+
],
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return AnimatedOpacity(
|
|
121
|
+
duration: AppDurations.fast,
|
|
122
|
+
opacity: isDisabled ? 0.6 : 1.0,
|
|
123
|
+
child: SizedBox(
|
|
124
|
+
width: isFullWidth ? double.infinity : buttonWidth,
|
|
125
|
+
height: buttonHeight,
|
|
126
|
+
child: TextButton(
|
|
127
|
+
onPressed: isDisabled ? null : onPressed,
|
|
128
|
+
style: TextButton.styleFrom(
|
|
129
|
+
backgroundColor: bg,
|
|
130
|
+
foregroundColor: fg,
|
|
131
|
+
padding: EdgeInsets.symmetric(horizontal: horizontalPadding),
|
|
132
|
+
shape: border != null
|
|
133
|
+
? RoundedRectangleBorder(
|
|
134
|
+
borderRadius: AppBorders.button,
|
|
135
|
+
side: border,
|
|
136
|
+
)
|
|
137
|
+
: const RoundedRectangleBorder(borderRadius: AppBorders.button),
|
|
138
|
+
),
|
|
139
|
+
child: child,
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import '../../imports/imports.dart';
|
|
2
|
+
|
|
3
|
+
/// A themed card widget with consistent padding, radius, and optional header.
|
|
4
|
+
///
|
|
5
|
+
/// Usage:
|
|
6
|
+
/// ```dart
|
|
7
|
+
/// AppCard(
|
|
8
|
+
/// child: Text('Card content'),
|
|
9
|
+
/// )
|
|
10
|
+
///
|
|
11
|
+
/// // With a header
|
|
12
|
+
/// AppCard(
|
|
13
|
+
/// title: 'Recent Transactions',
|
|
14
|
+
/// trailing: TextButton(onPressed: _seeAll, child: const Text('See all')),
|
|
15
|
+
/// child: TransactionList(),
|
|
16
|
+
/// )
|
|
17
|
+
/// ```
|
|
18
|
+
class AppCard extends StatelessWidget {
|
|
19
|
+
const AppCard({
|
|
20
|
+
super.key,
|
|
21
|
+
required this.child,
|
|
22
|
+
this.title,
|
|
23
|
+
this.subtitle,
|
|
24
|
+
this.leading,
|
|
25
|
+
this.trailing,
|
|
26
|
+
this.padding,
|
|
27
|
+
this.margin,
|
|
28
|
+
this.onTap,
|
|
29
|
+
this.showShadow = false,
|
|
30
|
+
this.color,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
final Widget child;
|
|
34
|
+
final String? title;
|
|
35
|
+
final String? subtitle;
|
|
36
|
+
final Widget? leading;
|
|
37
|
+
final Widget? trailing;
|
|
38
|
+
final EdgeInsetsGeometry? padding;
|
|
39
|
+
final EdgeInsetsGeometry? margin;
|
|
40
|
+
final VoidCallback? onTap;
|
|
41
|
+
|
|
42
|
+
/// When true, uses [AppShadows.card] instead of a border outline.
|
|
43
|
+
final bool showShadow;
|
|
44
|
+
final Color? color;
|
|
45
|
+
|
|
46
|
+
@override
|
|
47
|
+
Widget build(BuildContext context) {
|
|
48
|
+
final cs = context.theme.colorScheme;
|
|
49
|
+
final tt = context.theme.textTheme;
|
|
50
|
+
|
|
51
|
+
final cardColor = color ?? cs.surfaceContainerLow;
|
|
52
|
+
|
|
53
|
+
final Widget content = Column(
|
|
54
|
+
mainAxisSize: MainAxisSize.min,
|
|
55
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
56
|
+
children: [
|
|
57
|
+
if (title != null || leading != null || trailing != null)
|
|
58
|
+
Padding(
|
|
59
|
+
padding: EdgeInsets.only(
|
|
60
|
+
left: AppSpacing.md,
|
|
61
|
+
right: AppSpacing.md,
|
|
62
|
+
top: AppSpacing.md,
|
|
63
|
+
bottom: AppSpacing.sm,
|
|
64
|
+
),
|
|
65
|
+
child: Row(
|
|
66
|
+
children: [
|
|
67
|
+
if (leading != null) ...[leading!, {{#if flags.usesScreenutil}}SizedBox(width: 12.w){{else}}const SizedBox(width: 12){{/if}}],
|
|
68
|
+
Expanded(
|
|
69
|
+
child: Column(
|
|
70
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
71
|
+
children: [
|
|
72
|
+
if (title != null)
|
|
73
|
+
Text(
|
|
74
|
+
title!,
|
|
75
|
+
style: tt.titleMedium?.copyWith(
|
|
76
|
+
fontWeight: FontWeight.w600,
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
if (subtitle != null)
|
|
80
|
+
Text(
|
|
81
|
+
subtitle!,
|
|
82
|
+
style: tt.bodySmall?.copyWith(
|
|
83
|
+
color: cs.onSurfaceVariant,
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
],
|
|
87
|
+
),
|
|
88
|
+
),
|
|
89
|
+
if (trailing != null) trailing!,
|
|
90
|
+
],
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
Padding(
|
|
94
|
+
padding: padding ??
|
|
95
|
+
EdgeInsets.fromLTRB(
|
|
96
|
+
AppSpacing.md,
|
|
97
|
+
title == null ? AppSpacing.md : 0,
|
|
98
|
+
AppSpacing.md,
|
|
99
|
+
AppSpacing.md,
|
|
100
|
+
),
|
|
101
|
+
child: child,
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return Container(
|
|
107
|
+
margin: margin,
|
|
108
|
+
decoration: BoxDecoration(
|
|
109
|
+
color: cardColor,
|
|
110
|
+
borderRadius: AppBorders.card,
|
|
111
|
+
border: showShadow
|
|
112
|
+
? null
|
|
113
|
+
: Border.all(color: cs.outlineVariant, width: 1),
|
|
114
|
+
boxShadow: showShadow ? AppShadows.card : AppShadows.none,
|
|
115
|
+
),
|
|
116
|
+
clipBehavior: Clip.antiAlias,
|
|
117
|
+
child: onTap != null
|
|
118
|
+
? InkWell(
|
|
119
|
+
onTap: onTap,
|
|
120
|
+
borderRadius: AppBorders.card,
|
|
121
|
+
child: content,
|
|
122
|
+
)
|
|
123
|
+
: content,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|