163 lines
6.1 KiB
Dart
163 lines
6.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../widgets/digital_clock_widget.dart';
|
|
import '../../widgets/weather_widget.dart';
|
|
import '../../widgets/calendar_widget.dart';
|
|
import '../../widgets/schedule_list_widget.dart';
|
|
import '../../widgets/announcement_widget.dart';
|
|
import '../../widgets/photo_slideshow_widget.dart';
|
|
import '../../widgets/todo_list_widget.dart';
|
|
import '../../widgets/bible_verse_widget.dart';
|
|
|
|
class TvDashboardScreen extends StatefulWidget {
|
|
const TvDashboardScreen({super.key});
|
|
|
|
@override
|
|
State<TvDashboardScreen> createState() => _TvDashboardScreenState();
|
|
}
|
|
|
|
class _TvDashboardScreenState extends State<TvDashboardScreen> {
|
|
// Timer for periodic refresh (every 5 minutes for data, 1 second for clock)
|
|
Timer? _dataRefreshTimer;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Initial data fetch could be triggered here or within widgets
|
|
_startDataRefresh();
|
|
}
|
|
|
|
void _startDataRefresh() {
|
|
_dataRefreshTimer = Timer.periodic(const Duration(minutes: 5), (timer) {
|
|
// Trigger refreshes if needed, or let widgets handle their own polling
|
|
// For simplicity, we assume widgets or providers handle their data
|
|
setState(() {}); // Rebuild to refresh UI state if needed
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_dataRefreshTimer?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 1920x1080 reference
|
|
return Scaffold(
|
|
body: Center(
|
|
child: AspectRatio(
|
|
aspectRatio: 16 / 9,
|
|
child: FittedBox(
|
|
fit: BoxFit.contain,
|
|
child: SizedBox(
|
|
width: 1920,
|
|
height: 1080,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32.0), // Outer margin safe zone
|
|
child: Column(
|
|
children: [
|
|
// Header: Time and Weather
|
|
SizedBox(
|
|
height: 100,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const DigitalClockWidget(),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const WeatherWidget(),
|
|
const SizedBox(width: 16),
|
|
IconButton(
|
|
icon: const Icon(Icons.settings,
|
|
color: Colors.white70),
|
|
onPressed: () {
|
|
Navigator.of(context).pushNamed('/admin');
|
|
},
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
// Main Content Grid
|
|
Expanded(
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Left Column: Calendar, Bible Verse (Swapped)
|
|
Expanded(
|
|
flex: 3,
|
|
child: Column(
|
|
children: [
|
|
const Expanded(
|
|
flex: 3, child: CalendarWidget()), // Increased flex from 2 to 3
|
|
const SizedBox(height: 16),
|
|
const Expanded(
|
|
flex: 3, child: BibleVerseWidget()), // Reduced flex from 4 to 3
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 24),
|
|
// Center Column: Todos, Weekly Schedule (Swapped)
|
|
Expanded(
|
|
flex: 3, // Reduced from 4 to 3
|
|
child: Column(
|
|
children: [
|
|
const Expanded(
|
|
flex: 6, child: TodoListWidget()),
|
|
const SizedBox(height: 16),
|
|
const Expanded(
|
|
flex: 6, child: ScheduleListWidget()),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 24),
|
|
// Right Column: Photo Slideshow
|
|
Expanded(
|
|
flex: 4, // Increased from 3 to 4
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.5),
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 10),
|
|
),
|
|
],
|
|
),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: const PhotoSlideshowWidget(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Hidden trigger for admin/mobile view (e.g. long press corner)
|
|
GestureDetector(
|
|
onLongPress: () {
|
|
Navigator.of(context).pushNamed('/admin');
|
|
},
|
|
child: Container(
|
|
width: 50,
|
|
height: 50,
|
|
color: Colors.transparent,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|