You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.4 KiB

3 years ago
import 'package:flutter/material.dart';
import 'PageWidgets/Alerts/header.dart';
import 'Sub_Pages/Notifications/Alerts.dart';
import 'Sub_Pages/Notifications/Inbox.dart';
import 'package:teso/providers/user_provider.dart';
import 'package:provider/provider.dart';
import 'package:teso/Classes/TesoUser.dart';
class Notifications extends StatefulWidget {
@override
_NotificationsState createState() => _NotificationsState();
}
class _NotificationsState extends State<Notifications> {
// ignore: avoid_init_to_null
Color fcurrentColor = null;
Color fTextColor1 = Colors.white;
Color fcurrentColor1;
Color fTextColor2;
int _page = 0;
PageController _pageController;
bool chats = false;
@override
void initState() {
super.initState();
_pageController = PageController(initialPage: _page);
fTextColor1 = Colors.white;
fTextColor2 = Colors.grey;
//setColor();
}
void setColor() {
setState(() {
fcurrentColor = Theme.of(context).colorScheme.secondary;
fTextColor1 = Colors.white;
});
}
void navigationTapped(int page) {
_pageController.animateToPage(
page,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
switch (page) {
case 0:
setState(() {
fcurrentColor = Theme.of(context).colorScheme.secondary;
fTextColor1 = Colors.white;
fcurrentColor1 = Theme.of(context).primaryColor;
fTextColor2 = Colors.grey;
chats = false;
});
break;
case 1:
setState(() {
fcurrentColor1 = Theme.of(context).colorScheme.secondary;
fTextColor1 = Colors.grey;
fcurrentColor = Theme.of(context).primaryColor;
fTextColor2 = Colors.white;
chats = true;
});
break;
}
}
void onPageChanged(int page) {
setState(() {
this._page = page;
});
switch (page) {
case 0:
setState(() {
fcurrentColor = Theme.of(context).colorScheme.secondary;
fTextColor1 = Colors.white;
fcurrentColor1 = Theme.of(context).primaryColor;
fTextColor2 = Colors.grey;
chats = false;
});
break;
case 1:
setState(() {
fcurrentColor1 = Theme.of(context).colorScheme.secondary;
fTextColor1 = Colors.grey;
fcurrentColor = Theme.of(context).primaryColor;
fTextColor2 = Colors.white;
chats = true;
});
break;
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
TesoUser user =
Provider.of<UserProvider>(context, listen: false).currentUser;
return Scaffold(
appBar: PreferredSize(
child: AppBar(
backgroundColor: Theme.of(context).primaryColor,
title: buildNotficationHeader(
context,
fcurrentColor,
fcurrentColor1,
fTextColor1,
fTextColor2,
navigationTapped,
chats,
user),
),
preferredSize: Size.fromHeight(50)),
body: PageView(
//physics:,
controller: _pageController,
onPageChanged: onPageChanged,
children: <Widget>[
Alerts(),
Inbox(
user: user,
),
],
),
);
}
}