recent activities added.

main_design2.0
Sikander Saleem 2 years ago
parent fe624596a1
commit e3fbcae6d3

@ -1,11 +1,62 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/notifications_provider.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/notifications/notification_item.dart';
class RecentActivitiesFragment extends StatelessWidget {
RecentActivitiesFragment({Key key}) : super(key: key);
NotificationsProvider _notificationsProvider;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container();
_notificationsProvider ??= Provider.of<NotificationsProvider>(context);
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Container(
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadows: const [
BoxShadow(
color: Color(0x07000000),
blurRadius: 14,
offset: Offset(0, 0),
spreadRadius: 0,
)
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Recent Activities", style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50)).paddingOnly(top: 16, start: 16, end: 16),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(16),
itemCount: _notificationsProvider.notifications.length,
separatorBuilder: (context, itemIndex) => 1.divider.paddingOnly(top: 16, bottom: 16),
itemBuilder: (context, itemIndex) {
// todo add priority & progress tag to show chip
return NotificationItem(
notification: _notificationsProvider.notifications[itemIndex],
onPressed: (notification) {
// todo @sikander, check notifications payload, because notification model is different to need to check from backend
//Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId);
},
);
},
),
],
),
),
);
}
}

@ -12,8 +12,6 @@ import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/recent_act
import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart';
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
import 'dashboard_page_indicator.dart';
class DashboardPage extends StatefulWidget {
final VoidCallback onDrawerPress;
@ -24,22 +22,15 @@ class DashboardPage extends StatefulWidget {
}
class _DashboardPageState extends State<DashboardPage> {
PageController _controller;
int _currentPage = 1;
int _currentPage = 0;
@override
void initState() {
super.initState();
_controller = PageController()
..addListener(() {
_currentPage = _controller.page.toInt() + 1;
setState(() {});
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@ -113,32 +104,41 @@ class _DashboardPageState extends State<DashboardPage> {
24.height,
Row(
children: [
DashboardPageIndicator(index: 0, currentPage: _currentPage, controller: _controller),
indicatorView(0),
3.width,
DashboardPageIndicator(index: 1, currentPage: _currentPage, controller: _controller),
indicatorView(1),
3.width,
DashboardPageIndicator(index: 2, currentPage: _currentPage, controller: _controller),
indicatorView(2),
10.width,
Text(
"0$_currentPage/03",
"0${_currentPage + 1}/03",
style: Theme.of(context).textTheme.labelMedium?.copyWith(fontWeight: FontWeight.w500),
),
],
),
],
).paddingOnly(start: 16, end: 16, top: 8, bottom: 8),
Expanded(
child: PageView(
controller: _controller,
children: [
RequestsFragment(),
ProgressFragment(),
RecentActivitiesFragment(),
],
),
),
PageView(
onPageChanged: (index) => setState(() => _currentPage = index),
children: [
RequestsFragment(),
ProgressFragment(),
RecentActivitiesFragment(),
],
).expanded,
],
),
);
}
Widget indicatorView(int index) {
bool isActive = _currentPage == index;
return AnimatedContainer(
duration: const Duration(milliseconds: 250),
width: (isActive ? 30 : 12).toScreenWidth,
height: 9.toScreenHeight,
decoration: BoxDecoration(color: isActive ? AppColor.green50 : AppColor.neutral40, borderRadius: BorderRadius.circular(8)),
);
}
}

@ -1,31 +0,0 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import '../../app_style/app_color.dart';
class DashboardPageIndicator extends StatelessWidget {
final PageController controller;
final int index, currentPage;
const DashboardPageIndicator({
Key key,
@required this.controller,
@required this.index,
@required this.currentPage,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final bool isActive = currentPage == (index + 1);
return InkWell(
onTap: () {
controller.animateToPage(index, duration: const Duration(milliseconds: 500), curve: Curves.ease);
},
child: Container(
width: (isActive ? 30 : 12).toScreenWidth,
height: 9.toScreenHeight,
decoration: BoxDecoration(color: isActive ? AppColor.green50 : AppColor.neutral40, borderRadius: BorderRadius.circular(8)),
),
);
}
}
Loading…
Cancel
Save