update gitignore
This commit is contained in:
263
lib/ui/views/log_data/log_data_view.dart
Normal file
263
lib/ui/views/log_data/log_data_view.dart
Normal file
@ -0,0 +1,263 @@
|
||||
import 'package:electric_app/app/themes/app_text.dart';
|
||||
import 'package:electric_app/ui/widgets/my_textformfield.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../model/electric_model.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(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: mainColor,
|
||||
title: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 30,
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
'Log Data',
|
||||
style: TextStyle(
|
||||
color: backgroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
controller: model.dateController,
|
||||
hintText: "Pencarian Tanggal",
|
||||
suffixIcon: const Icon(
|
||||
Icons.calendar_month,
|
||||
color: mainColor,
|
||||
),
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
model.log.wtf("Pencarian Tanggal");
|
||||
await model.changeDate(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
_ContainerData(
|
||||
name: "Fase R",
|
||||
data: model.listFaseR,
|
||||
color: Colors.red,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
_ContainerData(
|
||||
name: "Fase S",
|
||||
data: model.listFaseS,
|
||||
color: Colors.yellow,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
_ContainerData(
|
||||
name: "Fase T",
|
||||
data: model.listFaseT,
|
||||
color: Colors.green,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ContainerData extends StatelessWidget {
|
||||
const _ContainerData({
|
||||
required this.name,
|
||||
required this.data,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final List<ElectricModel> data;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 3),
|
||||
)
|
||||
]),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Data Log$name",
|
||||
style: boldTextStyle.copyWith(
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
if (data.isNotEmpty)
|
||||
Table(
|
||||
border: TableBorder.all(),
|
||||
children: [
|
||||
const TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Waktu',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Voltage',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Current',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Power',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Energy',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'PF',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
...data.map(
|
||||
(data) {
|
||||
// add 1 day to the date
|
||||
var theDate = DateTime.parse(data.date!);
|
||||
theDate = theDate.add(const Duration(days: 1));
|
||||
// get the date in the format dd-mm-yyyy
|
||||
String formattedDate =
|
||||
theDate.toIso8601String().split('T')[0];
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"$formattedDate\n${data.time!}",
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.voltage! == ' NAN'
|
||||
? '-'
|
||||
: '${data.voltage!} V',
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.current! == ' NAN'
|
||||
? '-'
|
||||
: '${data.current!} A',
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.power! == ' NAN' ? '-' : '${data.power!} W',
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.energy! == ' NAN'
|
||||
? '-'
|
||||
: '${data.energy!} KWh',
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
TableCell(
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.pf! == ' NAN' ? '-' : '${data.pf!} %',
|
||||
style: italicTextStyle.copyWith(fontSize: 12),
|
||||
)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (data.isEmpty)
|
||||
const Center(
|
||||
child: Text(
|
||||
"Tidak ada data",
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
65
lib/ui/views/log_data/log_data_view_model.dart
Normal file
65
lib/ui/views/log_data/log_data_view_model.dart
Normal file
@ -0,0 +1,65 @@
|
||||
import 'package:date_picker_plus/date_picker_plus.dart';
|
||||
import 'package:electric_app/model/electric_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class LogDataViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LogDataViewModel');
|
||||
List<ElectricModel> listFaseR = [];
|
||||
List<ElectricModel> listFaseS = [];
|
||||
List<ElectricModel> listFaseT = [];
|
||||
TextEditingController dateController = TextEditingController();
|
||||
DateTime selectedDate = DateTime.now().subtract(const Duration(days: 1));
|
||||
|
||||
Future<void> init() async {
|
||||
await getData(null);
|
||||
}
|
||||
|
||||
getData(String? param) async {
|
||||
try {
|
||||
var response = await httpService.get('?date=${param ?? ''}');
|
||||
var data = response.data;
|
||||
var faseR = data['result_fase_r'];
|
||||
var faseS = data['result_fase_s'];
|
||||
var faseT = data['result_fase_t'];
|
||||
|
||||
listFaseR.clear();
|
||||
listFaseS.clear();
|
||||
listFaseT.clear();
|
||||
|
||||
listFaseR = faseR
|
||||
.map<ElectricModel>((json) => ElectricModel.fromJson(json))
|
||||
.toList();
|
||||
listFaseS = faseS
|
||||
.map<ElectricModel>((json) => ElectricModel.fromJson(json))
|
||||
.toList();
|
||||
listFaseT = faseT
|
||||
.map<ElectricModel>((json) => ElectricModel.fromJson(json))
|
||||
.toList();
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
changeDate(BuildContext context) async {
|
||||
var date = await showDatePickerDialog(
|
||||
context: context,
|
||||
minDate: DateTime(2024, 1, 1),
|
||||
// maxdate = yesterday
|
||||
maxDate: DateTime.now(),
|
||||
);
|
||||
|
||||
// only get the date in the format yyyy-mm-dd
|
||||
if (date != null) {
|
||||
String formattedDate = date.toIso8601String().split('T')[0];
|
||||
dateController.text = formattedDate;
|
||||
log.wtf(formattedDate);
|
||||
getData(formattedDate);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
194
lib/ui/views/monitoring/monitoring_view.dart
Normal file
194
lib/ui/views/monitoring/monitoring_view.dart
Normal file
@ -0,0 +1,194 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import '../../../model/electric_model.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 Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: mainColor,
|
||||
title: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 30,
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
'Electric Monitoring',
|
||||
style: TextStyle(
|
||||
color: backgroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
MyContainer(
|
||||
electricModel: model.faseR,
|
||||
color: Colors.red,
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyContainer(
|
||||
electricModel: model.faseS,
|
||||
color: Colors.yellow,
|
||||
fontColor: Colors.black,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyContainer(
|
||||
electricModel: model.faseT,
|
||||
color: Colors.green,
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyContainer extends StatelessWidget {
|
||||
const MyContainer({
|
||||
super.key,
|
||||
required this.electricModel,
|
||||
required this.color,
|
||||
required this.fontColor,
|
||||
});
|
||||
|
||||
final ElectricModel? electricModel;
|
||||
final Color color;
|
||||
final Color fontColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: electricModel == null
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: fontColor,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
electricModel?.fase ?? '',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: fontColor,
|
||||
fontSize: 15,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
MyText(
|
||||
title: 'Voltage : ',
|
||||
text: electricModel?.voltage != ' NAN'
|
||||
? "${electricModel?.voltage} V"
|
||||
: "Error getting voltage",
|
||||
fontColor: fontColor,
|
||||
),
|
||||
MyText(
|
||||
title: 'Current : ',
|
||||
text: electricModel?.current != ' NAN'
|
||||
? "${electricModel?.current} A"
|
||||
: "Error getting current",
|
||||
fontColor: fontColor,
|
||||
),
|
||||
MyText(
|
||||
title: 'Power : ',
|
||||
text: electricModel?.power != ' NAN'
|
||||
? "${electricModel?.power} W"
|
||||
: "Error getting power",
|
||||
fontColor: fontColor,
|
||||
),
|
||||
MyText(
|
||||
title: 'Energy : ',
|
||||
text: electricModel?.energy != ' NAN'
|
||||
? "${electricModel?.energy} kWh"
|
||||
: "Error getting energy",
|
||||
fontColor: fontColor,
|
||||
),
|
||||
MyText(
|
||||
title: 'Power Factor : ',
|
||||
text: electricModel?.pf != ' NAN'
|
||||
? "${electricModel?.pf} %"
|
||||
: "Error getting power factor",
|
||||
fontColor: fontColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyText extends StatelessWidget {
|
||||
const MyText({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.text,
|
||||
required this.fontColor,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String text;
|
||||
final Color fontColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: title,
|
||||
style: boldTextStyle.copyWith(
|
||||
color: fontColor,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: text,
|
||||
style: italicTextStyle.copyWith(
|
||||
color: fontColor,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
33
lib/ui/views/monitoring/monitoring_view_model.dart
Normal file
33
lib/ui/views/monitoring/monitoring_view_model.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/electric_model.dart';
|
||||
|
||||
class MonitoringViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('MonitoringViewModel');
|
||||
|
||||
ElectricModel? faseR;
|
||||
ElectricModel? faseS;
|
||||
ElectricModel? faseT;
|
||||
|
||||
Future<void> init() async {
|
||||
socketIoClient.on('datanya', (data) {
|
||||
// log.i('data : $data');
|
||||
ElectricModel electricModel = ElectricModel.fromJson(data);
|
||||
// log.i('electricModel : ${electricModel.fase}');
|
||||
// create a switch case
|
||||
switch (electricModel.fase) {
|
||||
case 'Fase R':
|
||||
faseR = electricModel;
|
||||
break;
|
||||
case 'Fase S':
|
||||
faseS = electricModel;
|
||||
break;
|
||||
case 'Fase T':
|
||||
faseT = electricModel;
|
||||
break;
|
||||
}
|
||||
// log.i('faseR : ${faseR?.fase}');
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
}
|
76
lib/ui/views/nav_bar/nav_bar_view.dart
Normal file
76
lib/ui/views/nav_bar/nav_bar_view.dart
Normal file
@ -0,0 +1,76 @@
|
||||
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(
|
||||
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:electric_app/app/app.router.dart';
|
||||
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';
|
||||
|
||||
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(
|
||||
"Electric Monitoring",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 20,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
"Made with Flutter and Passion By Kk",
|
||||
textAlign: TextAlign.center,
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
18
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
18
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
Future<void> init() async {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
// navigate to login page
|
||||
// ignore: use_build_context_synchronously
|
||||
socketIoClient.init();
|
||||
// socketIoClient.connect();
|
||||
// socketIoClient.on('datanya', (data) {
|
||||
// log.i('data : $data');
|
||||
// });
|
||||
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