Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Android 13+ requires this to be requested at runtime too; see
Expand All @@ -7,6 +8,13 @@
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- Lets WorkManager reschedule the background Kréta check after a reboot. -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- open_filex declares these so it can open files anywhere on the device.
Pala only opens message attachments saved in its own cache folder,
which needs none of them, so they are left out of the app. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" tools:node="remove"/>

<!-- No auto backup: a restored flutter_secure_storage blob can't be
decrypted without this device's Keystore key, and the backup would
Expand Down
133 changes: 112 additions & 21 deletions app/lib/core/adaptive/adaptive_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import '../../views/tasks_view.dart';
import '../../views/timetable_view.dart';
import 'adaptive_breakpoints.dart';
import 'app_pages.dart';
import 'pala_sidebar.dart';
import '../theme/pala_tokens.dart';
import 'package:pala/utils/pala_clock.dart';
import '../theme/app_shapes.dart';

/// Unified adaptive root scaffold auto-swapping between NavigationBar (<600dp)
/// and NavigationRail (>=600dp) while preserving state via IndexedStack and PageStorageKey.
/// Unified adaptive root scaffold: a bottom NavigationBar on phones (<600dp)
/// and, from 600dp up, Kréta Web's layout (a [PalaSidebar] and a top bar),
/// while preserving state via IndexedStack and PageStorageKey.
class AdaptiveScaffold extends StatefulWidget {
final AppModel appModel;

Expand Down Expand Up @@ -188,31 +192,23 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
final bottomNavIndex = barSlot >= 0 ? barSlot : _compactBranches.length;

return Scaffold(
appBar: _buildAppBar(context, theme, colorScheme, isCompact: isCompact),
appBar: isCompact ? _buildAppBar(context, theme, colorScheme, isCompact: true) : null,
body: Row(
children: [
if (!isCompact) ...[
NavigationRail(
if (!isCompact)
PalaSidebar(
extended: isLargeDesktop,
// Rows narrower than this get centred in the rail, so keep it above the longest label.
minExtendedWidth: 256,
labelType: isLargeDesktop ? NavigationRailLabelType.none : NavigationRailLabelType.all,
selectedIndex: _currentIndex,
onDestinationSelected: _navigateToIndex,
destinations: [
for (final d in _destinations)
NavigationRailDestination(
icon: Icon(d.$1),
selectedIcon: Icon(d.$2),
label: Text(d.$3),
),
],
onSelected: _navigateToIndex,
items: [for (final d in _destinations) PalaSidebarItem(d.$1, d.$2, d.$3)],
userName: widget.appModel.student?.name,
userSubtitle: widget.appModel.student?.institutionName,
onUserTap: () => _navigateToIndex(AppPages.profile),
),
const VerticalDivider(width: 1),
],
Expanded(
child: Column(
children: [
if (!isCompact) _buildTopBar(context, isLargeDesktop: isLargeDesktop),
_buildMaintenanceBanner(colorScheme),
Expanded(
child: IndexedStack(
Expand Down Expand Up @@ -249,6 +245,101 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
);
}

/// Kréta Web's top bar: the page title on the left, bordered action
/// buttons on the right, and a thin progress line while data loads.
Widget _buildTopBar(BuildContext context, {required bool isLargeDesktop}) {
final t = PalaTokens.of(context);
final model = widget.appModel;
Widget action({required IconData icon, required String label, required VoidCallback? onPressed}) {
if (!isLargeDesktop) {
return IconButton(tooltip: label, icon: Icon(icon, size: 20), onPressed: onPressed);
}
return OutlinedButton.icon(
style: OutlinedButton.styleFrom(
minimumSize: const Size(0, 38),
padding: const EdgeInsets.symmetric(horizontal: 16),
// From the theme, so the label keeps the app's font family.
textStyle: Theme.of(context).textTheme.labelLarge?.copyWith(fontSize: 13.5, fontWeight: FontWeight.w600),
),
onPressed: onPressed,
icon: Icon(icon, size: 16),
label: Text(label),
);
}

return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 64,
padding: const EdgeInsets.symmetric(horizontal: 28),
decoration: BoxDecoration(
color: t.sidebar,
border: Border(bottom: BorderSide(color: t.border)),
),
child: Row(
children: [
Expanded(
child: Text(
_titles[_currentIndex],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.text, fontSize: 20, fontWeight: FontWeight.w700),
),
),
if (model.isDemo) ...[
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: t.primary.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(AppShapes.control),
border: Border.all(color: t.primary.withValues(alpha: 0.3)),
),
child: Text(
'DEMÓ',
style: TextStyle(color: t.primary, fontSize: 11, fontWeight: FontWeight.w700, letterSpacing: 0.5),
),
),
const SizedBox(width: 12),
],
// Pala Wrapped: only in the summer break or demo mode. A plain
// button, so it does not read as an AI feature.
if (isWrappedSeason(PalaClock.now()) || model.isDemo) ...[
action(
icon: Icons.summarize_outlined,
label: 'Pala Wrapped',
onPressed: () => PalaWrappedView.show(context, model),
),
const SizedBox(width: 12),
],
action(
icon: Icons.search,
label: 'Keresés',
onPressed: () => GlobalSearchView.show(context, model),
),
const SizedBox(width: 12),
action(
icon: Icons.refresh,
label: 'Frissítés',
onPressed: model.isLoading ? null : () => model.refreshAll(),
),
],
),
),
SizedBox(
height: 2,
child: model.isLoading
? LinearProgressIndicator(
minHeight: 2,
backgroundColor: Colors.transparent,
valueColor: AlwaysStoppedAnimation<Color>(t.primary),
)
: null,
),
],
);
}

PreferredSizeWidget _buildAppBar(
BuildContext context,
ThemeData theme,
Expand All @@ -268,7 +359,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: colorScheme.primary,
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(AppShapes.control),
),
child: const Text(
'PALA',
Expand Down Expand Up @@ -312,7 +403,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: colorScheme.tertiaryContainer,
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(AppShapes.control),
border: Border.all(color: colorScheme.tertiary),
),
child: Text(
Expand Down
198 changes: 198 additions & 0 deletions app/lib/core/adaptive/pala_sidebar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import 'package:flutter/material.dart';

import '../theme/app_shapes.dart';
import '../theme/pala_tokens.dart';

/// One page in the [PalaSidebar].
class PalaSidebarItem {
final IconData icon;
final IconData selectedIcon;
final String label;

const PalaSidebarItem(this.icon, this.selectedIcon, this.label);
}

/// The desktop navigation, laid out like Kréta Web's sidebar: brand row, one
/// row per page (the open page gets an orange tint and a left accent bar) and
/// the student at the bottom. Below [extended] width only icons are shown.
class PalaSidebar extends StatelessWidget {
static const double extendedWidth = 270;
static const double collapsedWidth = 76;

final List<PalaSidebarItem> items;
final int selectedIndex;
final ValueChanged<int> onSelected;
final bool extended;
final String? userName;
final String? userSubtitle;
final VoidCallback? onUserTap;

const PalaSidebar({
super.key,
required this.items,
required this.selectedIndex,
required this.onSelected,
this.extended = true,
this.userName,
this.userSubtitle,
this.onUserTap,
});

@override
Widget build(BuildContext context) {
final t = PalaTokens.of(context);
return Container(
width: extended ? extendedWidth : collapsedWidth,
decoration: BoxDecoration(
color: t.sidebar,
border: Border(right: BorderSide(color: t.border)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: extended ? 20 : 12, vertical: 20),
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: t.border))),
child: Row(
mainAxisAlignment: extended ? MainAxisAlignment.start : MainAxisAlignment.center,
children: [
Semantics(
header: true,
label: 'Pala alkalmazás',
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 5),
decoration: AppShapes.primaryFill(),
child: const Text(
'PALA',
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w900, fontSize: 14, letterSpacing: 1),
),
),
),
if (extended) ...[
const SizedBox(width: 12),
Flexible(
child: Text(
'Kréta App',
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.text, fontSize: 18, fontWeight: FontWeight.w700, letterSpacing: 0.3),
),
),
],
],
),
),
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
children: [
for (var i = 0; i < items.length; i++)
_SidebarRow(
item: items[i],
selected: i == selectedIndex,
extended: extended,
onTap: () => onSelected(i),
),
],
),
),
if (extended && userName != null && userName!.isNotEmpty)
Material(
color: t.shade,
child: InkWell(
onTap: onUserTap,
hoverColor: t.cardHover,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
decoration: BoxDecoration(border: Border(top: BorderSide(color: t.border))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
userName!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.text, fontSize: 14.5, fontWeight: FontWeight.w600),
),
if (userSubtitle != null && userSubtitle!.isNotEmpty) ...[
const SizedBox(height: 3),
Text(
userSubtitle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.textMuted, fontSize: 12.5),
),
],
],
),
),
),
),
],
),
);
}
}

class _SidebarRow extends StatelessWidget {
final PalaSidebarItem item;
final bool selected;
final bool extended;
final VoidCallback onTap;

const _SidebarRow({required this.item, required this.selected, required this.extended, required this.onTap});

@override
Widget build(BuildContext context) {
final t = PalaTokens.of(context);
final color = selected ? t.primary : t.textMuted;
final row = Padding(
padding: const EdgeInsets.only(bottom: 4),
child: ClipRRect(
borderRadius: BorderRadius.circular(AppShapes.control),
child: Material(
color: selected ? t.primary.withValues(alpha: 0.12) : Colors.transparent,
child: InkWell(
onTap: onTap,
hoverColor: t.cardHover,
child: Stack(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
child: Row(
mainAxisAlignment: extended ? MainAxisAlignment.start : MainAxisAlignment.center,
children: [
Icon(selected ? item.selectedIcon : item.icon, size: 20, color: color),
if (extended) ...[
const SizedBox(width: 14),
Expanded(
child: Text(
item.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: color,
fontSize: 14.5,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
),
),
),
],
],
),
),
if (selected)
Positioned(left: 0, top: 0, bottom: 0, child: Container(width: 3, color: t.primary)),
],
),
),
),
),
);
return Semantics(
button: true,
selected: selected,
label: extended ? null : item.label,
child: extended ? row : Tooltip(message: item.label, child: row),
);
}
}
Loading
Loading