You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
5.0 KiB
Dart
142 lines
5.0 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
|
|
import 'package:doctor_app_flutter/core/model/dashboard/dashboard_model.dart';
|
|
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
|
import 'package:doctor_app_flutter/widgets/dashboard/guage_chart.dart';
|
|
import 'package:doctor_app_flutter/widgets/dashboard/out_patient_stack.dart';
|
|
import 'package:doctor_app_flutter/widgets/dashboard/row_count.dart';
|
|
import 'package:doctor_app_flutter/widgets/dashboard/swiper_rounded_pagination.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
import 'package:charts_flutter/flutter.dart' as charts;
|
|
|
|
import 'dashboard_referral_patient.dart';
|
|
|
|
class DashboardSwipeWidget extends StatefulWidget {
|
|
final List<DashboardModel> dashboardItemList;
|
|
final DashboardViewModel model;
|
|
final Function(int) sliderChange;
|
|
|
|
DashboardSwipeWidget(this.dashboardItemList, this.model, this.sliderChange);
|
|
|
|
@override
|
|
_DashboardSwipeWidgetState createState() => _DashboardSwipeWidgetState();
|
|
}
|
|
|
|
class _DashboardSwipeWidgetState extends State<DashboardSwipeWidget> {
|
|
int sliderActiveIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
double height = SizeConfig.heightMultiplier *
|
|
(SizeConfig.isHeightVeryShort
|
|
? 40
|
|
: SizeConfig.isHeightLarge
|
|
? 33
|
|
: 31);
|
|
|
|
return Container(
|
|
height: height,
|
|
// height: 230,
|
|
child: Swiper(
|
|
onIndexChanged: (index) {
|
|
if (mounted) {
|
|
setState(() {
|
|
sliderActiveIndex = index;
|
|
widget.sliderChange(index);
|
|
});
|
|
}
|
|
},
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return getSwipeWidget(widget.dashboardItemList, index, height);
|
|
},
|
|
itemCount: 3,
|
|
// itemHeight: 300,
|
|
pagination: new SwiperCustomPagination(
|
|
builder: (BuildContext context, SwiperPluginConfig config) {
|
|
return new Stack(
|
|
alignment: Alignment.bottomCenter,
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
child: Center(
|
|
child: InkWell(
|
|
onTap: () {},
|
|
child: Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
config.activeIndex == 0
|
|
? SwiperRoundedPagination(true)
|
|
: SwiperRoundedPagination(false),
|
|
config.activeIndex == 1
|
|
? SwiperRoundedPagination(true)
|
|
: SwiperRoundedPagination(false),
|
|
config.activeIndex == 2
|
|
? SwiperRoundedPagination(true)
|
|
: SwiperRoundedPagination(false),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}),
|
|
viewportFraction: 0.9,
|
|
// scale: 0.9,
|
|
// control: new SwiperControl(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget getSwipeWidget(
|
|
List<DashboardModel> dashboardItemList, int index, double height) {
|
|
if (index == 1) return GetOutPatientStack(dashboardItemList[1]);
|
|
if (index == 0) return GetOutPatientStack(dashboardItemList[0]);
|
|
if (index == 2)
|
|
return DashboardReferralPatient(
|
|
dashboardItemList: widget.dashboardItemList,
|
|
height: height,
|
|
model: widget.model,
|
|
);
|
|
|
|
return Container();
|
|
}
|
|
|
|
static List<charts.Series<GaugeSegment, String>> _createReferralData(
|
|
List<DashboardModel> dashboardItemList) {
|
|
final data = [
|
|
new GaugeSegment(
|
|
dashboardItemList[2].summaryoptions[0].kPIParameter,
|
|
getValue(dashboardItemList[1].summaryoptions[0].value),
|
|
charts.MaterialPalette.black),
|
|
new GaugeSegment(
|
|
dashboardItemList[2].summaryoptions[1].kPIParameter,
|
|
getValue(dashboardItemList[1].summaryoptions[1].value),
|
|
charts.MaterialPalette.gray.shadeDefault),
|
|
new GaugeSegment(
|
|
dashboardItemList[2].summaryoptions[2].kPIParameter,
|
|
getValue(dashboardItemList[1].summaryoptions[2].value),
|
|
charts.MaterialPalette.red.shadeDefault),
|
|
];
|
|
|
|
return [
|
|
new charts.Series<GaugeSegment, String>(
|
|
id: 'Segments',
|
|
domainFn: (GaugeSegment segment, _) => segment.segment,
|
|
measureFn: (GaugeSegment segment, _) => segment.size,
|
|
data: data,
|
|
colorFn: (GaugeSegment segment, _) => segment.color,
|
|
)
|
|
];
|
|
}
|
|
|
|
static int getValue(value) {
|
|
return value == 0 ? 1 : value;
|
|
}
|
|
}
|