Skip to content

Commit

Permalink
⚡ Controlled Lottie Animations and Build Optimizations.
Browse files Browse the repository at this point in the history
- Added Icon for animation option in settings
- Reverted `my_application.cc` (although the previous change by @ZhymabekRoman fixes deprecation but that the app cannot be made to launch on operating systems like Ubuntu on Wayland because of assertion problem in the gdk library)
- Lottie Animations now obey app wide animation settings.
  • Loading branch information
omegaui committed Jan 2, 2024
1 parent 267bbf1 commit a32685f
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 22 deletions.
Binary file added assets/icons/settings/animations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:cliptopia/app/clipboard/presentation/widgets/download_button.dar
import 'package:cliptopia/config/assets/app_animations.dart';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/backdrop_panel.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
Expand Down Expand Up @@ -132,6 +133,10 @@ class _ClipboardDaemonIntegrationStateViewState
Lottie.asset(
AppAnimations.downloading,
width: 100,
animate: Storage.get(
StorageKeys.animationEnabledKey,
fallback:
StorageValues.defaultAnimationEnabledKey),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/database/database.dart';
import 'package:cliptopia/core/search_engine.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/backdrop_panel.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
Expand Down Expand Up @@ -132,6 +133,8 @@ class _ClipboardEmptyStateViewState extends State<ClipboardEmptyStateView> {
AppAnimations.getEmptyAnimationOnCause(widget.cause),
fit: BoxFit.fitWidth,
repeat: widget.cause != EmptyCause.noImageElements,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:cliptopia/config/assets/app_animations.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -36,7 +37,11 @@ class ClipboardLoadingStateView extends StatelessWidget {
child: Stack(
children: [
Align(
child: Lottie.asset(AppAnimations.loading),
child: Lottie.asset(
AppAnimations.loading,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
const Align(
alignment: Alignment.topCenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/database/database.dart';
import 'package:cliptopia/core/search_engine.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/core/utils.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/backdrop_panel.dart';
Expand Down Expand Up @@ -125,6 +126,8 @@ class _CommandsEmptyStateViewState extends State<CommandsEmptyStateView> {
child: Lottie.asset(
AppAnimations.getEmptyAnimationOnCause(widget.cause),
fit: BoxFit.fitWidth,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/database/database.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -65,6 +66,8 @@ class _EmojisEmptyStateViewState extends State<EmojisEmptyStateView> {
child: Lottie.asset(
AppAnimations.emojis,
fit: BoxFit.fitWidth,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/database/database.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -80,6 +81,8 @@ class _EmojisInitializedStateViewState
AppAnimations.emojis,
width: 200,
fit: BoxFit.fitWidth,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:cliptopia/config/assets/app_animations.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/top_bar.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -35,6 +36,8 @@ class EmojisLoadingStateView extends StatelessWidget {
AppAnimations.emojis,
width: 200,
reverse: true,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
const Align(
Expand Down
3 changes: 3 additions & 0 deletions lib/app/notes/presentation/states/notes_empty_state_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/database/database.dart';
import 'package:cliptopia/core/search_engine.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/core/utils.dart';
import 'package:cliptopia/widgets/app_close_button.dart';
import 'package:cliptopia/widgets/topbar/backdrop_panel.dart';
Expand Down Expand Up @@ -126,6 +127,8 @@ class _NotesEmptyStateViewState extends State<NotesEmptyStateView> {
AppAnimations.getEmptyAnimationOnCause(widget.cause),
fit: BoxFit.fitWidth,
repeat: widget.cause != EmptyCause.noNoteElements,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class _DaemonManagerDialogState extends State<DaemonManagerDialog> {
Lottie.asset(
AppAnimations.downloading,
width: 300,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
Text(
"Downloading Cliptopia Daemon",
Expand Down Expand Up @@ -181,6 +183,8 @@ class _DaemonManagerDialogState extends State<DaemonManagerDialog> {
Lottie.asset(
AppAnimations.connection,
width: 250,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
Text(
"Please integrate the Cliptopia Daemon",
Expand Down Expand Up @@ -224,6 +228,8 @@ class _DaemonManagerDialogState extends State<DaemonManagerDialog> {
AppAnimations.sleeping,
width: 250,
filterQuality: FilterQuality.high,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
Text(
"Looks like your cliptopia-daemon is not running",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class _CommandPanelState extends State<CommandPanel> {
child: Lottie.asset(
AppAnimations.commandsEmpty,
width: 200,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:cliptopia/app/powermode/domain/entity/typedefs.dart';
import 'package:cliptopia/app/powermode/presentation/panels/widgets/file_card.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/config/assets/app_animations.dart';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/powermode/power_data_handler.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
Expand Down Expand Up @@ -128,6 +128,8 @@ class _FilePanelState extends State<FilePanel> {
AppAnimations.filesEmpty,
width: 200,
repeat: false,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:cliptopia/app/powermode/domain/entity/typedefs.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/app/powermode/presentation/panels/widgets/text_card.dart';
import 'package:cliptopia/config/assets/app_animations.dart';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/powermode/power_data_handler.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
Expand Down Expand Up @@ -117,6 +117,8 @@ class _TextPanelState extends State<TextPanel> {
AppAnimations.notesEmpty,
width: 200,
repeat: false,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
Text(
Expand Down
2 changes: 2 additions & 0 deletions lib/app/powermode/presentation/panels/images_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class _ImagesPanelState extends State<ImagesPanel> {
AppAnimations.imagesEmpty,
width: 175,
repeat: false,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
),
],
Expand Down
1 change: 0 additions & 1 deletion lib/app/powermode/presentation/panels/search_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:cliptopia/app/powermode/presentation/dialogs/daemon_manager_dial
import 'package:cliptopia/app/powermode/presentation/dialogs/power_mode_settings.dart';
import 'package:cliptopia/app/powermode/presentation/panels/widgets/date_filter.dart';
import 'package:cliptopia/app/powermode/presentation/panels/widgets/power_search_field.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/powermode/power_data_handler.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:cliptopia/app/filter/presentation/widgets/filter_dialog_button.dart';
import 'package:cliptopia/app/powermode/domain/entity/typedefs.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/constants/typedefs.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ class _SettingsInitializedStateViewState
),
),
Option(
title: "Enable animations",
description: "Toggle this to enable or disable animations",
title: "App Animations",
description:
"Toggle animations for motion sensitive eyes, or other problems",
active: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey) ==
StorageValues.defaultAnimationEnabledKey,
icon: AppIcons.animation,
icon: AppIcons.animations,
onChanged: (enabled) {
setState(() {
Storage.set(StorageKeys.animationEnabledKey, enabled);
Expand Down Expand Up @@ -607,7 +608,12 @@ class _SettingsInitializedStateViewState
SizedBox(
width: MediaQuery.of(context).size.width,
),
Lottie.asset(AppAnimations.shield, width: 300),
Lottie.asset(
AppAnimations.shield,
width: 300,
animate: Storage.get(StorageKeys.animationEnabledKey,
fallback: StorageValues.defaultAnimationEnabledKey),
),
Text(
"No content filter detected, looks like you also removed the default ones\nPlease not that any password or key you copy will be watched",
textAlign: TextAlign.center,
Expand Down
2 changes: 1 addition & 1 deletion lib/config/assets/app_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppIcons {
static const correct = 'assets/icons/settings/correct.png';
static const incorrect = 'assets/icons/settings/incorrect.png';
static const theme = 'assets/icons/settings/theme.png';
static const animations = 'assets/icons/settings/animations.png';

// Power Mode
static const copyLight = 'assets/icons/power-mode/copy-light.png';
Expand Down Expand Up @@ -74,5 +75,4 @@ class AppIcons {
static const cache = 'assets/icons/cache.png';
static const magic = 'assets/icons/magic.png';
static const appIcon = 'assets/icons/app-icon.png';
static const animation = 'assets/icons/app-icon.png'; // TODO
}
1 change: 0 additions & 1 deletion lib/core/search_engine.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:cliptopia/constants/typedefs.dart';
import 'package:cliptopia/core/logger.dart';

class SearchEngine {
String _searchText = "";
Expand Down
3 changes: 2 additions & 1 deletion lib/core/storage/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class StorageValues {

static const defaultViewMode = 'default';
static const backgroundViewMode = 'background';
static const defaultCliptopiaPath = 'cliptopia';
static const defaultCliptopiaPath =
'/usr/bin/cliptopia'; // manual installer default
static const defaultAnimationEnabledKey = true;
}
19 changes: 14 additions & 5 deletions lib/widgets/topbar/power_mode_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'dart:io';
import 'package:cliptopia/config/assets/app_icons.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/app_session.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:cliptopia/core/powermode/power_utils.dart';
import 'package:cliptopia/core/services/injector.dart';
import 'package:cliptopia/core/storage/storage.dart';
import 'package:flutter/material.dart';

class PowerModeButton extends StatefulWidget {
Expand Down Expand Up @@ -39,11 +39,20 @@ class _PowerModeButtonState extends State<PowerModeButton> {
fallback: StorageValues.defaultCliptopiaPath);
if (await FileSystemEntity.type(cliptopiaPath) ==
FileSystemEntityType.notFound) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
void notify() {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'The Cliptopia executable was not found at $cliptopiaPath. You might be running Cliptopia in development mode.')),
);
'The Cliptopia executable was not found at $cliptopiaPath.\nYou might be running Cliptopia in development mode.'
'\nIf not installed from source, you should create a link to the executable (`/usr/bin/cliptopia`)',
style: AppTheme.fontSize(14).withColor(AppTheme.background),
),
showCloseIcon: true,
),
);
}

notify();
} else {
await Process.start(cliptopiaPath, ['--silent', '--power']);
Injector.find<AppSession>().endSession();
Expand Down
9 changes: 4 additions & 5 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ static void my_application_activate(GApplication* application) {
gtk_window_set_resizable(window, FALSE);

if (global_argv != NULL &&
hasFlag("--silent", length, global_argv) &&
hasFlag("--power", length, global_argv)) {
GdkDisplay* display = gdk_display_get_default();
GdkMonitor* monitor = gdk_display_get_primary_monitor(display);
hasFlag("--silent", length, global_argv) &&
hasFlag("--power", length, global_argv)) {
GdkScreen* screen = gtk_window_get_screen(window);
GdkRectangle monitor_rect;
gdk_monitor_get_geometry(monitor, &monitor_rect);
gdk_screen_get_monitor_geometry(screen, 0, &monitor_rect);
gtk_window_set_default_size(window, monitor_rect.width, monitor_rect.height);
} else {
gtk_window_set_default_size(window, 750, 650);
Expand Down

0 comments on commit a32685f

Please sign in to comment.