Skip to content

Commit

Permalink
Fix foldouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexerate committed Oct 14, 2024
1 parent cb4e863 commit e660718
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 70 deletions.
3 changes: 3 additions & 0 deletions assets/icons/lucide/chevron_down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 2 additions & 11 deletions lib/components/separator.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:online/theme/theme.dart';

class Separator extends StatelessWidget {
const Separator({super.key, this.margin = 0, this.length, this.axis = Axis.horizontal});
Expand All @@ -14,17 +15,7 @@ class Separator extends StatelessWidget {
height: h ? 1 : length,
width: !h ? 1 : length,
margin: EdgeInsets.symmetric(vertical: h ? margin : 0, horizontal: !h ? margin : 0),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: h ? Alignment.centerLeft : Alignment.bottomCenter,
end: h ? Alignment.centerRight : Alignment.topCenter,
colors: const [
Color(0xFF000212),
Color(0xFF2E3440),
Color(0xFF000212),
],
),
),
color: OnlineTheme.current.border,
);
}
}
2 changes: 1 addition & 1 deletion lib/pages/home/bedpres.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class BedpresCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconLabel(icon: IconType.dateTime, label: formatDate()),
IconLabel(icon: IconType.usersFilled, label: participants(), iconSize: 16),
IconLabel(icon: IconType.users, label: participants(), iconSize: 16),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/event_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class EventCard extends StatelessWidget {
fontWeight: 5,
),
IconLabel(
icon: IconType.usersFilled,
icon: IconType.users,
label: participants(),
color: OnlineTheme.current.mutedForeground,
iconSize: 16,
Expand Down
115 changes: 78 additions & 37 deletions lib/pages/menu/menu_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,76 @@ import '/services/env.dart';
import '/theme/theme.dart';
import '/theme/themed_icon.dart';

class Foldout extends StatefulWidget {
final Widget? leading;
final Widget? trailing;
final String title;
final List<Widget> children;

const Foldout({
super.key,
required this.title,
required this.children,
this.leading,
this.trailing,
});

@override
State<StatefulWidget> createState() => FoldoutState();
}

class FoldoutState extends State<Foldout> {
bool open = false;

Widget header() {
return Listener(
onPointerUp: (event) {
setState(() {
open = !open;
});
},
behavior: HitTestBehavior.opaque,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (widget.leading != null) widget.leading!,
Expanded(child: Text(widget.title, style: OnlineTheme.textStyle())),
AnimatedRotation(
turns: open ? -0.5 : 0,
duration: Duration(milliseconds: 100),
child: widget.trailing ??
Lucide(
LucideIcon.chevronDown,
size: 20,
),
),
],
),
);
}

@override
Widget build(BuildContext context) {
return Column(
children: [
header(),
ClipRect(
child: AnimatedAlign(
alignment: open ? Alignment.topCenter : Alignment.topCenter,
heightFactor: open ? 1.0 : 0.0,
duration: Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Column(
children: widget.children,
),
),
),
],
);
}
}

class MenuPage extends StatefulWidget {
const MenuPage({super.key});

Expand Down Expand Up @@ -128,41 +198,12 @@ class MenuPageState extends State<MenuPage> {
);
}

static Widget accordion(String title, Widget icon, List<Widget> children) {
return Accordion(
headerBackgroundColor: Colors.transparent,
contentBackgroundColor: OnlineTheme.current.card,
contentBorderWidth: 0,
contentHorizontalPadding: 0,
leftIcon: icon,
scaleWhenAnimating: false,
headerPadding: EdgeInsets.zero,
paddingListTop: 0,
paddingListBottom: 0,
paddingListHorizontal: 0,
paddingBetweenClosedSections: 0,
initialOpeningSequenceDelay: 0,
disableScrolling: true,
openAndCloseAnimation: true,
paddingBetweenOpenSections: 0,
contentVerticalPadding: 0,
children: [
AccordionSection(
header: Text(title, style: OnlineTheme.textStyle()),
content: Column(
children: children,
),
),
],
);
}

Widget helpAndSupportCard() {
return OnlineCard(
child: accordion(
"Hjelp og Støtte",
Lucide(LucideIcon.users, size: 24),
[
child: Foldout(
title: "Hjelp og Støtte",
leading: Padding(padding: EdgeInsets.only(right: 16), child: Lucide(LucideIcon.users, size: 24)),
children: [
const SizedBox(height: 16),
Row(
children: [
Expand Down Expand Up @@ -242,10 +283,10 @@ class MenuPageState extends State<MenuPage> {

Widget settingsAndPrivacyCard() {
return OnlineCard(
child: accordion(
'Din Data',
Lucide(LucideIcon.database, size: 24),
[
child: Foldout(
title: 'Din Data',
leading: Padding(padding: EdgeInsets.only(right: 16), child: Lucide(LucideIcon.database, size: 24)),
children: [
const SizedBox(height: 16),
AnimatedButton(onTap: () {
io.Client.launchInBrowser('https://online.ntnu.no/profile/settings/userdata');
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/menu/profile_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class ProfileCard extends StaticPage {
const SizedBox(width: 24),
ValueListenableBuilder(
valueListenable: Client.userCache,
builder: (contex, value, child) {
builder: (contex, user, child) {
return Text(
"${value?.firstName} ${value?.lastName}",
"${user?.firstName} ${user?.lastName}",
style: OnlineTheme.textStyle(),
);
},
Expand Down
50 changes: 35 additions & 15 deletions lib/pages/menu/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,42 @@ class SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
return OnlineCard(
child: MenuPageState.accordion(
"Varslinger",
Lucide(LucideIcon.notification, size: 24),
eventCategories.keys.map((String key) {
return CheckboxListTile(
title: Text(key, style: OnlineTheme.textStyle()),
value: eventCategories[key],
activeColor: OnlineTheme.current.pos,
checkColor: OnlineTheme.current.fg,
contentPadding: EdgeInsets.zero,
onChanged: (bool? value) {
_handleSubscription(key, value);
},
);
}).toList(),
child: Foldout(
leading: Padding(padding: EdgeInsets.only(right: 16), child: Lucide(LucideIcon.notification, size: 24)),
title: 'Varslinger',
children: eventCategories.keys.map(
(String key) {
return CheckboxListTile(
title: Text(key, style: OnlineTheme.textStyle()),
value: eventCategories[key],
activeColor: OnlineTheme.current.pos,
checkColor: OnlineTheme.current.fg,
contentPadding: EdgeInsets.zero,
onChanged: (bool? value) {
_handleSubscription(key, value);
},
);
},
).toList(),
),
);
// return OnlineCard(
// child: MenuPageState.accordion(
// "Varslinger",
// Lucide(LucideIcon.notification, size: 24),
// eventCategories.keys.map((String key) {
// return CheckboxListTile(
// title: Text(key, style: OnlineTheme.textStyle()),
// value: eventCategories[key],
// activeColor: OnlineTheme.current.pos,
// checkColor: OnlineTheme.current.fg,
// contentPadding: EdgeInsets.zero,
// onChanged: (bool? value) {
// _handleSubscription(key, value);
// },
// );
// }).toList(),
// ),
// );
}
}
8 changes: 6 additions & 2 deletions lib/services/authenticator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ abstract class Authenticator {
//final scheme = dotenv.env['AUTH0_CUSTOM_SCHEME'];
final response = await auth0!.webAuthentication(scheme: dotenv.env['AUTH0_CUSTOM_SCHEME']).login();
await auth0!.credentialsManager.storeCredentials(response);
await Client.getUserProfile();

loggedIn.value = true;
return credentials = response;
credentials = response;

await Client.getUserProfile();

return response;
} catch (e) {
// User cancelled login
return null;
Expand Down
1 change: 1 addition & 0 deletions lib/theme/themed_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum LucideIcon {
bug,
database,
notification,
chevronDown,
}

class Lucide extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: online
description: Online App
publish_to: "none"
version: 1.1.0
version: 1.1.2

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down

0 comments on commit e660718

Please sign in to comment.