Skip to content

Commit

Permalink
Minor improvements and dialog fix on large screens (#7)
Browse files Browse the repository at this point in the history
Bugfix/ipad dialog
  • Loading branch information
thermitex committed Jun 11, 2024
2 parents c67cb32 + 8fd8185 commit 47a1923
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 65 deletions.
10 changes: 4 additions & 6 deletions lib/src/common/services/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,18 @@ class Constants {
static const kLearnMore = 'Learn more';
static const kAboutTitle = 'About';
static const kTipTitle = 'Tip Jar';
static const kAccountLearnMoreUrl =
'https://thermitex.github.io/cuckoo/auth/';
static const kAccountLearnMoreUrl = 'https://cuckoo-hku.xyz/safety/';
static const kCheckGithub = 'Check repo on Github';
static const kAboutWebsiteTitle = 'Project Website';
static const kAboutWebsiteUrl = 'https://thermitex.github.io/cuckoo/';
static const kAboutWebsiteUrl = 'https://cuckoo-hku.xyz/';
static const kAboutDiscordTitle = 'Discord Community';
static const kAboutDiscordContent =
'Join our Discord community to leave your thoughts and receive latest updates.';
static const kAboutDiscordUrl = 'https://discord.gg/K9scQKDF';
static const kAboutPrivacyTitle = 'Privacy Policy';
static const kAboutPrivacyUrl = 'https://thermitex.github.io/cuckoo/privacy/';
static const kAboutPrivacyUrl = 'https://cuckoo-hku.xyz/privacy/';
static const kAboutSoftwareLicense = 'Software Licenses';
static const kAboutSoftwareLicenseUrl =
'https://thermitex.github.io/cuckoo/license/';
static const kAboutSoftwareLicenseUrl = 'https://cuckoo-hku.xyz/license/';
static const kProjectGithubUrl =
'https://github.com/thermitex/cuckoo-flutter';
static const kTipJarTitle =
Expand Down
8 changes: 8 additions & 0 deletions lib/src/common/services/moodle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ class Moodle {
static Future<bool> fetchCourses({bool saveNow = true}) async {
final moodle = Moodle();
if (!isUserLoggedIn) return false;
// Abort if already fetching on one thread
if (moodle.courseManager.status == MoodleManagerStatus.updating) {
return false;
}
moodle.courseManager.status = MoodleManagerStatus.updating;
final response =
await callFunction(MoodleFunctions.getEnrolledCourses, params: {
Expand Down Expand Up @@ -391,6 +395,10 @@ class Moodle {
final moodle = Moodle();

if (!isUserLoggedIn) return false;
// Abort if already fetching on one thread
if (moodle.eventManager.status == MoodleManagerStatus.updating) {
return false;
}
// Check if fetches are too close
if (!force && moodle.eventManager._eventsLastUpdated != null) {
final diff =
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/services/moodle_extra.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extension MoodleEventExtension on MoodleEvent {
..id = DateTime.now().secondEpoch
..name = ''
..description = ''
..timestart = DateTime.now().secondEpoch
..timestart = DateTime.now().secondEpoch + 3600
..eventtype = MoodleEventTypes.custom
..hascompletion = false;
return event;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/ui/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CuckooLargeAppBar extends StatelessWidget implements PreferredSizeWidget {
Widget _titleWidget() {
return Text(
title,
style: TextStylePresets.title(size: 32),
style: TextStylePresets.title(size: 31.5),
);
}

Expand Down
117 changes: 61 additions & 56 deletions lib/src/common/ui/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,70 +41,75 @@ class CuckooDialog {
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
backgroundColor: context.cuckooTheme.popUpBackground,
child: Container(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 85.0),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Center(
child: Column(mainAxisSize: MainAxisSize.min, children: [
Text(
title,
textAlign: TextAlign.center,
style: TextStylePresets.popUpDisplayBody(
weight: FontWeight.w500),
),
if (description != null) const SizedBox(height: 10.0),
if (description != null)
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 350),
child: Container(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 85.0),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Center(
child: Column(mainAxisSize: MainAxisSize.min, children: [
Text(
description!,
style: TextStylePresets.body(),
title,
textAlign: TextAlign.center,
style: TextStylePresets.popUpDisplayBody(
weight: FontWeight.w500),
),
]),
if (description != null) const SizedBox(height: 10.0),
if (description != null)
Text(
description!,
style: TextStylePresets.body(),
),
]),
),
),
),
),
const SizedBox(height: 15.0),
if (buttonAlignment == DialogButtonAlignment.horizontal)
Row(
children: List.generate(buttonTitles.length * 2 - 1, (index) {
if (index % 2 == 1) {
return const SizedBox(width: 18.0);
} else {
final i = index ~/ 2;
return Expanded(
child: CuckooButton(
const SizedBox(height: 15.0),
if (buttonAlignment == DialogButtonAlignment.horizontal)
Row(
children:
List.generate(buttonTitles.length * 2 - 1, (index) {
if (index % 2 == 1) {
return const SizedBox(width: 18.0);
} else {
final i = index ~/ 2;
return Expanded(
child: CuckooButton(
text: buttonTitles[i],
style: buttonStyles[i],
height: 44.0,
action: () => Navigator.of(context).pop(i),
),
);
}
}),
)
else
Column(
mainAxisSize: MainAxisSize.min,
children:
List.generate(buttonTitles.length * 2 - 1, (index) {
if (index % 2 == 1) {
return const SizedBox(width: 18.0);
} else {
final i = index ~/ 2;
return CuckooButton(
text: buttonTitles[i],
style: buttonStyles[i],
height: 44.0,
action: () => Navigator.of(context).pop(i),
),
);
}
}),
)
else
Column(
mainAxisSize: MainAxisSize.min,
children: List.generate(buttonTitles.length * 2 - 1, (index) {
if (index % 2 == 1) {
return const SizedBox(width: 18.0);
} else {
final i = index ~/ 2;
return CuckooButton(
text: buttonTitles[i],
style: buttonStyles[i],
height: 44.0,
action: () => Navigator.of(context).pop(i),
);
}
}),
)
],
);
}
}),
)
],
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/routes/settings/settings_topbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SettingsTopBar extends StatelessWidget implements PreferredSizeWidget {
minFontSize: 22,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStylePresets.title(size: 30).copyWith(height: 1.1),
style: TextStylePresets.title(size: 29).copyWith(height: 1.1),
);

final username = Container(
Expand Down

0 comments on commit 47a1923

Please sign in to comment.