fix: fixing laoyout in login screen

This commit is contained in:
pahmiudahgede 2025-05-24 17:14:08 +07:00
parent ce514d0a27
commit b988933413
11 changed files with 437 additions and 219 deletions

View File

@ -1,4 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="Rijig"
android:name="${applicationName}"

View File

@ -1,11 +1,9 @@
import 'package:rijig_mobile/core/utils/exportimportview.dart';
import 'package:rijig_mobile/features/home/presentation/screen/collector/pickup_history_screen.dart';
import 'package:rijig_mobile/features/pickup/presentation/screen/pickup_map_screen.dart';
final router = GoRouter(
routes: [
// GoRoute(path: '/', builder: (context, state) => SplashScreen()),
GoRoute(path: '/', builder: (context, state) => CollectorRouteMapScreen()),
GoRoute(path: '/', builder: (context, state) => SplashScreen()),
GoRoute(path: '/cmapview', builder: (context, state) => CollectorRouteMapScreen()),
GoRoute(
path: '/onboarding',
builder: (context, state) => OnboardingPageScreen(),

View File

@ -15,8 +15,10 @@ export 'package:rijig_mobile/features/home/presentation/components/about_detail_
export 'package:rijig_mobile/features/home/presentation/components/article_content.dart';
export 'package:rijig_mobile/features/pickup/presentation/screen/pickup_screen.dart';
export 'package:rijig_mobile/features/pickup/presentation/screen/selectcollector_screen.dart';
export 'package:rijig_mobile/features/auth/presentation/screen/collector/clogin_screen.dart';
export 'package:rijig_mobile/features/auth/presentation/screen/collector/identity_validation_screen.dart';
export 'package:rijig_mobile/features/auth/presentation/screen/collector/welcome_collector_screen.dart';
export 'package:rijig_mobile/features/home/presentation/screen/collector/chome_screen.dart';
export 'package:rijig_mobile/features/auth/presentation/screen/collector/cotp_screen.dart';
export 'package:rijig_mobile/features/auth/presentation/screen/collector/clogin_screen.dart';
export 'package:rijig_mobile/features/home/presentation/screen/collector/pickup_history_screen.dart';
export 'package:rijig_mobile/features/pickup/presentation/screen/pickup_map_screen.dart';

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gap/gap.dart';
import 'package:rijig_mobile/core/router.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
import 'package:rijig_mobile/widget/buttoncard.dart';
@ -10,82 +9,112 @@ class CloginScreen extends StatefulWidget {
const CloginScreen({super.key});
@override
State<CloginScreen> createState() => _CloginScreenState();
CloginScreenState createState() => CloginScreenState();
}
class _CloginScreenState extends State<CloginScreen> {
class CloginScreenState extends State<CloginScreen> {
final TextEditingController cPhoneController = TextEditingController();
@override
void dispose() {
cPhoneController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
return Scaffold(
body: SafeArea(
child: Center(
child: Padding(
padding: PaddingCustom().paddingHorizontalVertical(15, 40),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
"Selamat datang di aplikasi",
style: Tulisan.subheading(),
),
Text("Rijig", style: Tulisan.heading(color: primaryColor)),
SizedBox(height: mediaQuery.size.height * 0.2),
Column(
children: [
Image.asset(
'assets/image/security.png',
width: mediaQuery.size.width * 0.35,
),
FormFieldOne(
controllers: cPhoneController,
hintText: 'Masukkan nomor whatsapp anda!',
placeholder: "cth.62..",
isRequired: true,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
onTap: () {},
onChanged: (value) {},
fontSize: 14,
fontSizeField: 16,
onFieldSubmitted: (value) {},
readOnly: false,
enabled: true,
),
SizedBox(height: 20),
CardButtonOne(
textButton: "Kirim OTP",
fontSized: 16.sp,
colorText: whiteColor,
color: primaryColor,
borderRadius: 10,
horizontal: double.infinity,
vertical: 50,
onTap: () {
router.go('/cverif-otp');
},
usingRow: false,
),
],
),
Gap(20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("kembali ke login sebagai:"),
TextButton(
onPressed: () => router.go('/login'),
child: Text("masyarakat?"),
),
],
),
],
),
],
return Scaffold(
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
padding: PaddingCustom().paddingHorizontalVertical(15, 40),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight:
mediaQuery.size.height * 1 / 4 -
mediaQuery.padding.top -
mediaQuery.padding.bottom,
),
child: IntrinsicHeight(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
"Selamat datang di aplikasi",
style: Tulisan.subheading(),
),
Text(
"Rijig",
style: Tulisan.heading(color: primaryColor),
),
SizedBox(height: mediaQuery.size.height * 0.1),
Image.asset(
'assets/image/security.png',
width: mediaQuery.size.width * 0.35,
),
SizedBox(height: 30),
FormFieldOne(
controllers: cPhoneController,
hintText: 'Masukkan nomor whatsapp anda!',
placeholder: "cth.62..",
isRequired: true,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
onTap: () {},
onChanged: (value) {},
fontSize: 14,
fontSizeField: 16,
onFieldSubmitted: (value) {},
readOnly: false,
enabled: true,
),
SizedBox(height: 20),
CardButtonOne(
textButton: "kirim otp",
// viewModel.isLoading
// ? 'Sending OTP...'
// : 'Send OTP',
fontSized: 16.sp,
colorText: whiteColor,
color: primaryColor,
borderRadius: 10,
horizontal: double.infinity,
vertical: 50,
onTap: () {
// if (cPhoneController.text.isNotEmpty) {
// debugPrint("send otp dipencet");
// await viewModel.loginOrRegister(
// cPhoneController.text,
// );
// if (viewModel.loginResponse != null) {
// router.go(
// "/verif-otp",
// extra: cPhoneController.text,
// );
// }
// }
},
// loadingTrue: viewModel.isLoading,
usingRow: false,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("login sebagai:"),
TextButton(
onPressed: () => router.push('/login'),
child: Text("masyarakat?"),
),
],
),
],
),
),
),
),

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:provider/provider.dart';
import 'package:rijig_mobile/core/router.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
@ -15,103 +14,118 @@ class LoginScreen extends StatefulWidget {
}
class LoginScreenState extends State<LoginScreen> {
final TextEditingController phoneController = TextEditingController();
@override
void dispose() {
phoneController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
final TextEditingController phoneController = TextEditingController();
return Scaffold(
resizeToAvoidBottomInset: true,
body: Consumer<LoginViewModel>(
builder: (context, viewModel, child) {
return SafeArea(
child: Center(
child: Padding(
padding: PaddingCustom().paddingHorizontalVertical(15, 40),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
"Selamat datang di aplikasi",
style: Tulisan.subheading(),
),
Text(
"Rijig",
style: Tulisan.heading(color: primaryColor),
),
// Gap(60),
SizedBox(height: mediaQuery.size.height * 0.2),
Column(
children: [
// Image.asset(
// 'assets/image/security.png',
// width: mediaQuery.size.width * 0.35,
// ),
FormFieldOne(
controllers: phoneController,
hintText: 'Masukkan nomor whatsapp anda!',
placeholder: "cth.62..",
isRequired: true,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
onTap: () {},
onChanged: (value) {},
fontSize: 14,
fontSizeField: 16,
onFieldSubmitted: (value) {},
readOnly: false,
enabled: true,
),
SizedBox(height: 20),
CardButtonOne(
textButton:
viewModel.isLoading
? 'Sending OTP...'
: 'Send OTP',
fontSized: 16,
colorText: whiteColor,
color: primaryColor,
borderRadius: 10,
horizontal: double.infinity,
vertical: 50,
onTap: () async {
if (phoneController.text.isNotEmpty) {
debugPrint("send otp dipencet");
await viewModel.loginOrRegister(
phoneController.text,
child: SingleChildScrollView(
padding: PaddingCustom().paddingHorizontalVertical(15, 40),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight:
mediaQuery.size.height * 1 / 4 -
mediaQuery.padding.top -
mediaQuery.padding.bottom,
),
child: IntrinsicHeight(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
"Selamat datang di aplikasi",
style: Tulisan.subheading(),
),
Text(
"Rijig",
style: Tulisan.heading(color: primaryColor),
),
SizedBox(height: mediaQuery.size.height * 0.1),
Image.asset(
'assets/image/security.png',
width: mediaQuery.size.width * 0.35,
),
SizedBox(height: 30),
FormFieldOne(
controllers: phoneController,
hintText: 'Masukkan nomor whatsapp anda!',
placeholder: "cth.62..",
isRequired: true,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
onTap: () {},
onChanged: (value) {},
fontSize: 14,
fontSizeField: 16,
onFieldSubmitted: (value) {},
readOnly: false,
enabled: true,
),
SizedBox(height: 20),
CardButtonOne(
textButton:
viewModel.isLoading
? 'Sending OTP...'
: 'Send OTP',
fontSized: 16,
colorText: whiteColor,
color: primaryColor,
borderRadius: 10,
horizontal: double.infinity,
vertical: 50,
onTap: () async {
if (phoneController.text.isNotEmpty) {
debugPrint("send otp dipencet");
await viewModel.loginOrRegister(
phoneController.text,
);
if (viewModel.loginResponse != null) {
router.go(
"/verif-otp",
extra: phoneController.text,
);
if (viewModel.loginResponse != null) {
router.go(
"/verif-otp",
extra: phoneController.text,
);
}
}
},
loadingTrue: viewModel.isLoading,
usingRow: false,
),
],
),
Gap(20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("login sebagai:"),
TextButton(
onPressed: () => router.push('/welcomec'),
child: Text("pengepul?"),
),
],
),
Gap(20),
TextButton(
onPressed: () => router.push('/navigasi'),
child: Text("skip login"),
),
],
),
],
}
},
loadingTrue: viewModel.isLoading,
usingRow: false,
),
],
),
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("login sebagai:"),
TextButton(
onPressed: () => router.push('/welcomec'),
child: Text("pengepul?"),
),
],
),
TextButton(
onPressed: () => router.push('/navigasi'),
child: Text("skip login"),
),
],
),
],
),
),
),
),

View File

@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
import 'package:rijig_mobile/widget/appbar.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:toastification/toastification.dart';
import 'package:geolocator/geolocator.dart';
class CollectorRouteMapScreen extends StatefulWidget {
const CollectorRouteMapScreen({super.key});
@ -13,79 +16,141 @@ class CollectorRouteMapScreen extends StatefulWidget {
}
class _CollectorRouteMapScreenState extends State<CollectorRouteMapScreen> {
final LatLng userLocation = LatLng(-7.250445, 112.768845);
LatLng? userLocation;
final LatLng collectorLocation = LatLng(-7.260445, 112.758845);
@override
void initState() {
super.initState();
_initializeLocation();
}
Future<void> _initializeLocation() async {
final status = await Permission.location.request();
if (status.isGranted) {
try {
final LocationSettings locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
);
Position position = await Geolocator.getCurrentPosition(
locationSettings: locationSettings,
);
setState(() {
userLocation = LatLng(position.latitude, position.longitude);
});
} catch (e) {
toastification.show(
type: ToastificationType.error,
title: const Text("Gagal mendapatkan lokasi"),
description: Text(e.toString()),
);
}
} else if (status.isDenied) {
toastification.show(
type: ToastificationType.warning,
title: const Text("Izin lokasi ditolak sementara"),
autoCloseDuration: const Duration(seconds: 3),
);
} else if (status.isPermanentlyDenied) {
toastification.show(
type: ToastificationType.error,
title: const Text("Izin lokasi ditolak permanen"),
description: const Text(
"Buka pengaturan untuk mengaktifkan izin lokasi.",
),
);
}
}
Future<void> openMapWithGoogle(double latitude, double longitude) async {
if (userLocation == null) return;
final url =
'https://www.google.com/maps/dir/?api=1&destination=$latitude,$longitude';
'https://www.google.com/maps/dir/?api=1&origin=${userLocation!.latitude},${userLocation!.longitude}&destination=$latitude,$longitude';
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.externalApplication);
} else {
debugPrint("tidak dapat membuka google maps");
toastification.show(
type: ToastificationType.error,
title: const Text("Gagal membuka Google Maps"),
autoCloseDuration: const Duration(seconds: 3),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Peta Lokasi"),
backgroundColor: Colors.green,
foregroundColor: Colors.white,
),
body: Stack(
children: [
FlutterMap(
options: MapOptions(initialCenter: userLocation, initialZoom: 13),
children: [
TileLayer(
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
),
MarkerLayer(
markers: [
Marker(
point: userLocation,
child: Icon(Icons.location_on, color: redColor, size: 36),
appBar: CustomAppBar(judul: "Lokasi Pengguna"),
body:
userLocation == null
? const Center(child: CircularProgressIndicator())
: Stack(
children: [
FlutterMap(
options: MapOptions(
initialCenter: userLocation!,
initialZoom: 13,
),
children: [
TileLayer(
urlTemplate:
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
),
MarkerLayer(
markers: [
Marker(
point: userLocation!,
child: const Icon(
Icons.location_on,
color: Colors.blue,
size: 36,
),
),
Marker(
point: collectorLocation,
child: const Icon(
Icons.store,
color: Colors.green,
size: 36,
),
),
],
),
PolylineLayer(
polylines: [
Polyline(
points: [userLocation!, collectorLocation],
strokeWidth: 4,
color: Colors.orange,
),
],
),
],
),
Marker(
point: collectorLocation,
child: Icon(Icons.store, color: primaryColor, size: 36),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(vertical: 14),
),
onPressed:
() => openMapWithGoogle(
collectorLocation.latitude,
collectorLocation.longitude,
),
child: const Text("Buka di Google Maps"),
),
),
],
),
PolylineLayer(
polylines: [
Polyline(
points: [userLocation, collectorLocation],
strokeWidth: 4,
color: Colors.orange,
),
],
),
],
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: PaddingCustom().paddingVertical(14),
),
onPressed:
() => openMapWithGoogle(
collectorLocation.latitude,
collectorLocation.longitude,
),
child: const Text("Buka di Google Maps"),
),
),
],
),
);
}
}

View File

@ -9,6 +9,7 @@ import connectivity_plus
import device_info_plus
import file_selector_macos
import flutter_secure_storage_macos
import geolocator_apple
import path_provider_foundation
import shared_preferences_foundation
import url_launcher_macos
@ -18,6 +19,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

View File

@ -384,6 +384,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.1"
geolocator:
dependency: "direct main"
description:
name: geolocator
sha256: e7ebfa04ce451daf39b5499108c973189a71a919aa53c1204effda1c5b93b822
url: "https://pub.dev"
source: hosted
version: "14.0.0"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
sha256: "114072db5d1dce0ec0b36af2697f55c133bc89a2c8dd513e137c0afe59696ed4"
url: "https://pub.dev"
source: hosted
version: "5.0.1+1"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
sha256: dbdd8789d5aaf14cf69f74d4925ad1336b4433a6efdf2fce91e8955dc921bf22
url: "https://pub.dev"
source: hosted
version: "2.3.13"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
sha256: "30cb64f0b9adcc0fb36f628b4ebf4f731a2961a0ebd849f4b56200205056fe67"
url: "https://pub.dev"
source: hosted
version: "4.2.6"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
sha256: b1ae9bdfd90f861fde8fd4f209c37b953d65e92823cb73c7dee1fa021b06f172
url: "https://pub.dev"
source: hosted
version: "4.1.3"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
sha256: "175435404d20278ffd220de83c2ca293b73db95eafbdc8131fe8609be1421eb6"
url: "https://pub.dev"
source: hosted
version: "0.2.5"
get_it:
dependency: "direct main"
description:
@ -752,6 +800,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.0+3"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: "2d070d8684b68efb580a5997eb62f675e8a885ef0be6e754fb9ef489c177470f"
url: "https://pub.dev"
source: hosted
version: "12.0.0+1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "1e3bc410ca1bf84662104b100eb126e066cb55791b7451307f9708d4007350e6"
url: "https://pub.dev"
source: hosted
version: "13.0.1"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023
url: "https://pub.dev"
source: hosted
version: "9.4.7"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
url: "https://pub.dev"
source: hosted
version: "0.1.3+5"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878
url: "https://pub.dev"
source: hosted
version: "4.3.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
petitparser:
dependency: transitive
description:

View File

@ -26,6 +26,7 @@ dependencies:
flutter_secure_storage: ^9.2.4
flutter_svg: ^2.1.0
gap: ^3.0.1
geolocator: ^14.0.0
get_it: ^8.0.3
go_router: ^15.1.1
google_fonts: ^6.0.0
@ -40,6 +41,7 @@ dependencies:
latlong2: ^0.9.1
localstorage: ^6.0.0
path_provider: ^2.1.5
permission_handler: ^12.0.0+1
pin_code_fields: ^8.0.1
provider: ^6.1.4
shared_preferences: ^2.3.3

View File

@ -9,6 +9,8 @@
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <file_selector_windows/file_selector_windows.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <geolocator_windows/geolocator_windows.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
@ -18,6 +20,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("FileSelectorWindows"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View File

@ -6,6 +6,8 @@ list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus
file_selector_windows
flutter_secure_storage_windows
geolocator_windows
permission_handler_windows
url_launcher_windows
)