first commit
This commit is contained in:
69
lib/ui/views/user_index/user_home/user_home_view.dart
Normal file
69
lib/ui/views/user_index/user_home/user_home_view.dart
Normal file
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import './user_home_view_model.dart';
|
||||
|
||||
class UserHomeView extends StatelessWidget {
|
||||
const UserHomeView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<UserHomeViewModel>.nonReactive(
|
||||
viewModelBuilder: () => UserHomeViewModel(),
|
||||
onViewModelReady: (UserHomeViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
disposeViewModel: false,
|
||||
fireOnViewModelReadyOnce: true,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
UserHomeViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WebView(
|
||||
// initialUrl: 'http://192.168.43.125/rekam-medis',
|
||||
initialUrl: 'http://20.20.20.25/perumahan',
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
onWebViewCreated: (WebViewController webViewController) {
|
||||
// _controller.complete(webViewController);
|
||||
model.webViewControllerCompleter.future
|
||||
.then((value) => model.webVIewcontroller = value);
|
||||
model.webViewControllerCompleter.complete(webViewController);
|
||||
},
|
||||
onProgress: (int progress) {
|
||||
double progressDouble = progress / 100;
|
||||
model.myEasyLoading.showProgress(progressDouble, "Loading Denah");
|
||||
},
|
||||
// javascriptChannels: <JavascriptChannel>{
|
||||
// _toasterJavascriptChannel(context),
|
||||
// },
|
||||
javascriptChannels: <JavascriptChannel>{
|
||||
JavascriptChannel(
|
||||
name: 'messageHandler',
|
||||
onMessageReceived: (JavascriptMessage message) {
|
||||
model.log.d(message.message);
|
||||
// dev.i("message from the web view=\"${message.message}\"");
|
||||
// if (message.message == "coba") {
|
||||
// dev.i("sini untuk coba");
|
||||
// controller.runJavascript("coba22('heheheh')");
|
||||
// }
|
||||
},
|
||||
),
|
||||
},
|
||||
// navigationDelegate: (NavigationRequest request) async {},
|
||||
onPageStarted: (String url) {},
|
||||
onPageFinished: (String url) {
|
||||
// dev.i('Page finished loading: $url');
|
||||
model.myEasyLoading.dismissLoading();
|
||||
},
|
||||
|
||||
gestureNavigationEnabled: true,
|
||||
backgroundColor: const Color(0x00000000),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
25
lib/ui/views/user_index/user_home/user_home_view_model.dart
Normal file
25
lib/ui/views/user_index/user_home/user_home_view_model.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import '../../../../app/app.locator.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../services/my_easyloading.dart';
|
||||
|
||||
class UserHomeViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('UserHomeViewModel');
|
||||
final _myEasyLoading = locator<MyEasyLoading>();
|
||||
|
||||
get myEasyLoading => _myEasyLoading;
|
||||
late WebViewController webVIewcontroller;
|
||||
final Completer<WebViewController> webViewControllerCompleter =
|
||||
Completer<WebViewController>();
|
||||
|
||||
Future<void> init() async {
|
||||
if (Platform.isAndroid) {
|
||||
WebView.platform = SurfaceAndroidWebView();
|
||||
}
|
||||
}
|
||||
}
|
||||
84
lib/ui/views/user_index/user_index_view.dart
Normal file
84
lib/ui/views/user_index/user_index_view.dart
Normal file
@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:perumahan_bew/app/app.router.dart';
|
||||
import 'package:perumahan_bew/app/themes/app_colors.dart';
|
||||
import 'package:perumahan_bew/app/themes/app_text.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stylish_bottom_bar/model/bar_items.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
|
||||
import './user_index_view_model.dart';
|
||||
|
||||
class UserIndexView extends StatelessWidget {
|
||||
const UserIndexView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<UserIndexViewModel>.reactive(
|
||||
viewModelBuilder: () => UserIndexViewModel(),
|
||||
onViewModelReady: (UserIndexViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
disposeViewModel: false,
|
||||
fireOnViewModelReadyOnce: true,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
UserIndexViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
model.header,
|
||||
style: boldTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
backgroundColor: mainColor,
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
// extendBody: true,
|
||||
body: ExtendedNavigator(
|
||||
navigatorKey: StackedService.nestedNavigationKey(2),
|
||||
router: UserIndexViewRouter(),
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? mainColor
|
||||
: backgroundColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? mainColor
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
backgroundColor:
|
||||
model.currentIndex == model.bottomNavBarList.indexOf(item)
|
||||
? Colors.white
|
||||
: Colors.grey,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
option: BubbleBarOptions(),
|
||||
hasNotch: true,
|
||||
backgroundColor: mainColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
// fabLocation: StylishBarFabLocation.center,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/ui/views/user_index/user_index_view_model.dart
Normal file
49
lib/ui/views/user_index/user_index_view_model.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
|
||||
class UserIndexViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('UserIndexViewModel');
|
||||
final _navigationService = locator<NavigationService>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'List',
|
||||
'icon': Icons.list_alt_rounded,
|
||||
'header': 'List Perumahan'
|
||||
},
|
||||
{'name': 'Denah', 'icon': Icons.home_outlined, 'header': 'Denah Perumahan'},
|
||||
{'name': 'Profil', 'icon': Icons.person_outline, 'header': 'Profil'},
|
||||
];
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
UserIndexViewRoutes.userListPembangunanView,
|
||||
UserIndexViewRoutes.userHomeView,
|
||||
UserIndexViewRoutes.userProfileView,
|
||||
];
|
||||
|
||||
String header = 'Denah Perumahan';
|
||||
|
||||
Future<void> init() async {
|
||||
setIndex(1);
|
||||
}
|
||||
|
||||
void handleNavigation(int index) {
|
||||
log.d("handleNavigation: $index");
|
||||
log.d("currentIndex: ${_views[index]}");
|
||||
|
||||
if (currentIndex == index) return;
|
||||
|
||||
setIndex(index);
|
||||
header = _bottomNavBarList[index]['header'] as String;
|
||||
_navigationService.navigateTo(
|
||||
_views[index],
|
||||
id: 2,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './user_list_pembangunan_view_model.dart';
|
||||
|
||||
class UserListPembangunanView extends StatelessWidget {
|
||||
const UserListPembangunanView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<UserListPembangunanViewModel>.reactive(
|
||||
viewModelBuilder: () => UserListPembangunanViewModel(),
|
||||
onViewModelReady: (UserListPembangunanViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
UserListPembangunanViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyTopWidget(
|
||||
icon: Icons.list_alt_outlined,
|
||||
title: 'Pembangunan',
|
||||
subtitle: '15 kali',
|
||||
// lastUpdate: '31/02/15 - 10.00 am',
|
||||
),
|
||||
MyTopWidget(
|
||||
icon: Icons.home,
|
||||
title: 'Progress',
|
||||
subtitle: '76 %',
|
||||
// lastUpdate: '31/02/15 - 10.00 am',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
// offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
// create a listview with 20 dummy data on card and scrollable
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 10),
|
||||
itemCount: 20,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
model.log.i('Card $index tapped');
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text('1/02/15 - 10.00 am',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13, color: mainColor)),
|
||||
subtitle: Text('Progress $index'),
|
||||
trailing: Text('Pembangunan $index'),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
import 'package:perumahan_bew/app/core/custom_base_view_model.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
|
||||
class UserListPembangunanViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('UserListPembangunanViewModel');
|
||||
Future<void> init() async {}
|
||||
}
|
||||
155
lib/ui/views/user_index/user_profile/user_profile_view.dart
Normal file
155
lib/ui/views/user_index/user_profile/user_profile_view.dart
Normal file
@ -0,0 +1,155 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:perumahan_bew/app/themes/app_colors.dart';
|
||||
import 'package:perumahan_bew/app/themes/app_text.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import './user_profile_view_model.dart';
|
||||
|
||||
class UserProfileView extends StatelessWidget {
|
||||
const UserProfileView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<UserProfileViewModel>.reactive(
|
||||
viewModelBuilder: () => UserProfileViewModel(),
|
||||
onViewModelReady: (UserProfileViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
UserProfileViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
// create a rounded container
|
||||
Center(
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: 150,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
image: const NetworkImage(
|
||||
'http://kicap-karan.com/assets/img/me.jpg',
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
onError: (exception, stackTrace) {
|
||||
model.log.e('Error: $exception');
|
||||
},
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
'Kicap Karan',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 30, vertical: 10),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (var i = 0; i < 10; i++) const _DetailChild(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
top: 15,
|
||||
right: 65,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
model.log.i('Edit Profile');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.edit,
|
||||
color: mainColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 15,
|
||||
right: 15,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
model.log.i('Logout');
|
||||
model.logout();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.logout,
|
||||
color: mainColor,
|
||||
size: 30,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DetailChild extends StatelessWidget {
|
||||
const _DetailChild({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 25),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.maps_home_work_outlined,
|
||||
color: mainColor,
|
||||
size: 40,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
'Jln 2, Blok C, No 2',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: mainGrey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
import 'package:perumahan_bew/app/core/custom_base_view_model.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
|
||||
class UserProfileViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('UserProfileViewModel');
|
||||
|
||||
Future<void> init() async {}
|
||||
|
||||
logout() {
|
||||
log.i('logout');
|
||||
navigationService.pushNamedAndRemoveUntil('/login-screen-view');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user