first commit
This commit is contained in:
314
lib/ui/views/nav_bar/log_data/log_data_view.dart
Normal file
314
lib/ui/views/nav_bar/log_data/log_data_view.dart
Normal file
@ -0,0 +1,314 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './log_data_view_model.dart';
|
||||
|
||||
class LogDataView extends StatelessWidget {
|
||||
const LogDataView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<LogDataViewModel>.reactive(
|
||||
viewModelBuilder: () => LogDataViewModel(),
|
||||
onViewModelReady: (LogDataViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
LogDataViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(30),
|
||||
child: model.isBusy
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Center(
|
||||
child: Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
" Log Data Tambak",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Table(
|
||||
border: TableBorder.all(),
|
||||
children: [
|
||||
// Header Row
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Waktu',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Ph 1',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Ph 2',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
'Ketinggian Air',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'TDS 1',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'TDS 2',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Data Rows
|
||||
for (var i = 0; i < model.listData.length; i++)
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.otherFunction.formatDateString2(
|
||||
model.listData[i]['waktu']
|
||||
.toString()),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.listData[i]['ph1'].toString(),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.listData[i]['ph2'].toString(),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
"${model.listData[i]['ultrasonic1']} cm",
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${model.listData[i]['tds1']} ppm",
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${model.listData[i]['tds2']} ppm",
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Divider(thickness: 1),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
" Log Data Saluran Air",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Table(
|
||||
border: TableBorder.all(),
|
||||
children: [
|
||||
// Header Row
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Waktu',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Ph',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
'Ketinggian Air',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Salinitas',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Data Rows
|
||||
for (var i = 0; i < model.listData.length; i++)
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.otherFunction.formatDateString2(
|
||||
model.listData[i]['waktu']
|
||||
.toString()),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
model.listData[i]['ph3'].toString(),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
"${model.listData[i]['ultrasonic1']} cm",
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${model.listData[i]['tds1']} ppm",
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/ui/views/nav_bar/log_data/log_data_view_model.dart
Normal file
26
lib/ui/views/nav_bar/log_data/log_data_view_model.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class LogDataViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LogDataViewModel');
|
||||
List<dynamic> listData = [];
|
||||
|
||||
Future<void> init() async {
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
setBusy(true);
|
||||
try {
|
||||
var response = await httpService.get('');
|
||||
var data = response.data;
|
||||
listData = data;
|
||||
log.i(data);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
193
lib/ui/views/nav_bar/monitoring/monitoring_view.dart
Normal file
193
lib/ui/views/nav_bar/monitoring/monitoring_view.dart
Normal file
@ -0,0 +1,193 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:tambak_app/ui/widgets/my_button.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './monitoring_view_model.dart';
|
||||
|
||||
class MonitoringView extends StatelessWidget {
|
||||
const MonitoringView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<MonitoringViewModel>.reactive(
|
||||
viewModelBuilder: () => MonitoringViewModel(),
|
||||
onViewModelReady: (MonitoringViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
MonitoringViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Monitoring Tambak App",
|
||||
style: boldTextStyle.copyWith(fontSize: 25),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 125,
|
||||
height: 125,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Dalam Tambak",
|
||||
style: boldTextStyle,
|
||||
),
|
||||
_ChildText(
|
||||
title: "Ketinggian Air",
|
||||
text: "${model.socketIoClient.ultrasonic1} cm",
|
||||
),
|
||||
_ChildText(
|
||||
title: "Ph 1",
|
||||
text: model.socketIoClient.ph1,
|
||||
),
|
||||
_ChildText(
|
||||
title: "Ph 2",
|
||||
text: model.socketIoClient.ph2,
|
||||
),
|
||||
_ChildText(
|
||||
title: "TDS 1",
|
||||
text: "${model.socketIoClient.tds1} ppm",
|
||||
),
|
||||
_ChildText(
|
||||
title: "TDS 2",
|
||||
text: "${model.socketIoClient.tds2} ppm",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Saluran Air",
|
||||
style: boldTextStyle,
|
||||
),
|
||||
_ChildText(
|
||||
title: "Ketinggian Air",
|
||||
text: "${model.socketIoClient.ultrasonic2} cm",
|
||||
),
|
||||
_ChildText(
|
||||
title: "Ph",
|
||||
text: model.socketIoClient.ph3,
|
||||
),
|
||||
_ChildText(
|
||||
title: "TDS",
|
||||
text: "${model.socketIoClient.tds3} ppm",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: "Status Gerbang: ",
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: model.socketIoClient.status == "buka"
|
||||
? "Terbuka"
|
||||
: model.socketIoClient.status == "tutup"
|
||||
? "Tertutup"
|
||||
: "Idle",
|
||||
style: boldTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
text: model.isBusy
|
||||
? "Loading..."
|
||||
: model.socketIoClient.status == "buka"
|
||||
? "Tutup Gerbang"
|
||||
: "Buka Gerbang",
|
||||
onPressed: () {
|
||||
if (model.isBusy) {
|
||||
return;
|
||||
}
|
||||
model.changeStatus();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChildText extends StatelessWidget {
|
||||
const _ChildText({
|
||||
required this.title,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "$title: ",
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: text,
|
||||
style: italicTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
27
lib/ui/views/nav_bar/monitoring/monitoring_view_model.dart
Normal file
27
lib/ui/views/nav_bar/monitoring/monitoring_view_model.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class MonitoringViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('MonitoringViewModel');
|
||||
Future<void> init() async {
|
||||
while (true) {
|
||||
notifyListeners();
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
}
|
||||
}
|
||||
|
||||
changeStatus() async {
|
||||
setBusy(true);
|
||||
try {
|
||||
var response = await httpService.postWithFormData("gerbang", FormData());
|
||||
var data = response.data;
|
||||
log.i(data);
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
83
lib/ui/views/nav_bar/nav_bar_view.dart
Normal file
83
lib/ui/views/nav_bar/nav_bar_view.dart
Normal file
@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './nav_bar_view_model.dart';
|
||||
|
||||
class NavBarView extends StatelessWidget {
|
||||
const NavBarView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<NavBarViewModel>.reactive(
|
||||
viewModelBuilder: () => NavBarViewModel(),
|
||||
onViewModelReady: (NavBarViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
NavBarViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: mainColor,
|
||||
title: Text(
|
||||
model.bottomNavBarList[model.currentIndex]['name'],
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
body: ExtendedNavigator(
|
||||
navigatorKey: StackedService.nestedNavigationKey(3),
|
||||
router: NavBarViewRouter(),
|
||||
initialRoute: NavBarViewRoutes.monitoringView,
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: backgroundColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: mainGrey,
|
||||
),
|
||||
),
|
||||
backgroundColor: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: mainGrey,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
hasNotch: true,
|
||||
backgroundColor: mainColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
option: BubbleBarOptions(
|
||||
barStyle: BubbleBarStyle.horizontal,
|
||||
bubbleFillStyle: BubbleFillStyle.fill,
|
||||
opacity: 0.3),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
46
lib/ui/views/nav_bar/nav_bar_view_model.dart
Normal file
46
lib/ui/views/nav_bar/nav_bar_view_model.dart
Normal file
@ -0,0 +1,46 @@
|
||||
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 NavBarViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('NavBarViewModel');
|
||||
final _navigationService = locator<NavigationService>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Real Time',
|
||||
'icon': Icons.home_outlined,
|
||||
},
|
||||
{
|
||||
'name': 'Log Data',
|
||||
'icon': Icons.list_alt_outlined,
|
||||
},
|
||||
];
|
||||
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
NavBarViewRoutes.monitoringView,
|
||||
NavBarViewRoutes.logDataView,
|
||||
];
|
||||
|
||||
Future<void> init() async {}
|
||||
|
||||
void handleNavigation(int index) {
|
||||
log.d("handleNavigation: $index");
|
||||
log.d("currentIndex: $currentIndex");
|
||||
|
||||
if (currentIndex == index) return;
|
||||
|
||||
setIndex(index);
|
||||
// header = _bottomNavBarList[index]['header'] as String;
|
||||
_navigationService.navigateTo(
|
||||
_views[index],
|
||||
id: 3,
|
||||
);
|
||||
}
|
||||
}
|
||||
61
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
61
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './splash_screen_view_model.dart';
|
||||
|
||||
class SplashScreenView extends StatelessWidget {
|
||||
const SplashScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<SplashScreenViewModel>.nonReactive(
|
||||
viewModelBuilder: () => SplashScreenViewModel(),
|
||||
onViewModelReady: (SplashScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
SplashScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
// backgroundColor: mainColor,
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
// show the logo.png
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Monitoring Tambak App",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 20,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
"Made with Flutter and Passion By Kk",
|
||||
textAlign: TextAlign.center,
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
40
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
40
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../services/my_notification.dart';
|
||||
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
Future<void> init() async {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
// navigate to login page
|
||||
// ignore: use_build_context_synchronously
|
||||
MyNotification.initialize(flutterLocalNotificationsPlugin);
|
||||
socketIoClient.init();
|
||||
// socketIoClient.connect();
|
||||
socketIoClient.on('data', (data) {
|
||||
String value = data["value"];
|
||||
List<String> list = value.split(',');
|
||||
String status = data["status"];
|
||||
// log.wtf('value: $value');
|
||||
// log.wtf('status: $status');
|
||||
socketIoClient.ultrasonic1 = list[1];
|
||||
socketIoClient.ultrasonic2 = list[2];
|
||||
socketIoClient.ph1 = list[3];
|
||||
socketIoClient.ph2 = list[4];
|
||||
socketIoClient.ph3 = list[5];
|
||||
socketIoClient.tds1 = list[6];
|
||||
socketIoClient.tds2 = list[6];
|
||||
socketIoClient.tds3 = list[6];
|
||||
socketIoClient.status = status;
|
||||
notifyListeners();
|
||||
});
|
||||
|
||||
navigationService.replaceWith(Routes.navBarView);
|
||||
}
|
||||
}
|
||||
34
lib/ui/widgets/my_button.dart
Normal file
34
lib/ui/widgets/my_button.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyButton extends StatelessWidget {
|
||||
const MyButton({
|
||||
Key? key,
|
||||
required this.text,
|
||||
this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: mainColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: backgroundColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
91
lib/ui/widgets/my_textformfield.dart
Normal file
91
lib/ui/widgets/my_textformfield.dart
Normal file
@ -0,0 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyTextFormField extends StatelessWidget {
|
||||
const MyTextFormField({
|
||||
Key? key,
|
||||
this.labelText,
|
||||
this.hintText,
|
||||
this.obscureText,
|
||||
this.validator,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.focusNode,
|
||||
this.controller,
|
||||
this.maxLines = 1,
|
||||
this.onEditingComplete,
|
||||
this.readOnly = false,
|
||||
this.onTap,
|
||||
this.keyboardType = TextInputType.text,
|
||||
this.initialValue,
|
||||
this.enabled = true,
|
||||
this.maxLength,
|
||||
}) : super(key: key);
|
||||
|
||||
final String? labelText;
|
||||
final String? hintText;
|
||||
final bool? obscureText;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final Widget? suffixIcon;
|
||||
final Widget? prefixIcon;
|
||||
final FocusNode? focusNode;
|
||||
final TextEditingController? controller;
|
||||
final int maxLines;
|
||||
final VoidCallback? onEditingComplete;
|
||||
final bool readOnly;
|
||||
final VoidCallback? onTap;
|
||||
final TextInputType keyboardType;
|
||||
final String? initialValue;
|
||||
final bool enabled;
|
||||
final int? maxLength;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
maxLength: maxLength,
|
||||
enabled: enabled,
|
||||
initialValue: initialValue,
|
||||
onEditingComplete: onEditingComplete,
|
||||
maxLines: maxLines,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
obscureText: obscureText ?? false,
|
||||
readOnly: readOnly,
|
||||
onTap: onTap,
|
||||
keyboardType: keyboardType,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: prefixIcon,
|
||||
suffixIcon: suffixIcon,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
errorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
labelText: labelText,
|
||||
hintText: hintText,
|
||||
labelStyle: const TextStyle(color: fontColor),
|
||||
),
|
||||
validator: validator,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user