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.
HMG_Patient_App/lib/widgets/others/app_scaffold_widget.dart

291 lines
10 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
5 years ago
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
5 years ago
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
6 years ago
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
5 years ago
import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart';
6 years ago
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
6 years ago
import 'package:diplomaticquarterapp/routes.dart';
5 years ago
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
6 years ago
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
5 years ago
import 'package:diplomaticquarterapp/widgets/typewriter/typewiter.dart';
import 'package:diplomaticquarterapp/widgets/weather_slider/weather_slider.dart';
import 'package:flutter/material.dart';
5 years ago
import 'package:flutter_svg/flutter_svg.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
6 years ago
import 'package:provider/provider.dart';
import '../../locator.dart';
6 years ago
import 'floating_button_search.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
import 'network_base_view.dart';
import 'not_auh_page.dart';
5 years ago
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
class AppScaffold extends StatelessWidget {
final String appBarTitle;
final Widget body;
final Widget bottomSheet;
final bool isLoading;
final bool isShowAppBar;
final bool hasAppBarParam;
final BaseViewModel baseViewModel;
6 years ago
final bool isBottomBar;
final Widget floatingActionButton;
final bool isPharmacy;
final String title;
final String description;
final bool isShowDecPage;
final List<String> infoList;
final Color backgroundColor;
final double preferredSize;
final bool showHomeAppBarIcon;
final List<Widget> appBarIcons;
5 years ago
final List<ImagesInfo> imagesInfo;
5 years ago
final bool isHelp;
AuthenticatedUserObject authenticatedUserObject =
5 years ago
locator<AuthenticatedUserObject>();
AppScaffold(
{@required this.body,
5 years ago
this.appBarTitle = '',
this.isLoading = false,
this.isShowAppBar = false,
this.hasAppBarParam,
this.bottomSheet,
this.baseViewModel,
this.floatingActionButton,
this.isPharmacy = false,
this.title,
this.description,
this.isShowDecPage = true,
this.isBottomBar,
this.backgroundColor,
this.preferredSize = 0.0,
this.appBarIcons,
this.infoList,
5 years ago
this.isHelp = false,
this.showHomeAppBarIcon = true,
5 years ago
this.imagesInfo});
@override
Widget build(BuildContext context) {
AppGlobal.context = context;
5 years ago
return Scaffold(
backgroundColor:
5 years ago
backgroundColor ?? Theme.of(context).scaffoldBackgroundColor,
appBar: isShowAppBar
? AppBarWidget(
appBarTitle: appBarTitle,
appBarIcons: appBarIcons,
showHomeAppBarIcon: showHomeAppBarIcon,
5 years ago
isPharmacy: isPharmacy,
isShowDecPage: isShowDecPage,
)
: null,
5 years ago
bottomSheet: bottomSheet,
body: (!Provider.of<ProjectViewModel>(context, listen: false).isLogin &&
5 years ago
isShowDecPage)
? NotAutPage(
5 years ago
title: title ?? appBarTitle,
description: description,
infoList: infoList,
imagesInfo: imagesInfo,
)
5 years ago
: baseViewModel != null
5 years ago
? NetworkBaseView(
5 years ago
child: buildBodyWidget(context),
5 years ago
baseViewModel: baseViewModel,
)
5 years ago
: buildBodyWidget(context),
);
}
buildAppLoaderWidget(bool isLoading) {
return isLoading ? AppLoaderWidget() : Container();
}
5 years ago
buildBodyWidget(context) {
return Stack(
children: <Widget>[body, isHelp == true ? RobotIcon() : Container()]);
}
}
class AppBarWidget extends StatelessWidget with PreferredSizeWidget {
final AuthenticatedUserObject authenticatedUserObject =
5 years ago
locator<AuthenticatedUserObject>();
final String appBarTitle;
final bool showHomeAppBarIcon;
final List<Widget> appBarIcons;
final bool isPharmacy;
final bool isShowDecPage;
5 years ago
AppBarWidget(
{this.appBarTitle,
this.showHomeAppBarIcon,
5 years ago
this.appBarIcons,
this.isPharmacy = true,
this.isShowDecPage = true});
@override
Widget build(BuildContext context) {
return buildAppBar(context);
}
Widget buildAppBar(BuildContext context) {
5 years ago
ProjectViewModel projectViewModel = Provider.of(context);
5 years ago
return AppBar(
elevation: 0,
backgroundColor:
5 years ago
isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color,
textTheme: TextTheme(
headline6: TextStyle(
color: Theme.of(context).textTheme.headline1.color,
fontWeight: FontWeight.bold),
),
5 years ago
title: Text(
authenticatedUserObject.isLogin || !isShowDecPage
? appBarTitle.toUpperCase()
: TranslationBase.of(context).serviceInformationTitle,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).textTheme.headline1.color,
5 years ago
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')),
leading: Builder(
builder: (BuildContext context) {
return ArrowBack();
},
),
centerTitle: true,
actions: <Widget>[
isPharmacy
? IconButton(
5 years ago
icon: Icon(Icons.shopping_cart),
color: Theme.of(context).textTheme.headline1.color,
5 years ago
onPressed: () {
Navigator.of(context).popUntil(ModalRoute.withName('/'));
})
: Container(),
5 years ago
IconButton(
icon: Icon(FontAwesomeIcons.home),
color: Theme.of(context).textTheme.headline1.color,
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
5 years ago
MaterialPageRoute(builder: (context) => LandingPage()),
(Route<dynamic> r) => false);
},
),
if (appBarIcons != null) ...appBarIcons
],
);
}
@override
Size get preferredSize => Size(double.maxFinite, 60);
}
5 years ago
class RobotIcon extends StatefulWidget {
@override
_RobotIcon createState() => _RobotIcon();
}
class _RobotIcon extends State<RobotIcon> {
var event = RobotProvider();
bool isAnimation = false;
@override
void initState() {
event.controller.stream.listen((p) {
if (p['animationEnable'] == 'false') {
if (this.mounted) {
setState(() {
this.isAnimation = false;
});
}
} else if (p['animationEnable'] == 'true') {
if (this.mounted) {
setState(() {
this.isAnimation = true;
});
}
5 years ago
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Positioned(
child: Column(
children: [
isAnimation
? Container(
height: 150,
width: 200,
padding: EdgeInsets.all(5),
margin: EdgeInsets.only(right: 35.0, bottom: 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
boxShadow: [
BoxShadow(color: Colors.black, spreadRadius: 1),
],
),
child: TyperAnimatedTextKit(
text: Provider.of<ProjectViewModel>(context,
listen: false)
.isArabic ==
true
? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي."
: "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file.",
textLength: Provider.of<ProjectViewModel>(context,
listen: false)
.isArabic ==
true
? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي."
.length
: "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file."
.length))
: Container(),
Stack(
children: [
isAnimation
? Positioned(
top: 0,
right: 40,
child: Container(
height: 0,
width: 0,
decoration: ShapeDecoration(
color: Colors.grey,
shape: MessageBorder(reverse: true),
)))
: Container(),
FloatingSearchButton()
],
)
],
),
right: -30,
bottom: 50);
}
// setAnimation() async {
// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) ||
// // var animation =
// // IS_TEXT_COMPLETED == ? true : false;
5 years ago
// }
5 years ago
}