diff --git a/images/hrhw3a.jpg b/images/dark-theme-background.jpg similarity index 100% rename from images/hrhw3a.jpg rename to images/dark-theme-background.jpg diff --git a/lib/main.dart b/lib/main.dart index 179e09e..926f70e 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -116,11 +116,13 @@ class _AppState extends State { @override void didChangeDependencies() { getIt().getLocale().then((value) { - getIt().getTheme().then((value1) { - setState(() { - _locale = value; - themeData = value1 == 'dark' ? darkTheme : lightTheme; - }); + setState(() { + _locale = value; + }); + }); + getIt().getTheme().then((value1) { + setState(() { + themeData = value1 == 'dark' ? darkTheme : lightTheme; }); }); super.didChangeDependencies(); diff --git a/lib/src/database/crud/user/user_crud.dart b/lib/src/database/crud/user/user_crud.dart index f69e804..aea510a 100755 --- a/lib/src/database/crud/user/user_crud.dart +++ b/lib/src/database/crud/user/user_crud.dart @@ -31,7 +31,9 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { Future getSingleUser(int id) { return (select(db.users)..where((u) => u.id.equals(id))).getSingle(); } - + Stream watchSingleUser(int id) { + return (select(db.users)..where((u) => u.id.equals(id))).watchSingle(); + } Future getSingleByName(int id) { return (select(db.users)..where((u) => u.id.equals(id))).getSingle(); } @@ -47,7 +49,10 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { (u) => u.userName.equals(userName) & u.tenantId.equals(tenantId))) .getSingle(); } + Future updateSingleUser(User user) { + return (update(db.users).replace(user)); + } Future updateUser(UsersCompanion u, int id) { return (update(db.users)..where((t) => t.id.equals(id))).write( UsersCompanion( diff --git a/lib/src/database/moor_database.g.dart b/lib/src/database/moor_database.g.dart index 47a9781..f5a1d89 100755 --- a/lib/src/database/moor_database.g.dart +++ b/lib/src/database/moor_database.g.dart @@ -22,6 +22,7 @@ class User extends DataClass implements Insertable { final DateTime creationTime; final DateTime lastLoginTime; final String currency; + final String themeData; User( {this.tenantId, @required this.id, @@ -36,7 +37,8 @@ class User extends DataClass implements Insertable { this.firebaseToken, this.creationTime, this.lastLoginTime, - this.currency}); + this.currency, + this.themeData}); factory User.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; @@ -71,6 +73,8 @@ class User extends DataClass implements Insertable { .mapFromDatabaseResponse(data['${effectivePrefix}last_login_time']), currency: stringType .mapFromDatabaseResponse(data['${effectivePrefix}currency']), + themeData: stringType + .mapFromDatabaseResponse(data['${effectivePrefix}theme_data']), ); } @override @@ -118,6 +122,9 @@ class User extends DataClass implements Insertable { if (!nullToAbsent || currency != null) { map['currency'] = Variable(currency); } + if (!nullToAbsent || themeData != null) { + map['theme_data'] = Variable(themeData); + } return map; } @@ -161,6 +168,9 @@ class User extends DataClass implements Insertable { currency: currency == null && nullToAbsent ? const Value.absent() : Value(currency), + themeData: themeData == null && nullToAbsent + ? const Value.absent() + : Value(themeData), ); } @@ -182,6 +192,7 @@ class User extends DataClass implements Insertable { creationTime: serializer.fromJson(json['creationTime']), lastLoginTime: serializer.fromJson(json['lastLoginTime']), currency: serializer.fromJson(json['currency']), + themeData: serializer.fromJson(json['themeData']), ); } @override @@ -202,6 +213,7 @@ class User extends DataClass implements Insertable { 'creationTime': serializer.toJson(creationTime), 'lastLoginTime': serializer.toJson(lastLoginTime), 'currency': serializer.toJson(currency), + 'themeData': serializer.toJson(themeData), }; } @@ -219,7 +231,8 @@ class User extends DataClass implements Insertable { String firebaseToken, DateTime creationTime, DateTime lastLoginTime, - String currency}) => + String currency, + String themeData}) => User( tenantId: tenantId ?? this.tenantId, id: id ?? this.id, @@ -235,6 +248,7 @@ class User extends DataClass implements Insertable { creationTime: creationTime ?? this.creationTime, lastLoginTime: lastLoginTime ?? this.lastLoginTime, currency: currency ?? this.currency, + themeData: themeData ?? this.themeData, ); @override String toString() { @@ -252,7 +266,8 @@ class User extends DataClass implements Insertable { ..write('firebaseToken: $firebaseToken, ') ..write('creationTime: $creationTime, ') ..write('lastLoginTime: $lastLoginTime, ') - ..write('currency: $currency') + ..write('currency: $currency, ') + ..write('themeData: $themeData') ..write(')')) .toString(); } @@ -284,8 +299,10 @@ class User extends DataClass implements Insertable { creationTime.hashCode, $mrjc( lastLoginTime.hashCode, - currency - .hashCode)))))))))))))); + $mrjc( + currency.hashCode, + themeData + .hashCode))))))))))))))); @override bool operator ==(dynamic other) => identical(this, other) || @@ -303,7 +320,8 @@ class User extends DataClass implements Insertable { other.firebaseToken == this.firebaseToken && other.creationTime == this.creationTime && other.lastLoginTime == this.lastLoginTime && - other.currency == this.currency); + other.currency == this.currency && + other.themeData == this.themeData); } class UsersCompanion extends UpdateCompanion { @@ -321,6 +339,7 @@ class UsersCompanion extends UpdateCompanion { final Value creationTime; final Value lastLoginTime; final Value currency; + final Value themeData; const UsersCompanion({ this.tenantId = const Value.absent(), this.id = const Value.absent(), @@ -336,6 +355,7 @@ class UsersCompanion extends UpdateCompanion { this.creationTime = const Value.absent(), this.lastLoginTime = const Value.absent(), this.currency = const Value.absent(), + this.themeData = const Value.absent(), }); UsersCompanion.insert({ this.tenantId = const Value.absent(), @@ -352,6 +372,7 @@ class UsersCompanion extends UpdateCompanion { this.creationTime = const Value.absent(), this.lastLoginTime = const Value.absent(), this.currency = const Value.absent(), + this.themeData = const Value.absent(), }) : userName = Value(userName), name = Value(name), surname = Value(surname), @@ -372,6 +393,7 @@ class UsersCompanion extends UpdateCompanion { Expression creationTime, Expression lastLoginTime, Expression currency, + Expression themeData, }) { return RawValuesInsertable({ if (tenantId != null) 'tenant_id': tenantId, @@ -389,6 +411,7 @@ class UsersCompanion extends UpdateCompanion { if (creationTime != null) 'creation_time': creationTime, if (lastLoginTime != null) 'last_login_time': lastLoginTime, if (currency != null) 'currency': currency, + if (themeData != null) 'theme_data': themeData, }); } @@ -406,7 +429,8 @@ class UsersCompanion extends UpdateCompanion { Value firebaseToken, Value creationTime, Value lastLoginTime, - Value currency}) { + Value currency, + Value themeData}) { return UsersCompanion( tenantId: tenantId ?? this.tenantId, id: id ?? this.id, @@ -422,6 +446,7 @@ class UsersCompanion extends UpdateCompanion { creationTime: creationTime ?? this.creationTime, lastLoginTime: lastLoginTime ?? this.lastLoginTime, currency: currency ?? this.currency, + themeData: themeData ?? this.themeData, ); } @@ -470,6 +495,9 @@ class UsersCompanion extends UpdateCompanion { if (currency.present) { map['currency'] = Variable(currency.value); } + if (themeData.present) { + map['theme_data'] = Variable(themeData.value); + } return map; } @@ -489,7 +517,8 @@ class UsersCompanion extends UpdateCompanion { ..write('firebaseToken: $firebaseToken, ') ..write('creationTime: $creationTime, ') ..write('lastLoginTime: $lastLoginTime, ') - ..write('currency: $currency') + ..write('currency: $currency, ') + ..write('themeData: $themeData') ..write(')')) .toString(); } @@ -656,6 +685,18 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> { ); } + final VerificationMeta _themeDataMeta = const VerificationMeta('themeData'); + GeneratedTextColumn _themeData; + @override + GeneratedTextColumn get themeData => _themeData ??= _constructThemeData(); + GeneratedTextColumn _constructThemeData() { + return GeneratedTextColumn( + 'theme_data', + $tableName, + true, + ); + } + @override List get $columns => [ tenantId, @@ -671,7 +712,8 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> { firebaseToken, creationTime, lastLoginTime, - currency + currency, + themeData ]; @override $UsersTable get asDslTable => this; @@ -761,6 +803,10 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> { context.handle(_currencyMeta, currency.isAcceptableOrUnknown(data['currency'], _currencyMeta)); } + if (data.containsKey('theme_data')) { + context.handle(_themeDataMeta, + themeData.isAcceptableOrUnknown(data['theme_data'], _themeDataMeta)); + } return context; } diff --git a/lib/src/models/user_model.dart b/lib/src/models/user_model.dart index fb58930..48fe2da 100755 --- a/lib/src/models/user_model.dart +++ b/lib/src/models/user_model.dart @@ -35,6 +35,7 @@ class Users extends Table implements MustHaveTenant { DateTimeColumn get lastLoginTime => dateTime().nullable()(); IntColumn get tenantId => integer().nullable()(); TextColumn get currency => text().nullable()(); + TextColumn get themeData => text().nullable()(); @override Set get primaryKey => {id}; diff --git a/lib/src/resources/repositories/user_repository.dart b/lib/src/resources/repositories/user_repository.dart index bcde331..74c6323 100755 --- a/lib/src/resources/repositories/user_repository.dart +++ b/lib/src/resources/repositories/user_repository.dart @@ -105,8 +105,8 @@ class UserRepository { String tenantState = await _prefs.get('tenantState'); String userName = await _prefs.get('userName'); String tenantName = await _prefs.get('tenantName'); - int tenantId = await _prefs.get('tenantId'); - int userId = await _prefs.get('userId'); + String tenantId = await _prefs.get('tenantId'); + String userId = await _prefs.get('userId'); Map map = { "deviceId": "$deviceId", diff --git a/lib/src/resources/shared/utils/theme.dart b/lib/src/resources/shared/utils/theme.dart index e413f8a..db388d4 100644 --- a/lib/src/resources/shared/utils/theme.dart +++ b/lib/src/resources/shared/utils/theme.dart @@ -5,7 +5,7 @@ final lightTheme = ThemeData( primaryColor: Colors.blue, cardColor: Colors.white, brightness: Brightness.light, - //backgroundColor: Color(0xffe7ebee), + backgroundColor: Color(0xffe7ebee), scaffoldBackgroundColor:Color(0xffe7ebee) , accentColor: Colors.black87, accentIconTheme: IconThemeData(color: Colors.white), diff --git a/lib/src/resources/shared/widgets/custom_drawer.dart b/lib/src/resources/shared/widgets/custom_drawer.dart index 33b28c0..94b580b 100755 --- a/lib/src/resources/shared/widgets/custom_drawer.dart +++ b/lib/src/resources/shared/widgets/custom_drawer.dart @@ -1,7 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:j3enterprise/main.dart'; +import 'package:j3enterprise/src/database/crud/user/user_crud.dart'; +import 'package:j3enterprise/src/database/moor_database.dart'; +import 'package:j3enterprise/src/resources/repositories/user_repository.dart'; import 'package:j3enterprise/src/resources/shared/icons/custom_icons.dart'; import 'package:j3enterprise/src/resources/shared/lang/appLocalization.dart'; +import 'package:j3enterprise/src/resources/shared/preferences/user_share_data.dart'; import 'package:j3enterprise/src/ui/about/about.dart'; import 'package:j3enterprise/src/ui/app_logger/applogger_page.dart'; import 'package:j3enterprise/src/ui/authentication/authentication.dart'; @@ -9,37 +14,83 @@ import 'package:j3enterprise/src/ui/background_jobs/background_jobs.dart'; import 'package:j3enterprise/src/ui/communication/setup_communication_page.dart'; import 'package:j3enterprise/src/ui/profile/profile_page.dart'; -class CustomDrawer extends StatelessWidget { +class CustomDrawer extends StatefulWidget { + var db; + UserDao userDao; + CustomDrawer() { + db = AppDatabase(); + userDao = UserDao(db); + } + + @override + _CustomDrawerState createState() => _CustomDrawerState(); +} + +class _CustomDrawerState extends State { + Future getProfileData() async { + + final data = await UserSharedData().getUserSharedPref(); + final profileData =await + widget.userDao.getSingleUser(int.parse(data['userId'])); + + return profileData; + } + + User user; + int userId; + + @override + void didChangeDependencies() async{ + await getIt().getUserSharedPref().then((value) { + + if(value==null) { + print(value); + + }else{ + setState(() { + userId = int.parse(value['userId']); + }); + } + + }); + super.didChangeDependencies(); + } + @override Widget build(BuildContext context) { return Drawer( - + child: Container( color: Theme.of(context).cardColor, child: ListView( children: [ - UserAccountsDrawerHeader( + FutureBuilder( + future: getProfileData(), + builder: (context,snapshot){ + user = snapshot.data; + return snapshot.hasData?UserAccountsDrawerHeader( - accountName: Text("Irfan Bashir"), - accountEmail: Text("malikfani112@gmail.com"), - currentAccountPicture: CircleAvatar( + accountName: Text( user.fullName), + accountEmail: Text( user.emailAddress), + currentAccountPicture: CircleAvatar( // backgroundColor: Theme.of(context).backgroundColor, - child: Icon(Icons.person)), - otherAccountsPictures: [ - CircleAvatar( - backgroundColor: Theme.of(context).backgroundColor, - child: Text( - "B", - ), - ), - CircleAvatar( - backgroundColor: Theme.of(context).backgroundColor, - child: Text( - "C", - ), - ), - ], - ), + child: Icon(Icons.person)), + otherAccountsPictures: [ +// CircleAvatar( +// backgroundColor: Theme.of(context).backgroundColor, +// child: Text( +// "B", +// ), +// ), +// CircleAvatar( +// backgroundColor: Theme.of(context).backgroundColor, +// child: Text( +// "C", +// ), +// ), + ], + ):UserAccountsDrawerHeader(accountName: null, accountEmail: null); + }), // DrawerHeader( // child: Align( // alignment: Alignment.bottomLeft, @@ -140,7 +191,7 @@ class CustomDrawer extends StatelessWidget { ), ), ), - Align( + userId!=null? Align( alignment: Alignment.bottomLeft, child: GestureDetector( onTap: () { @@ -162,7 +213,7 @@ class CustomDrawer extends StatelessWidget { ), ), ), - ), + ):Container(), Align( alignment: Alignment.bottomLeft, child: GestureDetector( diff --git a/lib/src/ui/about/about.dart b/lib/src/ui/about/about.dart index 534785c..b7f9c87 100755 --- a/lib/src/ui/about/about.dart +++ b/lib/src/ui/about/about.dart @@ -21,6 +21,7 @@ import 'package:device_info/device_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:j3enterprise/src/resources/shared/lang/appLocalization.dart'; +import 'package:j3enterprise/src/resources/shared/widgets/no_data_found.dart'; import 'dart:io' show Platform; import 'package:j3enterprise/src/resources/shared/widgets/snak_bar.dart'; @@ -85,6 +86,9 @@ class _AboutState extends State { ), ); } + if(Platform.isWindows||Platform.isMacOS){ + return BuildOnNoData(message: 'No information Found',); + } return Center(child: CircularProgressIndicator()); })); diff --git a/lib/src/ui/app_logger/applogger_form.dart b/lib/src/ui/app_logger/applogger_form.dart index e4087d9..c31c117 100644 --- a/lib/src/ui/app_logger/applogger_form.dart +++ b/lib/src/ui/app_logger/applogger_form.dart @@ -58,7 +58,7 @@ class _AppLoggerForm extends State { children: [ Container( height: 55, - color: Theme.of(context).backgroundColor, + color: Theme.of(context).scaffoldBackgroundColor, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), @@ -85,7 +85,7 @@ class _AppLoggerForm extends State { return Container( color: (index % 2 == 0) ? Theme.of(context).backgroundColor - : Theme.of(context).cardColor.withOpacity(0.1), + : Theme.of(context).cardColor.withOpacity(0.8), child: Row( children: [ Expanded( diff --git a/lib/src/ui/background_jobs/backgroundjobs_page.dart b/lib/src/ui/background_jobs/backgroundjobs_page.dart index ae98efe..83c27a0 100644 --- a/lib/src/ui/background_jobs/backgroundjobs_page.dart +++ b/lib/src/ui/background_jobs/backgroundjobs_page.dart @@ -94,287 +94,278 @@ class _BackgroundJobs extends State { Widget _buildForm(BackgroundJobsBloc bloc) { return Form( key: formKey, - child: SingleChildScrollView( - child: Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, boxShadow: kElevationToShadow[4]), - ), - // Container( - // decoration: BoxDecoration( - // color: Colors.grey, - // ), - // child: Padding( - // padding: - // const EdgeInsets.symmetric(horizontal: 16.0, vertical: 14), - // child: Text( - // AppLocalization.of(context) - // .translate('schedule_jobs_sub_title_backgroundjob') ?? - // 'Schedule Jobs', - // style: TextStyle(color: Colors.white, fontSize: 24), - // ), - // ), - // ), - SizedBox( - height: 10, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + Container( + decoration: BoxDecoration( + color: Colors.white, boxShadow: kElevationToShadow[4]), + ), + // Container( + // decoration: BoxDecoration( + // color: Colors.grey, + // ), + // child: Padding( + // padding: + // const EdgeInsets.symmetric(horizontal: 16.0, vertical: 14), + // child: Text( + // AppLocalization.of(context) + // .translate('schedule_jobs_sub_title_backgroundjob') ?? + // 'Schedule Jobs', + // style: TextStyle(color: Colors.white, fontSize: 24), + // ), + // ), + // ), + SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( children: [ - Column( - children: [ - time != null - ? Container( - margin: EdgeInsets.only(bottom: 10), - child: Text( - time.hour >= 12 - ? "${time.hour - 12} : ${time.minute} PM" - : "${time.hour} : ${time.minute} AM", - style: TextStyle( - fontSize: 22, - color: Colors.grey.shade700, - fontWeight: FontWeight.w700), - ), - ) - : Container( - height: 0, - width: 0, - ), - Container( - decoration: BoxDecoration( - color: Theme.of(context).cardColor, - borderRadius: BorderRadius.all(Radius.circular(10)), - ), - child: IconButton( - icon: Icon(Icons.alarm), - onPressed: () async { - var newTime = await showTimePicker( - context: context, initialTime: TimeOfDay.now()); - setState(() { - time = newTime; - }); - }, + time != null + ? Container( + margin: EdgeInsets.only(bottom: 10), + child: Text( + time.hour >= 12 + ? "${time.hour - 12} : ${time.minute} PM" + : "${time.hour} : ${time.minute} AM", + style: TextStyle( + fontSize: 22, + + fontWeight: FontWeight.w700), + ), + ) + : Container( + height: 0, + width: 0, ), - ), - ], + Container( + decoration: BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.all(Radius.circular(10)), + ), + child: IconButton( + icon: Icon(Icons.alarm), + onPressed: () async { + var newTime = await showTimePicker( + + context: context, initialTime: TimeOfDay.now()); + setState(() { + time = newTime; + }); + }, + ), ), - Column( - children: [ - date != null - ? Container( - margin: EdgeInsets.only(bottom: 10), - child: Text( - "${date.day}/${date.month}/${date.year}", - style: TextStyle( - fontSize: 22, + ], + ), + Column( + children: [ + date != null + ? Container( + margin: EdgeInsets.only(bottom: 10), + child: Text( + "${date.day}/${date.month}/${date.year}", + style: TextStyle( + fontSize: 22, - fontWeight: FontWeight.w700), - ), - ) - : Container( - height: 0, - width: 0, - ), - Container( - decoration: BoxDecoration( - color: Theme.of(context).cardColor, - borderRadius: BorderRadius.all(Radius.circular(10)), + fontWeight: FontWeight.w700), + ), + ) + : Container( + height: 0, + width: 0, + ), + Container( + decoration: BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.all(Radius.circular(10)), ), - child: IconButton( - icon: Icon(Icons.date_range), - onPressed: () async { - var result = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(1970), - lastDate: DateTime(2100)); + child: IconButton( + icon: Icon(Icons.date_range), + onPressed: () async { + var result = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1970), + lastDate: DateTime(2100)); - setState(() { - date = result; - }); - }, - ), - ), - ], + setState(() { + date = result; + }); + }, + ), ), ], ), - ), - Padding( - padding: const EdgeInsets.all(0.00), - child: DropdownFormFieldNormalReuse( - _onSetJobNameSelection, - hintText: AppLocalization.of(context).translate('set_job_name') ?? - 'Selected Job', - selectedValue: setjobname, - listData: [ - 'Device Setting', - 'Log Shipping', - 'Validate Enrollment', - 'Configuration', - 'Mobile Desktop' - ], - ), - ), - Padding( - padding: const EdgeInsets.all(0.00), - child: DropdownFormFieldNormalReuse( - _onUpdateeFrequencySelection, - hintText: AppLocalization.of(context) - .translate('sync_frequency_label_communication') ?? - 'Sync Frequency', - selectedValue: syncfrequencySelectedItem, - listData: [ - 'Every Minute', - 'Every 5 Minutes', - 'Every 20 Minutes', - 'Every Day', - 'Every Month', - 'Every Year' - ], - ), - ), - SizedBox( - height: 5, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - child: Container( - child: FlatButton( - onPressed: () { - _onBackGroundJobStartButtonPress(); - }, - child: Text( - AppLocalization.of(context) - .translate('start_button_backgroundjob'), - style: TextStyle( - color: Colors.blue, - fontSize: 18, - fontWeight: FontWeight.w600), - ), - )), - ), - Container( - decoration: BoxDecoration(), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(0.00), + child: DropdownFormFieldNormalReuse( + _onSetJobNameSelection, + hintText: AppLocalization.of(context).translate('set_job_name') ?? + 'Selected Job', + selectedValue: setjobname, + listData: [ + 'Device Setting', + 'Log Shipping', + 'Validate Enrollment', + 'Configuration', + 'Mobile Desktop' + ], + ), + ), + Padding( + padding: const EdgeInsets.all(0.00), + child: DropdownFormFieldNormalReuse( + _onUpdateeFrequencySelection, + hintText: AppLocalization.of(context) + .translate('sync_frequency_label_communication') ?? + 'Sync Frequency', + selectedValue: syncfrequencySelectedItem, + listData: [ + 'Every Minute', + 'Every 5 Minutes', + 'Every 20 Minutes', + 'Every Day', + 'Every Month', + 'Every Year' + ], + ), + ), + SizedBox( + height: 5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + child: Container( child: FlatButton( - onPressed: () async { - await _onBackGroundJobCancelButtonPress(); - }, - child: Text( - AppLocalization.of(context) - .translate('cancel_button_backgroundjob'), - style: TextStyle( - color: Colors.blue, - fontSize: 18, - fontWeight: FontWeight.w600)), - ), + onPressed: () { + _onBackGroundJobStartButtonPress(); + }, + child: Text( + AppLocalization.of(context) + .translate('start_button_backgroundjob'), + style: TextStyle( + color: Colors.blue, + fontSize: 18, + fontWeight: FontWeight.w600), ), - ], - ), - SizedBox( - height: 5, + )), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 0.0), - child: Column( - children: [ - SizedBox(height: 5.0), - ExpansionTile( - title: Text( - "System Jobs", - style: - TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold), - ), - ), - ], + Container( + decoration: BoxDecoration(), + child: FlatButton( + onPressed: () async { + await _onBackGroundJobCancelButtonPress(); + }, + child: Text( + AppLocalization.of(context) + .translate('cancel_button_backgroundjob'), + style: TextStyle( + color: Colors.blue, + fontSize: 18, + fontWeight: FontWeight.w600)), ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - StreamBuilder( - stream: bloc.backgroundJobScheduleDao.watchAllJobs(), - builder: (context, - AsyncSnapshot> snapshot) { - final jobs = snapshot.data ?? List(); + ], + ), - return Expanded( - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: jobs.length, - itemBuilder: (_, index) { - //final itemTask = jobs[index]; - return Container( - color: (index % 2 == 0) - ? Theme.of(context).cardColor.withOpacity(0.8) - : Theme.of(context).backgroundColor, - child: Row( + Padding( + padding: const EdgeInsets.symmetric(vertical: 15,horizontal: 12 ), + child: + Text( + "System Jobs", + style: + TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold), + ), + + ), + Expanded( + child: Container( + + child: StreamBuilder( + stream: bloc.backgroundJobScheduleDao.watchAllJobs(), + builder: (context, + AsyncSnapshot> snapshot) { + final jobs = snapshot.data ?? List(); + + return ListView.builder( + scrollDirection: Axis.vertical, + + itemCount: jobs.length, + itemBuilder: (_, index) { + //final itemTask = jobs[index]; + return Container( + color: (index % 2 == 0) + ? Theme.of(context).cardColor.withOpacity(0.8) + : Theme.of(context).backgroundColor, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Divider(height: 0.5), - ListTile( - title: Text( - '${jobs[index].jobName}', - style: TextStyle( - fontSize: 14.0, - color: Colors.blueAccent), - ), - subtitle: Text( - '${jobs[index].syncFrequency}', - style: new TextStyle( - fontSize: 18.0, - fontStyle: FontStyle.italic, - ), - ), - ), - ], + Divider(height: 0.5), + ListTile( + title: Text( + '${jobs[index].jobName}', + style: TextStyle( + fontSize: 14.0, + color: Colors.blueAccent), + ), + subtitle: Text( + '${jobs[index].syncFrequency}', + style: new TextStyle( + fontSize: 18.0, + fontStyle: FontStyle.italic, + ), ), ), - Expanded( - child: Column( - children: [ - Divider(height: 0.5), - ListTile( - title: Text( - '${jobs[index].jobStatus}', - style: TextStyle( - fontSize: 14.0, - color: Colors.blueAccent), - ), - subtitle: Text( - '${jobs[index].lastRun}', - style: new TextStyle( - fontSize: 18.0, - fontStyle: FontStyle.italic, - ), - ), - ), - ], + ], + ), + ), + Expanded( + child: Column( + children: [ + Divider(height: 0.5), + ListTile( + title: Text( + '${jobs[index].jobStatus}', + style: TextStyle( + fontSize: 14.0, + color: Colors.blueAccent), + ), + subtitle: Text( + '${jobs[index].lastRun}', + style: new TextStyle( + fontSize: 18.0, + fontStyle: FontStyle.italic, + ), ), - ) + ), ], ), - ); - }, + ) + ], ), ); }, - ), - ], - ) + ); + }, + ), + ), + ) ], - )), + ), ); } } diff --git a/lib/src/ui/home/home_page.dart b/lib/src/ui/home/home_page.dart index 804964c..569c890 100644 --- a/lib/src/ui/home/home_page.dart +++ b/lib/src/ui/home/home_page.dart @@ -19,10 +19,14 @@ import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; +import 'package:j3enterprise/main.dart'; import 'package:j3enterprise/src/database/crud/desktop/desktop_crud.dart'; +import 'package:j3enterprise/src/database/crud/user/user_crud.dart'; import 'package:j3enterprise/src/database/moor_database.dart'; +import 'package:j3enterprise/src/resources/repositories/user_repository.dart'; import 'package:j3enterprise/src/resources/shared/colors/my_color.dart'; import 'package:j3enterprise/src/resources/shared/lang/appLocalization.dart'; +import 'package:j3enterprise/src/resources/shared/preferences/user_share_data.dart'; import 'package:j3enterprise/src/resources/shared/widgets/circuler_indicator.dart'; import 'package:j3enterprise/src/resources/shared/widgets/custom_drawer.dart'; @@ -33,9 +37,12 @@ class HomePage extends StatefulWidget { static final route = '/home'; var db; DesktopDao desktopDao; + UserDao userDao; HomePage() { db = AppDatabase(); desktopDao = DesktopDao(db); + userDao=UserDao(db); + } @override @@ -43,9 +50,30 @@ class HomePage extends StatefulWidget { } class _HomePageState extends State { + String searchText = ''; //final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); int code = 0xe8b8; + String image= 'images/beach-background.jpg'; + int userId; + @override + void didChangeDependencies() async{ + await getIt().getUserSharedPref().then((value) { + setState(() { + userId=int.parse(value['userId']); + }); + }); + super.didChangeDependencies(); + } +getImageName(String themeMode){ + if(themeMode=='dark'){ + return 'images/dark-theme-background.jpg'; + }else{ + return 'images/beach-background.jpg'; + } + +} + User user; @override Widget build(BuildContext context) { try { @@ -72,174 +100,185 @@ class _HomePageState extends State { })) ], ), - drawer: CustomDrawer(), - body: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - 'images/hrhw3a.jpg', - ), - fit: BoxFit.cover, - )), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 12), - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 12, vertical: 5), - child: Center( - child: ListFilter( - placeholder: 'Search', - filter: searchText, - onFilterChanged: (search) { - setState(() { - searchText = search; - }); - }), - ), - ) - ], - // color: Theme.of(context).backgroundColor, - ), + drawer: CustomDrawer( ), + body: StreamBuilder ( + stream:widget.userDao.watchSingleUser(userId), + builder: (context, snapshot) { + + if(snapshot.hasData){ + + user = snapshot.data; + + } + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + snapshot.hasData==true?getImageName(user.themeData):image, ), - StreamBuilder( - stream: widget.desktopDao.watchAllBusinessRule(searchText), - builder: (context, snapshot) { - if (snapshot.hasData) { - List prefData = snapshot.data; - List groupsCollection = List(); - prefData.forEach((element) { - if (!groupsCollection.contains(element.iconGroup)) { - groupsCollection.add(element.iconGroup); - } - }); - if (prefData.isEmpty) { - return BuildOnNoData( - message: "No Desktop Icons found", - ); - } - return Expanded( - child: ListView.builder( - itemCount: groupsCollection.length, - itemBuilder: (context, index) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16), - child: Text( - groupsCollection[index], - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 15, vertical: 8), - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .cardColor - .withOpacity(0.8), - borderRadius: - BorderRadius.circular(10), + fit: BoxFit.cover, + )), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 12), + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 12, vertical: 5), + child: Center( + child: ListFilter( + placeholder: 'Search', + filter: searchText, + onFilterChanged: (search) { + setState(() { + searchText = search; + }); + }), + ), + ) + ], + // color: Theme.of(context).backgroundColor, + ), + ), + StreamBuilder( + stream: widget.desktopDao.watchAllBusinessRule(searchText), + builder: (context, snapshot) { + if (snapshot.hasData) { + List prefData = snapshot.data; + List groupsCollection = List(); + prefData.forEach((element) { + if (!groupsCollection.contains(element.iconGroup)) { + groupsCollection.add(element.iconGroup); + } + }); + if (prefData.isEmpty) { + return BuildOnNoData( + message: "No Desktop Icons found", + ); + } + return Expanded( + child: ListView.builder( + itemCount: groupsCollection.length, + itemBuilder: (context, index) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16), + child: Text( + groupsCollection[index], + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), ), - child: Wrap(children: [ - ...prefData.map((e) { - if (e.iconGroup == - groupsCollection[index]) { - return InkWell( - onTap: () { - Navigator.pushNamed(context, - e.navigationRoute); - }, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 12, - vertical: 8), - child: Container( - width: 70, - child: Column( - children: [ - Card( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius - .circular( - 5)), - clipBehavior: - Clip.antiAlias, - child: Container( - width: 60, - height: 60, - color: Color( - int.parse(e - .iconColour)), - child: Icon( - IconData( + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 8), + child: Container( + decoration: BoxDecoration( + color: Theme.of(context) + .cardColor + .withOpacity(0.8), + borderRadius: + BorderRadius.circular(10), + ), + child: Wrap(children: [ + ...prefData.map((e) { + if (e.iconGroup == + groupsCollection[index]) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, + e.navigationRoute); + }, + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: 12, + vertical: 8), + child: Container( + width: 70, + child: Column( + children: [ + Card( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5)), + clipBehavior: + Clip.antiAlias, + child: Container( + width: 60, + height: 60, + color: Color( int.parse(e - .iconCode), - fontFamily: e - .iconFamily), - color: Colors - .white), - ), + .iconColour)), + child: Icon( + IconData( + int.parse(e + .iconCode), + fontFamily: e + .iconFamily), + color: Colors + .white), + ), + ), + Container( + child: Text( + e.iconName, + style: TextStyle( + fontWeight: + FontWeight + .w500, + ), + textAlign: TextAlign + .center, + softWrap: true, + )) + ], ), - Container( - child: Text( - e.iconName, - style: TextStyle( - fontWeight: - FontWeight - .w500, - ), - textAlign: TextAlign - .center, - softWrap: true, - )) - ], - ), - ), - )); - } else { - return Container(); - } - }), - ]), - ), - ), - ], - ); - }), - ); // r - } + ), + )); + } else { + return Container(); + } + }), + ]), + ), + ), + ], + ); + }), + ); // r + } - return BuildProgressIndicator(); - }) - ]), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // StreamBuilder( - // stream: widget.desktopDao.watchAllBusinessRule(), - // builder: (context, snapshot) { - // if (snapshot.hasData) { - // return Text(snapshot.data.toString()); - // } - // return BuildProgressIndicator(); - // }) - // ], - // ), + return BuildProgressIndicator(); + }) + ]), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // StreamBuilder( + // stream: widget.desktopDao.watchAllBusinessRule(), + // builder: (context, snapshot) { + // if (snapshot.hasData) { + // return Text(snapshot.data.toString()); + // } + // return BuildProgressIndicator(); + // }) + // ], + // ), + ); + } ), ); } catch (e) {} diff --git a/lib/src/ui/login/login_form.dart b/lib/src/ui/login/login_form.dart index f48a202..3121669 100755 --- a/lib/src/ui/login/login_form.dart +++ b/lib/src/ui/login/login_form.dart @@ -58,7 +58,7 @@ class _LoginFormState extends State { _onLoginButtonPressed() async { formKey.currentState.validate(); - // await getIt().setTenantIntoSharedPref(_tenantController.text); + await getIt().setTenantIntoSharedPref(_tenantController.text); BlocProvider.of(context).add( LoginButtonPressed( username: _usernameController.text.trim(), diff --git a/lib/src/ui/login/login_page.dart b/lib/src/ui/login/login_page.dart index ab663f5..c51791d 100755 --- a/lib/src/ui/login/login_page.dart +++ b/lib/src/ui/login/login_page.dart @@ -29,10 +29,28 @@ import 'package:j3enterprise/src/ui/authentication/authentication_bloc.dart'; import 'bloc/login_bloc.dart'; import 'login_form.dart'; -class LoginPage extends StatelessWidget { +class LoginPage extends StatefulWidget { static final route = '/login'; + + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { final UserRepository userRepository = getIt(); + String image= 'images/beach-background.jpg'; + @override + void didChangeDependencies() { + getIt().getTheme().then((value) { + if(value=='dark'){ + setState(() { + image='images/dark-theme-background.jpg'; + }); + } + }); + super.didChangeDependencies(); + } @override Widget build(BuildContext context) { return Scaffold( @@ -54,7 +72,7 @@ class LoginPage extends StatelessWidget { children: [ Positioned.fill( child: Image.asset( - 'images/hrhw3a.jpg', + image, fit: BoxFit.cover, ), ), diff --git a/lib/src/ui/preferences/preference_detail.dart b/lib/src/ui/preferences/preference_detail.dart index 511c3b5..80c6600 100644 --- a/lib/src/ui/preferences/preference_detail.dart +++ b/lib/src/ui/preferences/preference_detail.dart @@ -193,6 +193,7 @@ class _PreferenceDetailPageState extends State { ), InkWell( child: Container( + color: Theme.of(context).cardColor, margin: EdgeInsets.only( left: 8), @@ -216,6 +217,7 @@ class _PreferenceDetailPageState extends State { ], ) : FindDropdown( + backgroundColor: Theme.of(context).cardColor, onFind: (value) async { print(value); return prefData.dataValue @@ -421,9 +423,11 @@ class _PreferenceDetailPageState extends State { _displayDialog(BuildContext context, callBack) async { return showDialog( + barrierColor: Theme.of(context).cardColor, context: context, builder: (context) { return AlertDialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), title: Text('Option'), diff --git a/lib/src/ui/profile/profile_page.dart b/lib/src/ui/profile/profile_page.dart index 4333ece..f74e795 100644 --- a/lib/src/ui/profile/profile_page.dart +++ b/lib/src/ui/profile/profile_page.dart @@ -49,6 +49,7 @@ class ProfilePage extends StatefulWidget { class _ProfilePageState extends State { String tenantName; String theme; + @override void didChangeDependencies() async { await getIt().getLocale().then((value) { @@ -68,7 +69,7 @@ class _ProfilePageState extends State { tenantName = data['tenantName']; final profileData = - await widget.userDao.getSingleUser(int.parse(data['userId'])); + await widget.userDao.getSingleUser(int.parse(data['userId'])); return profileData; } @@ -76,7 +77,7 @@ class _ProfilePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - // backgroundColor: Theme.of(context).backgroundColor, + // backgroundColor: Theme.of(context).backgroundColor, appBar: AppBar( centerTitle: false, //ToDo add translation for preferences title @@ -120,7 +121,8 @@ class _ProfilePageState extends State { padding: EdgeInsets.all(16.0), margin: EdgeInsets.only(top: 16.0), decoration: BoxDecoration( - color: Theme.of(context) + color: Theme + .of(context) .cardColor .withOpacity(.8), borderRadius: BorderRadius.circular(5.0)), @@ -131,12 +133,15 @@ class _ProfilePageState extends State { margin: EdgeInsets.only(left: 96.0), child: Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( user.fullName, style: - Theme.of(context).textTheme.title, + Theme + .of(context) + .textTheme + .title, ), ListTile( contentPadding: EdgeInsets.all(0), @@ -166,7 +171,10 @@ class _ProfilePageState extends State { SizedBox(height: 20.0), Container( decoration: BoxDecoration( - color: Theme.of(context).cardColor.withOpacity(.8), + color: Theme + .of(context) + .cardColor + .withOpacity(.8), borderRadius: BorderRadius.circular(5.0), ), child: Column( @@ -190,14 +198,14 @@ class _ProfilePageState extends State { }, title: Text( AppLocalization.of(context) - .translate('language_appdraw') ?? + .translate('language_appdraw') ?? 'Language', ), subtitle: Text(selecteditem == 'es' ? 'Spanish' : selecteditem == 'en' - ? 'English' - : 'English'), + ? 'English' + : 'English'), leading: Icon(CustomIcons.language), ), ListTile( @@ -205,8 +213,24 @@ class _ProfilePageState extends State { subtitle: Text(theme), leading: Icon(Icons.brightness_4), trailing: Switch( - value: theme == 'dark' ? true : false, - onChanged: _changeTheme, + value: theme == 'dark' ? true : false, + onChanged: (theme) async { + if (theme == true) { + await getIt() + .setTheme('dark'); + widget.userDao.updateSingleUser( + user.copyWith(themeData: 'dark')); + } else { + await getIt() + .setTheme('light'); + widget.userDao.updateSingleUser( + user.copyWith(themeData: 'Light')); + } + App.setTheme( + context, + ); + } + )), ListTile( title: Text("Currency"), @@ -229,14 +253,4 @@ class _ProfilePageState extends State { ); } - void _changeTheme(bool theme) async { - if (theme == true) { - await getIt().setTheme('dark'); - } else { - await getIt().setTheme('light'); - } - App.setTheme( - context, - ); - } }