150 lines
4.9 KiB
Dart
150 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:insparkspokalen_ui/models/postModel.dart';
|
|
import 'package:insparkspokalen_ui/models/teamModel.dart';
|
|
|
|
class AdminInfoBlock extends StatefulWidget {
|
|
final TeamModel group;
|
|
final VoidCallback onReject;
|
|
final PostStatus status;
|
|
|
|
const AdminInfoBlock({
|
|
super.key,
|
|
required this.group,
|
|
required this.onReject,
|
|
required this.status,
|
|
});
|
|
|
|
@override
|
|
State<AdminInfoBlock> createState() => AdminInfoBlockState();
|
|
}
|
|
|
|
class AdminInfoBlockState extends State<AdminInfoBlock> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Byt färg beroende på status
|
|
Color backgroundColor;
|
|
switch (widget.status) {
|
|
case PostStatus.rejected:
|
|
backgroundColor = Colors.grey.shade400;
|
|
break;
|
|
case PostStatus.approved:
|
|
backgroundColor = Colors.green.shade200;
|
|
break;
|
|
default:
|
|
backgroundColor = const Color(0xFFFEDF00);
|
|
}
|
|
|
|
return Card(
|
|
margin: const EdgeInsets.all(10),
|
|
color: backgroundColor,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
side: const BorderSide(color: Colors.black12),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
ListTile(
|
|
leading: const CircleAvatar(
|
|
backgroundImage: AssetImage("images/profilepic.jpg"),
|
|
),
|
|
title: Text(
|
|
widget.group.name,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
subtitle: const Text(
|
|
"Tid: 12:20",
|
|
style: TextStyle(color: Colors.black),
|
|
),
|
|
trailing: const Icon(Icons.more_vert, color: Colors.black),
|
|
),
|
|
Image.asset(
|
|
"images/testbild.jpg",
|
|
width: double.infinity,
|
|
height: 300,
|
|
fit: BoxFit.cover,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
const Text(
|
|
"• Uppdrag ",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Chip(
|
|
label: Text(
|
|
widget.group.name,
|
|
style: const TextStyle(color: Colors.black),
|
|
),
|
|
backgroundColor: Colors.amber,
|
|
shape: RoundedRectangleBorder(
|
|
side: const BorderSide(color: Colors.amber),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Visa knappar endast om pending
|
|
if (widget.status == PostStatus.pending)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
// Godkänn
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text("Inlägg godkänt")),
|
|
);
|
|
// Här hade du troligen en onApprove också
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.green,
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(15),
|
|
),
|
|
),
|
|
child: const Text("Godkänd"),
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
widget.onReject();
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text("Inlägg nekat")),
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.white,
|
|
foregroundColor: Colors.black,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
),
|
|
child: const Text("Neka"),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|