124 lines
3.6 KiB
Dart
124 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:insparkspokalen_ui/info/informationPage.dart';
|
|
import 'package:insparkspokalen_ui/info/AdminInformationPage.dart';
|
|
import 'package:insparkspokalen_ui/ProfileInfoTab/ProfilePage.dart';
|
|
import 'package:insparkspokalen_ui/ProfileInfoTab/ProfilePageAdmin.dart';
|
|
|
|
class BaseScaffold extends StatelessWidget {
|
|
final String title;
|
|
final int selectedIndex;
|
|
final Function(int) onTap;
|
|
final Widget body;
|
|
final String role; // USER el ADMIN
|
|
|
|
const BaseScaffold({
|
|
super.key,
|
|
required this.title,
|
|
required this.selectedIndex,
|
|
required this.onTap,
|
|
required this.body,
|
|
required this.role, //USER el ADMIN
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Definiera items beroende på roll
|
|
final items = <BottomNavigationBarItem>[
|
|
const BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Hem'),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.calendar_month),
|
|
label: 'Schema',
|
|
),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.leaderboard),
|
|
label: 'Poängställning',
|
|
),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.description),
|
|
label: 'Uppdrag',
|
|
),
|
|
];
|
|
|
|
// Lägg till "Grupper" endast om ADMIN
|
|
if (role == 'ADMIN') {
|
|
items.add(
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.group),
|
|
label: 'Grupper',
|
|
),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF2E2E2E),
|
|
appBar: AppBar(
|
|
backgroundColor: const Color(0xFF2E2E2E),
|
|
centerTitle: true,
|
|
title: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
color: Color(0xFFDAA520),
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.info, color: Color(0xFFDAA520)),
|
|
onPressed: () {
|
|
if (role == 'ADMIN') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const AdminInformationPage(),
|
|
),
|
|
);
|
|
} else {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const InformationPage(),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.person_outline, color: Color(0xFFDAA520)),
|
|
onPressed: () {
|
|
if (role == 'ADMIN') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const ProfilePageAdmin(),
|
|
),
|
|
);
|
|
} else {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const ProfilePage()),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
const SizedBox(width: 12),
|
|
],
|
|
),
|
|
body: body,
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
backgroundColor: const Color(0xFF2E2E2E),
|
|
type: BottomNavigationBarType.fixed,
|
|
selectedItemColor: const Color(0xFFDAA520),
|
|
unselectedItemColor: Colors.grey,
|
|
currentIndex: selectedIndex,
|
|
onTap: (index) {
|
|
// Om inte ADMIN och index är 4, gör inget
|
|
if (role != 'ADMIN' && index >= items.length) return;
|
|
onTap(index);
|
|
},
|
|
items: items,
|
|
),
|
|
);
|
|
}
|
|
}
|