Skip to content

Commit

Permalink
chore: split constants file (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Nov 25, 2024
1 parent d6f99f3 commit 110099a
Show file tree
Hide file tree
Showing 54 changed files with 250 additions and 287 deletions.
2 changes: 1 addition & 1 deletion lib/app/view/desktop_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:yaru/yaru.dart';
import '../../app_config.dart';
import '../../common/view/snackbars.dart';
import '../../common/view/theme.dart';
import '../../constants.dart';
import '../../common/view/ui_constants.dart';
import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
import '../../patch_notes/patch_notes_dialog.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/app/view/master_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../../common/view/back_gesture.dart';
import '../../common/view/global_keys.dart';
import '../../common/view/header_bar.dart';
import '../../common/view/icons.dart';
import '../../common/view/ui_constants.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../library/library_model.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/app/view/master_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../common/data/audio_type.dart';
import '../../common/view/ui_constants.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../library/library_model.dart';
Expand Down
7 changes: 3 additions & 4 deletions lib/common/view/audio_page_header.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../extensions/theme_data_x.dart';
import '../../l10n/l10n.dart';
import 'ui_constants.dart';

class AudioPageHeader extends StatelessWidget {
const AudioPageHeader({
Expand Down Expand Up @@ -37,7 +36,7 @@ class AudioPageHeader extends StatelessWidget {
final radius = imageRadius ?? BorderRadius.circular(10);

return Padding(
padding: const EdgeInsets.only(bottom: kYaruPagePadding),
padding: const EdgeInsets.only(bottom: kLargestSpace),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expand All @@ -63,7 +62,7 @@ class AudioPageHeader extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 5),
padding: const EdgeInsets.only(top: kLargestSpace, bottom: 5),
child: Text(
title,
style: theme.pageHeaderStyle,
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/audio_page_header_html_description.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../constants.dart';
import 'ui_constants.dart';
import '../../extensions/build_context_x.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
Expand All @@ -21,7 +21,7 @@ class AudioPageHeaderHtmlDescription extends StatelessWidget {
Widget build(BuildContext context) {
final descriptionStyle = context.theme.pageHeaderDescription;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: kYaruPagePadding),
padding: const EdgeInsets.symmetric(horizontal: kLargestSpace),
child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: kAudioHeaderDescriptionWidth,
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../constants.dart';
import 'ui_constants.dart';
import '../../extensions/build_context_x.dart';
import '../../extensions/duration_x.dart';
import '../../extensions/theme_data_x.dart';
Expand Down Expand Up @@ -108,7 +108,7 @@ class _AudioTileState extends State<AudioTile> {
}
},
title: Padding(
padding: const EdgeInsets.only(right: kYaruPagePadding),
padding: const EdgeInsets.only(right: kLargestSpace),
child: widget.onTitleTap == null
? Text(
widget.audio.title ?? l10n.unknown,
Expand Down
5 changes: 3 additions & 2 deletions lib/common/view/audio_tile_bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:collection/collection.dart';

import 'ui_constants.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
Expand Down Expand Up @@ -77,7 +78,7 @@ class AudioTileBottomSheet extends StatelessWidget {
: null,
),
const SpacedDivider(
bottom: 20,
bottom: kLargestSpace,
top: 10,
left: 0,
right: 0,
Expand Down Expand Up @@ -174,7 +175,7 @@ class AudioTileBottomSheet extends StatelessWidget {
if (audios.first.audioType != AudioType.radio)
Expanded(
child: Padding(
padding: const EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.only(bottom: kLargestSpace),
child: ListView(
shrinkWrap: true,
children: [
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/audio_tile_image.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import '../../constants.dart';
import 'ui_constants.dart';
import '../../local_audio/view/local_cover.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
Expand Down
3 changes: 2 additions & 1 deletion lib/common/view/fall_back_header_image.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import '../../extensions/build_context_x.dart';
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../extensions/build_context_x.dart';

class FallBackHeaderImage extends StatelessWidget {
const FallBackHeaderImage({
super.key,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/mpv_metadata_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:yaru/yaru.dart';

import '../../constants.dart';
import 'ui_constants.dart';
import '../data/mpv_meta_data.dart';
import 'icons.dart';
import 'modals.dart';
Expand Down
3 changes: 2 additions & 1 deletion lib/common/view/offline_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:yaru/yaru.dart';
import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
import 'header_bar.dart';
import 'ui_constants.dart';

class OfflinePage extends StatelessWidget {
const OfflinePage({super.key, this.action});
Expand Down Expand Up @@ -45,7 +46,7 @@ class OfflineBody extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.only(
top: kYaruPagePadding,
top: kLargestSpace,
left: 40,
right: 40,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/sliver_audio_page_control_panel.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:yaru/constants.dart';

import '../../extensions/build_context_x.dart';
import 'ui_constants.dart';

class SliverAudioPageControlPanel extends StatelessWidget {
const SliverAudioPageControlPanel({
Expand Down Expand Up @@ -29,7 +29,7 @@ class SliverAudioPageControlPanel extends StatelessWidget {
centerTitle: true,
titleSpacing: 0,
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: kYaruPagePadding),
padding: const EdgeInsets.symmetric(horizontal: kLargestSpace),
child: controlPanel,
),
bottom: const _Space(),
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/sliver_audio_tile_list.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../constants.dart';
import 'ui_constants.dart';
import '../../player/player_model.dart';
import '../data/audio.dart';
import 'audio_page_type.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/common/view/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../app_config.dart';
import '../../constants.dart';
import 'ui_constants.dart';
import 'icons.dart';

ThemeData? yaruDarkWithTweaks(YaruThemeData yaru) {
Expand Down Expand Up @@ -209,7 +209,7 @@ double get iconSize => yaruStyled
? kYaruIconSize
: isMobile
? 24.0
: 20.0;
: kLargestSpace;

double get sideBarImageSize => 38;

Expand Down Expand Up @@ -255,7 +255,7 @@ SliverGridDelegate get audioCardGridDelegate =>

EdgeInsets get appBarSingleActionSpacing => Platform.isMacOS
? const EdgeInsets.only(right: 5, left: 5)
: EdgeInsets.only(right: 10, left: isMobile ? 0 : 20);
: EdgeInsets.only(right: 10, left: isMobile ? 0 : kLargestSpace);

EdgeInsetsGeometry get radioHistoryListPadding =>
EdgeInsets.only(left: yaruStyled ? 0 : 5);
Expand Down
100 changes: 100 additions & 0 deletions lib/common/view/ui_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';

const kLargestSpace = 20.0;

const kMediumSpace = 10.0;

const kSmallestSpace = 5.0;

const kTinyButtonSize = 30.0;

const kTinyButtonIconSize = 13.0;

const kDesktopSearchBarWidth = 335.0;

const kMobileSearchBarWidth = 270.0;

const kSnackBarWidth = 500.0;

const fullHeightPlayerImageSize = 300.0;

const kMaxAudioPageHeaderHeight = 200.0;

const kMinAudioPageHeaderHeight = 0.0;

const kSnackBarDuration = Duration(seconds: 10);

const kAudioTilePadding = EdgeInsets.symmetric(horizontal: 10);

const kAudioTileTrackPadding = EdgeInsets.only(right: kLargestSpace);

const kAudioTileSpacing = EdgeInsets.only(right: 10.0);

const kAudioTrackWidth = 40.0;

const kSideBarThreshHold = 1500.0;

const kSideBarPlayerWidth = 500.0;

const kGridPadding = EdgeInsets.only(
top: 0,
bottom: kLargestSpace,
left: kLargestSpace - 5,
right: kLargestSpace - 5,
);
const kMobileGridPadding = EdgeInsets.only(
top: 0,
bottom: kLargestSpace,
left: kLargestSpace - 5,
right: kLargestSpace - 5,
);

const kHeaderPadding = EdgeInsets.only(
top: kLargestSpace,
left: kLargestSpace,
right: kLargestSpace,
bottom: kLargestSpace - 5,
);

const kAudioCardDimension = 130.0;

const kAudioCardBottomHeight = 30.0;

const kMasterDetailBreakPoint = 720.0;

const kMasterDetailSideBarWidth = 250.0;

const kAdaptivContainerBreakPoint = 1200.0;

const kAudioCardGridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: kAudioCardDimension + 40,
mainAxisExtent: kAudioCardDimension + kAudioCardBottomHeight + 8,
mainAxisSpacing: 0,
crossAxisSpacing: 10,
);

const kMobileAudioCardGridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: kAudioCardDimension,
mainAxisExtent: kAudioCardDimension + kAudioCardBottomHeight + 5,
mainAxisSpacing: 0,
crossAxisSpacing: 10,
);

const kDiskGridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: kAudioCardDimension + 10,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
);

const kAudioControlPanelPadding = EdgeInsets.only(
top: kLargestSpace / 2,
left: kLargestSpace,
right: kLargestSpace,
bottom: kLargestSpace / 2,
);

const kMainPageIconPadding = EdgeInsets.only(right: 4.0);

const kAudioHeaderDescriptionWidth = 400.0;

const kShowLeadingThreshold = 3000;
Loading

0 comments on commit 110099a

Please sign in to comment.