feat: workspace scaffold with iced shell, theme and design system
Two-crate workspace (ym-api for the API client, musyx for the iced app). The app has the sidebar, top bar, Queue/Lyrics drawer and player bar from the approved mockup, plus signed-out states for every screen. - DESIGN.md records the mockup tokens; ui/theme.rs mirrors them for dark and light, and the app follows the system appearance - Bundles Onest/Unbounded (OFL) and Lucide 0.460 icons (ISC) - Back-stack navigator, player bar toggles (shuffle, repeat, volume, mute) - snapshot feature renders a screen to PNG via iced's window screenshot
No files matched your search
@@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "musyx"
|
||||
description = "Desktop player for Yandex Music"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
ym-api = { path = "../ym-api" }
|
||||
iced = { version = "0.14.0", features = ["svg", "image", "tokio", "advanced"] }
|
||||
png = { version = "0.18.1", optional = true }
|
||||
tokio = { version = "1", features = ["time"], optional = true }
|
||||
|
||||
[features]
|
||||
# `MUSYX_SNAPSHOT=out.png cargo run --features snapshot` renders one screen to a PNG and exits.
|
||||
snapshot = ["dep:png", "dep:tokio"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2021 The Onest Project Authors (https://github.com/googlefonts/onest)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2022 The Unbounded Project Authors (https://github.com/googlefonts/unbounded)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -0,0 +1,20 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-audio-lines"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M2 10v3" />
|
||||
<path d="M6 6v11" />
|
||||
<path d="M10 3v18" />
|
||||
<path d="M14 8v7" />
|
||||
<path d="M18 5v13" />
|
||||
<path d="M22 10v3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 432 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-ban"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="m4.9 4.9 14.2 14.2" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 353 B |
@@ -0,0 +1,15 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-chevron-left"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m15 18-6-6 6-6" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 322 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-clock-3"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<polyline points="12 6 12 12 16.5 12" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 366 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-copy"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
||||
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 415 B |
@@ -0,0 +1,18 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-disc-3"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M6 12c0-1.7.7-3.2 1.8-4.2" />
|
||||
<circle cx="12" cy="12" r="2" />
|
||||
<path d="M18 12c0 1.7-.7 3.2-1.8 4.2" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 441 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-ellipsis"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<circle cx="19" cy="12" r="1" />
|
||||
<circle cx="5" cy="12" r="1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 392 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-globe"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" />
|
||||
<path d="M2 12h20" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 408 B |
@@ -0,0 +1,20 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-grip-vertical"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="9" cy="12" r="1" />
|
||||
<circle cx="9" cy="5" r="1" />
|
||||
<circle cx="9" cy="19" r="1" />
|
||||
<circle cx="15" cy="12" r="1" />
|
||||
<circle cx="15" cy="5" r="1" />
|
||||
<circle cx="15" cy="19" r="1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 498 B |
@@ -0,0 +1,15 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-heart"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 445 B |
@@ -0,0 +1,15 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-heart"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 437 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-house"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" />
|
||||
<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 468 B |
@@ -0,0 +1,18 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-library"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m16 6 4 14" />
|
||||
<path d="M12 6v14" />
|
||||
<path d="M8 8v12" />
|
||||
<path d="M4 4v16" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 383 B |
@@ -0,0 +1,19 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-list-music"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M21 15V6" />
|
||||
<path d="M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z" />
|
||||
<path d="M12 12H3" />
|
||||
<path d="M16 6H3" />
|
||||
<path d="M12 18H3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 446 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-lock"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect width="18" height="11" x="3" y="11" rx="2" ry="2" />
|
||||
<path d="M7 11V7a5 5 0 0 1 10 0v4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 385 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-log-out"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
|
||||
<polyline points="16 17 21 12 16 7" />
|
||||
<line x1="21" x2="9" y1="12" y2="12" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 425 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-mic-vocal"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12" />
|
||||
<path d="M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5" />
|
||||
<circle cx="16" cy="7" r="5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 526 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-pause"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="14" y="4" width="4" height="16" rx="1" />
|
||||
<rect x="6" y="4" width="4" height="16" rx="1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 398 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-pause"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="14" y="4" width="4" height="16" rx="1" />
|
||||
<rect x="6" y="4" width="4" height="16" rx="1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 390 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-pencil"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />
|
||||
<path d="m15 5 4 4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 455 B |
@@ -0,0 +1,15 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-play"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polygon points="6 3 20 12 6 21 6 3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 334 B |
@@ -0,0 +1,15 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-play"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polygon points="6 3 20 12 6 21 6 3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 326 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-plus"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M5 12h14" />
|
||||
<path d="M12 5v14" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
@@ -0,0 +1,18 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-podcast"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M16.85 18.58a9 9 0 1 0-9.7 0" />
|
||||
<path d="M8 14a5 5 0 1 1 8 0" />
|
||||
<circle cx="12" cy="11" r="1" />
|
||||
<path d="M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 460 B |
@@ -0,0 +1,19 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-repeat-1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m17 2 4 4-4 4" />
|
||||
<path d="M3 11v-1a4 4 0 0 1 4-4h14" />
|
||||
<path d="m7 22-4-4 4-4" />
|
||||
<path d="M21 13v1a4 4 0 0 1-4 4H3" />
|
||||
<path d="M11 10h1v4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 453 B |
@@ -0,0 +1,18 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-repeat"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m17 2 4 4-4 4" />
|
||||
<path d="M3 11v-1a4 4 0 0 1 4-4h14" />
|
||||
<path d="m7 22-4-4 4-4" />
|
||||
<path d="M21 13v1a4 4 0 0 1-4 4H3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 425 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-search"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="11" r="8" />
|
||||
<path d="m21 21-4.3-4.3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 351 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-settings"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 904 B |
@@ -0,0 +1,19 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-shuffle"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22" />
|
||||
<path d="m18 2 4 4-4 4" />
|
||||
<path d="M2 6h1.9c1.5 0 2.9.9 3.6 2.2" />
|
||||
<path d="M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8" />
|
||||
<path d="m18 14 4 4-4 4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 524 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-skip-back"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polygon points="19 20 9 12 19 4 19 20" />
|
||||
<line x1="5" x2="5" y1="19" y2="5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 374 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-skip-forward"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polygon points="5 4 15 12 5 20 5 4" />
|
||||
<line x1="19" x2="19" y1="5" y2="19" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 376 B |
@@ -0,0 +1,23 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-sliders-horizontal"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<line x1="21" x2="14" y1="4" y2="4" />
|
||||
<line x1="10" x2="3" y1="4" y2="4" />
|
||||
<line x1="21" x2="12" y1="12" y2="12" />
|
||||
<line x1="8" x2="3" y1="12" y2="12" />
|
||||
<line x1="21" x2="16" y1="20" y2="20" />
|
||||
<line x1="12" x2="3" y1="20" y2="20" />
|
||||
<line x1="14" x2="14" y1="2" y2="6" />
|
||||
<line x1="8" x2="8" y1="10" y2="14" />
|
||||
<line x1="16" x2="16" y1="18" y2="22" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 673 B |
@@ -0,0 +1,19 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-trash-2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M3 6h18" />
|
||||
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
|
||||
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
|
||||
<line x1="10" x2="10" y1="11" y2="17" />
|
||||
<line x1="14" x2="14" y1="11" y2="17" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 499 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-volume-2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z" />
|
||||
<path d="M16 9a5 5 0 0 1 0 6" />
|
||||
<path d="M19.364 18.364a9 9 0 0 0 0-12.728" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 556 B |
@@ -0,0 +1,17 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-volume-x"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z" />
|
||||
<line x1="22" x2="16" y1="9" y2="15" />
|
||||
<line x1="16" x2="22" y1="9" y2="15" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 556 B |
@@ -0,0 +1,16 @@
|
||||
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||
<svg
|
||||
class="lucide lucide-x"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M18 6 6 18" />
|
||||
<path d="m6 6 12 12" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 333 B |
@@ -0,0 +1,140 @@
|
||||
//! Application state, messages and the window layout.
|
||||
|
||||
use iced::theme::Mode;
|
||||
use iced::widget::{column, container, row, scrollable, space};
|
||||
use iced::{Element, Fill, Subscription, Task, Theme};
|
||||
|
||||
use crate::route::{Navigator, Route};
|
||||
use crate::screens;
|
||||
use crate::ui::theme::{self, shell};
|
||||
use crate::widgets::drawer::{self, Panel};
|
||||
use crate::widgets::player_bar::{self, PlayerUi};
|
||||
use crate::widgets::{sidebar, topbar};
|
||||
|
||||
pub struct App {
|
||||
theme: Theme,
|
||||
/// Set by a snapshot run so the system appearance can't override it.
|
||||
forced_mode: Option<Mode>,
|
||||
nav: Navigator,
|
||||
search: String,
|
||||
drawer: Option<Panel>,
|
||||
player: PlayerUi,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
ThemeChanged(Mode),
|
||||
Navigate(Route),
|
||||
Back,
|
||||
SearchChanged(String),
|
||||
SearchSubmitted,
|
||||
ToggleDrawer(Panel),
|
||||
CloseDrawer,
|
||||
Player(player_bar::Action),
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> (Self, Task<Message>) {
|
||||
let app = Self {
|
||||
theme: theme::for_mode(Mode::Dark),
|
||||
forced_mode: None,
|
||||
nav: Navigator::new(Route::Home),
|
||||
search: String::new(),
|
||||
drawer: None,
|
||||
player: PlayerUi::default(),
|
||||
};
|
||||
let boot = iced::system::theme().map(Message::ThemeChanged);
|
||||
|
||||
#[cfg(feature = "snapshot")]
|
||||
if let Some(config) = crate::snapshot::Config::from_env() {
|
||||
let mut app = app;
|
||||
if let Some(route) = config.route {
|
||||
app.nav = Navigator::new(route);
|
||||
}
|
||||
app.drawer = config.drawer;
|
||||
app.forced_mode = config.mode;
|
||||
if let Some(mode) = config.mode {
|
||||
app.theme = theme::for_mode(mode);
|
||||
}
|
||||
return (app, Task::batch([boot, config.capture()]));
|
||||
}
|
||||
|
||||
(app, boot)
|
||||
}
|
||||
|
||||
pub fn title(&self) -> String {
|
||||
match self.nav.current() {
|
||||
Route::Home => "Musyx".into(),
|
||||
route => format!("{} · Musyx", route.label()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn theme(&self) -> Theme {
|
||||
self.theme.clone()
|
||||
}
|
||||
|
||||
pub fn subscription(&self) -> Subscription<Message> {
|
||||
iced::system::theme_changes().map(Message::ThemeChanged)
|
||||
}
|
||||
|
||||
pub fn update(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::ThemeChanged(mode) => {
|
||||
self.theme = theme::for_mode(self.forced_mode.unwrap_or(mode));
|
||||
}
|
||||
Message::Navigate(route) => self.nav.go(route),
|
||||
Message::Back => self.nav.back(),
|
||||
Message::SearchChanged(query) => self.search = query,
|
||||
Message::SearchSubmitted => self.nav.go(Route::Search),
|
||||
Message::ToggleDrawer(panel) => {
|
||||
self.drawer = if self.drawer == Some(panel) { None } else { Some(panel) };
|
||||
}
|
||||
Message::CloseDrawer => self.drawer = None,
|
||||
Message::Player(action) => self.player.apply(action),
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
pub fn view(&self) -> Element<'_, Message> {
|
||||
let t = theme::tokens(&self.theme);
|
||||
let route = self.nav.current();
|
||||
|
||||
let content = column![
|
||||
topbar::view(t, self.nav.can_go_back(), &self.search),
|
||||
scrollable(screens::view(t, route, &self.search))
|
||||
.height(Fill)
|
||||
.style(theme::scroll),
|
||||
]
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
let mut body = row![
|
||||
sidebar::view(t, route),
|
||||
vline(),
|
||||
content,
|
||||
]
|
||||
.height(Fill);
|
||||
|
||||
if let Some(panel) = self.drawer {
|
||||
body = body.push(vline()).push(drawer::view(t, panel));
|
||||
}
|
||||
|
||||
let window = column![
|
||||
body,
|
||||
hline(),
|
||||
container(player_bar::view(t, &self.player, self.drawer))
|
||||
.height(shell::PLAYER)
|
||||
.style(theme::panel),
|
||||
];
|
||||
|
||||
container(window).width(Fill).height(Fill).style(theme::app).into()
|
||||
}
|
||||
}
|
||||
|
||||
fn vline<'a>() -> Element<'a, Message> {
|
||||
container(space()).width(1).height(Fill).style(theme::divider).into()
|
||||
}
|
||||
|
||||
fn hline<'a>() -> Element<'a, Message> {
|
||||
container(space()).width(Fill).height(1).style(theme::divider).into()
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
mod app;
|
||||
mod route;
|
||||
mod screens;
|
||||
#[cfg(feature = "snapshot")]
|
||||
mod snapshot;
|
||||
mod ui;
|
||||
mod widgets;
|
||||
|
||||
use iced::{Size, window};
|
||||
|
||||
use app::App;
|
||||
use ui::theme;
|
||||
|
||||
fn main() -> iced::Result {
|
||||
let app = iced::application(App::new, App::update, App::view)
|
||||
.title(App::title)
|
||||
.theme(App::theme)
|
||||
.subscription(App::subscription)
|
||||
.default_font(theme::BODY)
|
||||
.window(window::Settings {
|
||||
size: Size::new(1280.0, 800.0),
|
||||
min_size: Some(Size::new(960.0, 620.0)),
|
||||
..window::Settings::default()
|
||||
})
|
||||
.centered();
|
||||
|
||||
theme::FONTS.into_iter().fold(app, |app, font| app.font(font)).run()
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
//! Every place the content area can show. Detail pages (album, artist, playlist)
|
||||
//! join this enum once they carry ids from the API.
|
||||
|
||||
use crate::ui::icons::Icon;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Route {
|
||||
Home,
|
||||
Wave,
|
||||
Search,
|
||||
Collection,
|
||||
Podcasts,
|
||||
Settings,
|
||||
SignIn,
|
||||
}
|
||||
|
||||
impl Route {
|
||||
/// Sidebar order.
|
||||
pub const NAV: [Route; 5] =
|
||||
[Route::Home, Route::Wave, Route::Search, Route::Collection, Route::Podcasts];
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Route::Home => "Home",
|
||||
Route::Wave => "My Wave",
|
||||
Route::Search => "Search",
|
||||
Route::Collection => "Collection",
|
||||
Route::Podcasts => "Podcasts",
|
||||
Route::Settings => "Settings",
|
||||
Route::SignIn => "Sign in",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn icon(self) -> Icon {
|
||||
match self {
|
||||
Route::Home => Icon::Home,
|
||||
Route::Wave => Icon::Wave,
|
||||
Route::Search => Icon::Search,
|
||||
Route::Collection => Icon::Library,
|
||||
Route::Podcasts => Icon::Podcast,
|
||||
Route::Settings => Icon::Settings,
|
||||
Route::SignIn => Icon::LogOut,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Back-stack navigation: the sidebar pushes, the back button pops.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Navigator {
|
||||
current: Route,
|
||||
history: Vec<Route>,
|
||||
}
|
||||
|
||||
impl Navigator {
|
||||
const MAX_HISTORY: usize = 50;
|
||||
|
||||
pub fn new(start: Route) -> Self {
|
||||
Self { current: start, history: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn current(&self) -> Route {
|
||||
self.current
|
||||
}
|
||||
|
||||
pub fn can_go_back(&self) -> bool {
|
||||
!self.history.is_empty()
|
||||
}
|
||||
|
||||
pub fn go(&mut self, route: Route) {
|
||||
if route == self.current {
|
||||
return;
|
||||
}
|
||||
if self.history.len() == Self::MAX_HISTORY {
|
||||
self.history.remove(0);
|
||||
}
|
||||
self.history.push(self.current);
|
||||
self.current = route;
|
||||
}
|
||||
|
||||
pub fn back(&mut self) {
|
||||
if let Some(previous) = self.history.pop() {
|
||||
self.current = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn back_returns_to_previous_route() {
|
||||
let mut nav = Navigator::new(Route::Home);
|
||||
nav.go(Route::Search);
|
||||
nav.go(Route::Collection);
|
||||
nav.back();
|
||||
assert_eq!(nav.current(), Route::Search);
|
||||
nav.back();
|
||||
assert_eq!(nav.current(), Route::Home);
|
||||
assert!(!nav.can_go_back());
|
||||
nav.back();
|
||||
assert_eq!(nav.current(), Route::Home);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn revisiting_current_route_does_not_grow_history() {
|
||||
let mut nav = Navigator::new(Route::Home);
|
||||
nav.go(Route::Home);
|
||||
assert!(!nav.can_go_back());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn history_is_bounded() {
|
||||
let mut nav = Navigator::new(Route::Home);
|
||||
for i in 0..200 {
|
||||
nav.go(if i % 2 == 0 { Route::Search } else { Route::Home });
|
||||
}
|
||||
assert_eq!(nav.history.len(), Navigator::MAX_HISTORY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
//! Content for each route. Until sign-in exists every screen shows its
|
||||
//! signed-out state, which is also what a signed-out user will see later.
|
||||
|
||||
use iced::widget::{Column, button, column, container, row, space};
|
||||
use iced::{Alignment, Element, Fill, Padding};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::route::Route;
|
||||
use crate::ui::icons::{Icon, icon, sized};
|
||||
use crate::ui::theme::{self, Tokens, radius, size, space as sp};
|
||||
use crate::ui::{line, para};
|
||||
|
||||
pub fn view<'a>(t: &'static Tokens, route: Route, query: &str) -> Element<'a, Message> {
|
||||
let content: Column<'a, Message> = match route {
|
||||
Route::Home => column![
|
||||
wave_hero(t),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::Library,
|
||||
"Your music, picked for you",
|
||||
"Sign in to see your daily playlists, the chart and albums picked from what you play.",
|
||||
),
|
||||
],
|
||||
Route::Wave => column![
|
||||
title(t, "My Wave"),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::Wave,
|
||||
"An endless stream that learns from you",
|
||||
"Sign in to start My Wave. Every like, skip and full listen steers what comes next.",
|
||||
),
|
||||
],
|
||||
Route::Search => column![
|
||||
title(t, if query.trim().is_empty() {
|
||||
"Search".to_owned()
|
||||
} else {
|
||||
format!("Results for “{}”", query.trim())
|
||||
}),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::Search,
|
||||
"Search the whole catalogue",
|
||||
"Sign in to search tracks, albums, artists, playlists and podcasts.",
|
||||
),
|
||||
],
|
||||
Route::Collection => column![
|
||||
title(t, "Collection"),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::HeartFilled,
|
||||
"Everything you've liked",
|
||||
"Your liked tracks, albums, artists and playlists appear here after you sign in.",
|
||||
),
|
||||
],
|
||||
Route::Podcasts => column![
|
||||
title(t, "Podcasts and books"),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::Podcast,
|
||||
"Pick up where you left off",
|
||||
"Podcasts and audiobooks you follow appear here after you sign in.",
|
||||
),
|
||||
],
|
||||
Route::Settings => column![
|
||||
title(t, "Settings"),
|
||||
signed_out(
|
||||
t,
|
||||
Icon::Settings,
|
||||
"Account and playback",
|
||||
"Sign in to choose streaming quality and manage your Yandex account.",
|
||||
),
|
||||
],
|
||||
Route::SignIn => column![sign_in(t)],
|
||||
};
|
||||
|
||||
content
|
||||
.spacing(sp::SECTION)
|
||||
.padding(Padding::default().top(6).bottom(40).left(sp::GUTTER).right(sp::GUTTER))
|
||||
.width(Fill)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn title<'a>(t: &'static Tokens, text: impl Into<String>) -> Element<'a, Message> {
|
||||
line(text.into(), theme::DISPLAY, size::DISPLAY_S, t.fg).into()
|
||||
}
|
||||
|
||||
fn signed_out<'a>(
|
||||
t: &'static Tokens,
|
||||
glyph: Icon,
|
||||
heading: &'a str,
|
||||
body: &'a str,
|
||||
) -> Element<'a, Message> {
|
||||
container(
|
||||
column![
|
||||
sized(glyph, 28.0, t.accent),
|
||||
column![
|
||||
line(heading, theme::SEMIBOLD, size::SECTION, t.fg),
|
||||
container(para(body, size::BODY, t.muted)).max_width(460),
|
||||
]
|
||||
.spacing(6),
|
||||
button(line("Sign in", theme::SEMIBOLD, size::BODY, t.accent_ink))
|
||||
.padding([11, 18])
|
||||
.style(theme::primary)
|
||||
.on_press(Message::Navigate(Route::SignIn)),
|
||||
]
|
||||
.spacing(18),
|
||||
)
|
||||
.padding(28)
|
||||
.width(Fill)
|
||||
.style(theme::card)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Static version of the My Wave hero; the animated wave arrives with playback.
|
||||
fn wave_hero<'a>(t: &'static Tokens) -> Element<'a, Message> {
|
||||
container(
|
||||
row![
|
||||
column![
|
||||
line("My Wave", theme::DISPLAY, size::DISPLAY_M, t.fg),
|
||||
container(para(
|
||||
"An endless stream picked from what you play, like and skip.",
|
||||
size::BODY,
|
||||
t.muted,
|
||||
))
|
||||
.max_width(380),
|
||||
]
|
||||
.spacing(6)
|
||||
.width(Fill),
|
||||
button(
|
||||
row![icon(Icon::Play, t.muted), line("Play My Wave", theme::SEMIBOLD, size::BODY, t.muted)]
|
||||
.spacing(8)
|
||||
.align_y(Alignment::Center),
|
||||
)
|
||||
.padding([11, 18])
|
||||
.style(theme::primary),
|
||||
]
|
||||
.spacing(28)
|
||||
.align_y(Alignment::End),
|
||||
)
|
||||
.padding(Padding::default().top(120).bottom(26).left(28).right(28))
|
||||
.width(Fill)
|
||||
.style(move |th| {
|
||||
let mut s = theme::card(th);
|
||||
s.border.radius = radius::HERO.into();
|
||||
s.background = Some(iced::Background::Gradient(
|
||||
iced::gradient::Linear::new(0.0)
|
||||
.add_stop(0.0, t.panel)
|
||||
.add_stop(1.0, theme::mix(t.panel, t.accent, 0.16))
|
||||
.into(),
|
||||
));
|
||||
s
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
fn sign_in<'a>(t: &'static Tokens) -> Element<'a, Message> {
|
||||
column![
|
||||
container(line("Sign in with your Yandex account", theme::DISPLAY, size::DISPLAY_M, t.fg)),
|
||||
container(para(
|
||||
"Musyx plays your Yandex Music library, My Wave and playlists. You confirm sign-in \
|
||||
on Yandex's own page, so your password never passes through this app.",
|
||||
15.0,
|
||||
t.muted,
|
||||
))
|
||||
.max_width(520),
|
||||
button(line("Get sign-in code", theme::SEMIBOLD, size::BODY, t.muted))
|
||||
.padding([11, 18])
|
||||
.style(theme::primary),
|
||||
space().height(8),
|
||||
container(para(
|
||||
"Musyx is an unofficial client and isn't affiliated with Yandex. Your sign-in token \
|
||||
is kept in the system keychain.",
|
||||
size::SMALL,
|
||||
t.muted,
|
||||
))
|
||||
.max_width(520),
|
||||
]
|
||||
.spacing(22)
|
||||
.padding(Padding::default().top(24))
|
||||
.into()
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
//! Headless-ish visual check: render one screen, save it as a PNG, quit.
|
||||
//!
|
||||
//! ```sh
|
||||
//! MUSYX_SNAPSHOT=home.png MUSYX_SNAPSHOT_ROUTE=wave MUSYX_SNAPSHOT_DRAWER=queue \
|
||||
//! MUSYX_SNAPSHOT_THEME=light cargo run -p musyx --features snapshot
|
||||
//! ```
|
||||
//! iced's own `window::screenshot` is used, so it needs no screen-recording permission.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
use iced::Task;
|
||||
use iced::theme::Mode;
|
||||
use iced::window;
|
||||
|
||||
use crate::route::Route;
|
||||
use crate::widgets::drawer::Panel;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub out: PathBuf,
|
||||
pub route: Option<Route>,
|
||||
pub drawer: Option<Panel>,
|
||||
pub mode: Option<Mode>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn from_env() -> Option<Self> {
|
||||
let out = PathBuf::from(std::env::var_os("MUSYX_SNAPSHOT")?);
|
||||
let var = |k: &str| std::env::var(k).ok().map(|v| v.to_ascii_lowercase());
|
||||
let route = var("MUSYX_SNAPSHOT_ROUTE").and_then(|r| {
|
||||
Some(match r.as_str() {
|
||||
"home" => Route::Home,
|
||||
"wave" => Route::Wave,
|
||||
"search" => Route::Search,
|
||||
"collection" => Route::Collection,
|
||||
"podcasts" => Route::Podcasts,
|
||||
"settings" => Route::Settings,
|
||||
"signin" => Route::SignIn,
|
||||
_ => return None,
|
||||
})
|
||||
});
|
||||
let drawer = var("MUSYX_SNAPSHOT_DRAWER").and_then(|d| match d.as_str() {
|
||||
"queue" => Some(Panel::Queue),
|
||||
"lyrics" => Some(Panel::Lyrics),
|
||||
_ => None,
|
||||
});
|
||||
let mode = var("MUSYX_SNAPSHOT_THEME").and_then(|m| match m.as_str() {
|
||||
"light" => Some(Mode::Light),
|
||||
"dark" => Some(Mode::Dark),
|
||||
_ => None,
|
||||
});
|
||||
Some(Self { out, route, drawer, mode })
|
||||
}
|
||||
|
||||
/// Waits for fonts and the first frames, captures the window, writes the PNG, exits.
|
||||
pub fn capture<M: Send + 'static>(self) -> Task<M> {
|
||||
Task::future(tokio::time::sleep(Duration::from_millis(1500)))
|
||||
.then(|()| window::latest())
|
||||
.then(|id| match id {
|
||||
Some(id) => window::screenshot(id),
|
||||
None => Task::none(),
|
||||
})
|
||||
.then(move |shot| {
|
||||
if let Err(e) = write_png(&self.out, &shot) {
|
||||
eprintln!("snapshot: {e}");
|
||||
} else {
|
||||
eprintln!("snapshot: wrote {}", self.out.display());
|
||||
}
|
||||
iced::exit()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn write_png(path: &std::path::Path, shot: &window::Screenshot) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let file = std::io::BufWriter::new(std::fs::File::create(path)?);
|
||||
let mut encoder = png::Encoder::new(file, shot.size.width, shot.size.height);
|
||||
encoder.set_color(png::ColorType::Rgba);
|
||||
encoder.set_depth(png::BitDepth::Eight);
|
||||
encoder.write_header()?.write_image_data(&shot.rgba)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//! Bundled Lucide 0.460 icons (ISC, see `assets/icons/LICENSE.txt`).
|
||||
//!
|
||||
//! The SVGs stroke with `currentColor`; iced ignores that, so every icon is tinted
|
||||
//! through `svg::Style::color` instead — pass the colour the surrounding text uses.
|
||||
|
||||
// Bundled ahead of the screens that use them.
|
||||
#![allow(dead_code)]
|
||||
|
||||
use iced::widget::{Svg, svg};
|
||||
use iced::{Color, Length, Theme};
|
||||
|
||||
use super::theme::shell;
|
||||
|
||||
macro_rules! icons {
|
||||
($($variant:ident => $file:literal),+ $(,)?) => {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Icon { $($variant),+ }
|
||||
|
||||
impl Icon {
|
||||
pub const ALL: &[Icon] = &[$(Icon::$variant),+];
|
||||
|
||||
fn bytes(self) -> &'static [u8] {
|
||||
match self {
|
||||
$(Icon::$variant => include_bytes!(concat!("../../assets/icons/", $file, ".svg"))),+
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
icons! {
|
||||
Home => "house",
|
||||
Wave => "audio-lines",
|
||||
Search => "search",
|
||||
Library => "library",
|
||||
Podcast => "podcast",
|
||||
Plus => "plus",
|
||||
LogOut => "log-out",
|
||||
Back => "chevron-left",
|
||||
Play => "play-fill",
|
||||
Pause => "pause-fill",
|
||||
Previous => "skip-back",
|
||||
Next => "skip-forward",
|
||||
Shuffle => "shuffle",
|
||||
Repeat => "repeat",
|
||||
RepeatOne => "repeat-1",
|
||||
Heart => "heart",
|
||||
HeartFilled => "heart-fill",
|
||||
Dislike => "ban",
|
||||
Lyrics => "mic-vocal",
|
||||
Queue => "list-music",
|
||||
Volume => "volume-2",
|
||||
Muted => "volume-x",
|
||||
More => "ellipsis",
|
||||
Disc => "disc-3",
|
||||
Lock => "lock",
|
||||
Globe => "globe",
|
||||
Pencil => "pencil",
|
||||
Trash => "trash-2",
|
||||
Grip => "grip-vertical",
|
||||
Close => "x",
|
||||
Copy => "copy",
|
||||
Clock => "clock-3",
|
||||
Tune => "sliders-horizontal",
|
||||
Settings => "settings",
|
||||
}
|
||||
|
||||
impl Icon {
|
||||
pub fn handle(self) -> svg::Handle {
|
||||
svg::Handle::from_memory(self.bytes())
|
||||
}
|
||||
}
|
||||
|
||||
/// An icon at the standard 18px size, tinted `color`.
|
||||
pub fn icon<'a>(icon: Icon, color: Color) -> Svg<'a, Theme> {
|
||||
sized(icon, shell::ICON, color)
|
||||
}
|
||||
|
||||
pub fn sized<'a>(icon: Icon, size: f32, color: Color) -> Svg<'a, Theme> {
|
||||
svg(icon.handle())
|
||||
.width(Length::Fixed(size))
|
||||
.height(Length::Fixed(size))
|
||||
.style(move |_, _| svg::Style { color: Some(color) })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn every_icon_is_an_svg() {
|
||||
for icon in Icon::ALL {
|
||||
let text = std::str::from_utf8(icon.bytes()).expect("utf-8");
|
||||
assert!(text.contains("<svg"), "{icon:?} is not an SVG");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
pub mod icons;
|
||||
pub mod theme;
|
||||
|
||||
use iced::widget::{Text, text};
|
||||
use iced::widget::text::Wrapping;
|
||||
use iced::{Color, Font};
|
||||
|
||||
/// Single-line text in the given face; long values are clipped by their container.
|
||||
pub fn line<'a>(content: impl text::IntoFragment<'a>, font: Font, size: f32, color: Color) -> Text<'a> {
|
||||
text(content).font(font).size(size).color(color).wrapping(Wrapping::None)
|
||||
}
|
||||
|
||||
/// Running text that wraps.
|
||||
pub fn para<'a>(content: impl text::IntoFragment<'a>, size: f32, color: Color) -> Text<'a> {
|
||||
text(content).font(theme::BODY).size(size).color(color).line_height(1.45)
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
//! Design tokens and widget styles. Mirrors `DESIGN.md`; change both together.
|
||||
|
||||
// The token set is the whole design system; screens adopt pieces milestone by milestone.
|
||||
#![allow(dead_code)]
|
||||
|
||||
use iced::border::Radius;
|
||||
use iced::font::{Family, Weight};
|
||||
use iced::theme::{Mode, Palette};
|
||||
use iced::widget::{button, container, scrollable, slider, text_input};
|
||||
use iced::{Background, Border, Color, Font, Shadow, Theme, Vector};
|
||||
|
||||
/// Colour tokens for one theme mode.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Tokens {
|
||||
pub bg: Color,
|
||||
pub panel: Color,
|
||||
pub raised: Color,
|
||||
pub line: Color,
|
||||
pub fg: Color,
|
||||
pub muted: Color,
|
||||
pub accent: Color,
|
||||
pub accent_ink: Color,
|
||||
pub like: Color,
|
||||
pub ok: Color,
|
||||
}
|
||||
|
||||
const fn hex(h: u32) -> Color {
|
||||
Color::from_rgb8((h >> 16) as u8, (h >> 8) as u8, h as u8)
|
||||
}
|
||||
|
||||
pub const DARK: Tokens = Tokens {
|
||||
bg: hex(0x1C1A22),
|
||||
panel: hex(0x23202B),
|
||||
raised: hex(0x2D2937),
|
||||
line: hex(0x3A3546),
|
||||
fg: hex(0xEEEAF3),
|
||||
muted: hex(0xA39CB0),
|
||||
accent: hex(0xF0B23E),
|
||||
accent_ink: hex(0x2A1D04),
|
||||
like: hex(0xF27286),
|
||||
ok: hex(0x7FCB9B),
|
||||
};
|
||||
|
||||
pub const LIGHT: Tokens = Tokens {
|
||||
bg: hex(0xF3F1F6),
|
||||
panel: hex(0xFFFFFF),
|
||||
raised: hex(0xEAE6F0),
|
||||
line: hex(0xDCD6E4),
|
||||
fg: hex(0x1F1B27),
|
||||
muted: hex(0x686178),
|
||||
accent: hex(0xA86C05),
|
||||
accent_ink: hex(0xFFF7E6),
|
||||
like: hex(0xD2405A),
|
||||
ok: hex(0x2E8A55),
|
||||
};
|
||||
|
||||
/// Tokens for whichever theme is active. Style closures only receive `&Theme`,
|
||||
/// so the tokens are recovered from the palette's darkness.
|
||||
pub fn tokens(theme: &Theme) -> &'static Tokens {
|
||||
if theme.extended_palette().is_dark { &DARK } else { &LIGHT }
|
||||
}
|
||||
|
||||
/// The iced theme for a system appearance. Musyx is dark-first, so "no preference" is dark.
|
||||
pub fn for_mode(mode: Mode) -> Theme {
|
||||
let (name, t) = match mode {
|
||||
Mode::Light => ("Musyx Light", &LIGHT),
|
||||
Mode::Dark | Mode::None => ("Musyx Dark", &DARK),
|
||||
};
|
||||
Theme::custom(
|
||||
name,
|
||||
Palette {
|
||||
background: t.bg,
|
||||
text: t.fg,
|
||||
primary: t.accent,
|
||||
success: t.ok,
|
||||
warning: t.accent,
|
||||
danger: t.like,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// ---- Type ----
|
||||
|
||||
pub const BODY: Font = Font::with_name("Onest");
|
||||
pub const MEDIUM: Font = Font { weight: Weight::Medium, ..BODY };
|
||||
pub const SEMIBOLD: Font = Font { weight: Weight::Semibold, ..BODY };
|
||||
pub const DISPLAY: Font = Font {
|
||||
family: Family::Name("Unbounded"),
|
||||
weight: Weight::Semibold,
|
||||
..Font::DEFAULT
|
||||
};
|
||||
|
||||
pub const FONTS: [&[u8]; 4] = [
|
||||
include_bytes!("../../assets/fonts/Onest-Regular.ttf"),
|
||||
include_bytes!("../../assets/fonts/Onest-Medium.ttf"),
|
||||
include_bytes!("../../assets/fonts/Onest-SemiBold.ttf"),
|
||||
include_bytes!("../../assets/fonts/Unbounded-SemiBold.ttf"),
|
||||
];
|
||||
|
||||
pub mod size {
|
||||
pub const DISPLAY_XL: f32 = 46.0;
|
||||
pub const DISPLAY_L: f32 = 40.0;
|
||||
pub const DISPLAY_M: f32 = 34.0;
|
||||
pub const DISPLAY_S: f32 = 30.0;
|
||||
pub const WORDMARK: f32 = 20.0;
|
||||
pub const SECTION: f32 = 19.0;
|
||||
pub const BODY: f32 = 14.0;
|
||||
pub const META: f32 = 13.0;
|
||||
pub const SMALL: f32 = 12.5;
|
||||
}
|
||||
|
||||
// ---- Space and shape ----
|
||||
|
||||
pub mod space {
|
||||
pub const XS: f32 = 4.0;
|
||||
pub const S: f32 = 8.0;
|
||||
pub const M: f32 = 12.0;
|
||||
pub const L: f32 = 18.0;
|
||||
pub const XL: f32 = 22.0;
|
||||
pub const GUTTER: f32 = 28.0;
|
||||
pub const SECTION: f32 = 34.0;
|
||||
}
|
||||
|
||||
pub mod radius {
|
||||
pub const COVER: f32 = 10.0;
|
||||
pub const CONTROL: f32 = 8.0;
|
||||
pub const SMALL_COVER: f32 = 6.0;
|
||||
pub const PILL: f32 = 999.0;
|
||||
pub const HERO: f32 = 16.0;
|
||||
pub const CARD: f32 = 14.0;
|
||||
}
|
||||
|
||||
pub mod shell {
|
||||
pub const SIDEBAR: f32 = 232.0;
|
||||
pub const PLAYER: f32 = 80.0;
|
||||
pub const DRAWER: f32 = 320.0;
|
||||
pub const ICON: f32 = 18.0;
|
||||
}
|
||||
|
||||
// ---- Containers ----
|
||||
|
||||
fn hairline(color: Color) -> Border {
|
||||
Border { color, width: 1.0, radius: Radius::from(0.0) }
|
||||
}
|
||||
|
||||
pub fn app(theme: &Theme) -> container::Style {
|
||||
let t = tokens(theme);
|
||||
container::Style {
|
||||
background: Some(t.bg.into()),
|
||||
text_color: Some(t.fg),
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Sidebar, player bar and drawer share the panel fill; the divider is drawn separately.
|
||||
pub fn panel(theme: &Theme) -> container::Style {
|
||||
let t = tokens(theme);
|
||||
container::Style {
|
||||
background: Some(t.panel.into()),
|
||||
text_color: Some(t.fg),
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn divider(theme: &Theme) -> container::Style {
|
||||
container::Style {
|
||||
background: Some(tokens(theme).line.into()),
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// A bordered surface such as the empty-state card or the device-code box.
|
||||
pub fn card(theme: &Theme) -> container::Style {
|
||||
let t = tokens(theme);
|
||||
container::Style {
|
||||
background: Some(t.panel.into()),
|
||||
border: Border { radius: radius::CARD.into(), ..hairline(t.line) },
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn badge(theme: &Theme) -> container::Style {
|
||||
let t = tokens(theme);
|
||||
container::Style {
|
||||
text_color: Some(t.muted),
|
||||
border: Border { radius: 5.0.into(), ..hairline(t.line) },
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accent_dot(theme: &Theme) -> container::Style {
|
||||
container::Style {
|
||||
background: Some(tokens(theme).accent.into()),
|
||||
border: Border { radius: radius::PILL.into(), ..Border::default() },
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn avatar(theme: &Theme) -> container::Style {
|
||||
let t = tokens(theme);
|
||||
container::Style {
|
||||
background: Some(Background::Gradient(
|
||||
iced::gradient::Linear::new(std::f32::consts::FRAC_PI_4 * 3.0)
|
||||
.add_stop(0.0, hex(0x8E7AB5))
|
||||
.add_stop(1.0, hex(0xE0A84B))
|
||||
.into(),
|
||||
)),
|
||||
text_color: Some(hex(0x1C1A22)),
|
||||
border: Border { radius: radius::PILL.into(), ..hairline(t.line) },
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Placeholder art for an item without a cover yet: two hues on a diagonal.
|
||||
pub fn cover(h1: f32, h2: f32, corner: f32) -> impl Fn(&Theme) -> container::Style {
|
||||
move |_| container::Style {
|
||||
background: Some(Background::Gradient(
|
||||
iced::gradient::Linear::new(std::f32::consts::FRAC_PI_4 * 3.0)
|
||||
.add_stop(0.0, hsl(h1, 0.70, 0.60))
|
||||
.add_stop(0.55, hsl((h1 + h2) / 2.0, 0.45, 0.30))
|
||||
.add_stop(1.0, hsl(h2, 0.40, 0.16))
|
||||
.into(),
|
||||
)),
|
||||
border: Border { radius: corner.into(), ..Border::default() },
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn hsl(h: f32, s: f32, l: f32) -> Color {
|
||||
let c = (1.0 - (2.0 * l - 1.0).abs()) * s;
|
||||
let hp = (h.rem_euclid(360.0)) / 60.0;
|
||||
let x = c * (1.0 - (hp % 2.0 - 1.0).abs());
|
||||
let (r, g, b) = match hp as u32 {
|
||||
0 => (c, x, 0.0),
|
||||
1 => (x, c, 0.0),
|
||||
2 => (0.0, c, x),
|
||||
3 => (0.0, x, c),
|
||||
4 => (x, 0.0, c),
|
||||
_ => (c, 0.0, x),
|
||||
};
|
||||
let m = l - c / 2.0;
|
||||
Color::from_rgb(r + m, g + m, b + m)
|
||||
}
|
||||
|
||||
// ---- Buttons ----
|
||||
|
||||
/// Sidebar navigation item; `active` is the current page.
|
||||
pub fn nav_item(active: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme, status| {
|
||||
let t = tokens(theme);
|
||||
let lit = active || matches!(status, button::Status::Hovered | button::Status::Pressed);
|
||||
button::Style {
|
||||
background: lit.then(|| t.raised.into()),
|
||||
text_color: if lit { t.fg } else { t.muted },
|
||||
border: Border { radius: radius::CONTROL.into(), ..Border::default() },
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Square icon button. `on` tints it (accent for toggles, `like` for hearts).
|
||||
pub fn icon_button(on: Option<Color>) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme, status| {
|
||||
let t = tokens(theme);
|
||||
let hovered = matches!(status, button::Status::Hovered | button::Status::Pressed);
|
||||
let disabled = matches!(status, button::Status::Disabled);
|
||||
button::Style {
|
||||
background: (hovered && !disabled).then(|| t.raised.into()),
|
||||
text_color: match (on, disabled, hovered) {
|
||||
(_, true, _) => t.muted.scale_alpha(0.45),
|
||||
(Some(c), _, _) => c,
|
||||
(None, _, true) => t.fg,
|
||||
(None, _, false) => t.muted,
|
||||
},
|
||||
border: Border { radius: radius::CONTROL.into(), ..Border::default() },
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The round play/pause disc in the player bar.
|
||||
pub fn play_disc(theme: &Theme, status: button::Status) -> button::Style {
|
||||
let t = tokens(theme);
|
||||
let disabled = matches!(status, button::Status::Disabled);
|
||||
button::Style {
|
||||
background: Some(if disabled { t.raised } else { t.fg }.into()),
|
||||
text_color: if disabled { t.muted } else { t.bg },
|
||||
border: Border { radius: radius::PILL.into(), ..Border::default() },
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primary(theme: &Theme, status: button::Status) -> button::Style {
|
||||
let t = tokens(theme);
|
||||
let bg = match status {
|
||||
button::Status::Hovered => mix(t.accent, t.fg, 0.12),
|
||||
button::Status::Pressed => mix(t.accent, t.bg, 0.12),
|
||||
button::Status::Disabled => t.raised,
|
||||
button::Status::Active => t.accent,
|
||||
};
|
||||
button::Style {
|
||||
background: Some(bg.into()),
|
||||
text_color: if matches!(status, button::Status::Disabled) { t.muted } else { t.accent_ink },
|
||||
border: Border { radius: radius::PILL.into(), ..Border::default() },
|
||||
shadow: Shadow {
|
||||
color: Color::BLACK.scale_alpha(0.18),
|
||||
offset: Vector::new(0.0, 4.0),
|
||||
blur_radius: 12.0,
|
||||
},
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ghost(theme: &Theme, status: button::Status) -> button::Style {
|
||||
let t = tokens(theme);
|
||||
button::Style {
|
||||
background: matches!(status, button::Status::Hovered | button::Status::Pressed)
|
||||
.then(|| t.raised.into()),
|
||||
text_color: t.fg,
|
||||
border: Border { radius: radius::PILL.into(), ..hairline(t.line) },
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Tab in a tab strip (drawer Queue | Lyrics, collection tabs).
|
||||
pub fn tab(selected: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme, status| {
|
||||
let t = tokens(theme);
|
||||
let hovered = matches!(status, button::Status::Hovered);
|
||||
button::Style {
|
||||
background: None,
|
||||
text_color: if selected || hovered { t.fg } else { t.muted },
|
||||
border: Border::default(),
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tab_underline(selected: bool) -> impl Fn(&Theme) -> container::Style {
|
||||
move |theme| container::Style {
|
||||
background: selected.then(|| tokens(theme).accent.into()),
|
||||
..container::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Inputs ----
|
||||
|
||||
pub fn search_field(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let t = tokens(theme);
|
||||
let focused = matches!(status, text_input::Status::Focused { .. });
|
||||
text_input::Style {
|
||||
background: t.panel.into(),
|
||||
border: Border {
|
||||
color: if focused { t.accent } else { t.line },
|
||||
width: 1.0,
|
||||
radius: radius::PILL.into(),
|
||||
},
|
||||
icon: t.muted,
|
||||
placeholder: t.muted,
|
||||
value: t.fg,
|
||||
selection: t.accent.scale_alpha(0.35),
|
||||
}
|
||||
}
|
||||
|
||||
/// Thin seek bar: amber fill, knob only while hovered or dragged.
|
||||
pub fn seek_bar(theme: &Theme, status: slider::Status) -> slider::Style {
|
||||
thin_slider(theme, status, tokens(theme).accent)
|
||||
}
|
||||
|
||||
pub fn volume_bar(theme: &Theme, status: slider::Status) -> slider::Style {
|
||||
thin_slider(theme, status, tokens(theme).fg)
|
||||
}
|
||||
|
||||
fn thin_slider(theme: &Theme, status: slider::Status, fill: Color) -> slider::Style {
|
||||
let t = tokens(theme);
|
||||
let engaged = matches!(status, slider::Status::Hovered | slider::Status::Dragged);
|
||||
slider::Style {
|
||||
rail: slider::Rail {
|
||||
backgrounds: (fill.into(), t.raised.into()),
|
||||
width: 4.0,
|
||||
border: Border { radius: 2.0.into(), ..Border::default() },
|
||||
},
|
||||
handle: slider::Handle {
|
||||
shape: slider::HandleShape::Circle { radius: if engaged { 6.0 } else { 0.0 } },
|
||||
background: t.fg.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll(theme: &Theme, status: scrollable::Status) -> scrollable::Style {
|
||||
let t = tokens(theme);
|
||||
let mut style = scrollable::default(theme, status);
|
||||
let rail = scrollable::Rail {
|
||||
background: None,
|
||||
border: Border::default(),
|
||||
scroller: scrollable::Scroller {
|
||||
background: t.line.into(),
|
||||
border: Border { radius: radius::PILL.into(), ..Border::default() },
|
||||
},
|
||||
};
|
||||
style.vertical_rail = rail;
|
||||
style.horizontal_rail = rail;
|
||||
style
|
||||
}
|
||||
|
||||
/// Linear blend of two colours; `amount` is the share of `b`.
|
||||
pub fn mix(a: Color, b: Color, amount: f32) -> Color {
|
||||
Color {
|
||||
r: a.r + (b.r - a.r) * amount,
|
||||
g: a.g + (b.g - a.g) * amount,
|
||||
b: a.b + (b.b - a.b) * amount,
|
||||
a: a.a + (b.a - a.a) * amount,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn tokens_follow_theme_mode() {
|
||||
assert_eq!(tokens(&for_mode(Mode::Dark)), &DARK);
|
||||
assert_eq!(tokens(&for_mode(Mode::None)), &DARK);
|
||||
assert_eq!(tokens(&for_mode(Mode::Light)), &LIGHT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hex_unpacks_channels() {
|
||||
assert_eq!(hex(0xF0B23E), Color::from_rgb8(0xF0, 0xB2, 0x3E));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hsl_primaries() {
|
||||
let red = hsl(0.0, 1.0, 0.5);
|
||||
assert!((red.r - 1.0).abs() < 1e-5 && red.g.abs() < 1e-5 && red.b.abs() < 1e-5);
|
||||
let blue = hsl(240.0, 1.0, 0.5);
|
||||
assert!((blue.b - 1.0).abs() < 1e-5 && blue.r.abs() < 1e-5);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//! Right-hand panel with the play queue and lyrics.
|
||||
|
||||
use iced::widget::{button, column, container, row, space};
|
||||
use iced::{Alignment, Element, Fill, Padding};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::icons::{Icon, icon};
|
||||
use crate::ui::theme::{self, Tokens, shell, size};
|
||||
use crate::ui::{line, para};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Panel {
|
||||
Queue,
|
||||
Lyrics,
|
||||
}
|
||||
|
||||
impl Panel {
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Panel::Queue => "Queue",
|
||||
Panel::Lyrics => "Lyrics",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view<'a>(t: &'static Tokens, panel: Panel) -> Element<'a, Message> {
|
||||
let tabs = row![tab(t, Panel::Queue, panel), tab(t, Panel::Lyrics, panel)].spacing(4);
|
||||
|
||||
let head = row![
|
||||
tabs,
|
||||
space().width(Fill),
|
||||
button(icon(Icon::Close, t.muted))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None))
|
||||
.on_press(Message::CloseDrawer),
|
||||
]
|
||||
.align_y(Alignment::Center)
|
||||
.padding(Padding::default().top(14).bottom(8).left(18).right(14));
|
||||
|
||||
let body = match panel {
|
||||
Panel::Queue => para(
|
||||
"Nothing queued yet. Tracks you play, and the ones lined up after them, show up here.",
|
||||
size::META,
|
||||
t.muted,
|
||||
),
|
||||
Panel::Lyrics => para(
|
||||
"Play a track to see its lyrics. Synced lyrics follow playback, and clicking a line jumps to it.",
|
||||
size::META,
|
||||
t.muted,
|
||||
),
|
||||
};
|
||||
|
||||
container(column![head, container(body).padding([4, 20])])
|
||||
.width(shell::DRAWER)
|
||||
.height(Fill)
|
||||
.style(theme::panel)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn tab<'a>(t: &'static Tokens, panel: Panel, selected: Panel) -> Element<'a, Message> {
|
||||
let on = panel == selected;
|
||||
button(
|
||||
column![
|
||||
line(panel.label(), theme::MEDIUM, size::BODY, if on { t.fg } else { t.muted }),
|
||||
container(space()).width(Fill).height(2).style(theme::tab_underline(on)),
|
||||
]
|
||||
.spacing(7)
|
||||
.width(iced::Shrink),
|
||||
)
|
||||
.padding(Padding::default().left(10).right(10).top(6))
|
||||
.style(theme::tab(on))
|
||||
.on_press(Message::ToggleDrawer(panel))
|
||||
.into()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
pub mod drawer;
|
||||
pub mod player_bar;
|
||||
pub mod sidebar;
|
||||
pub mod topbar;
|
||||
@@ -0,0 +1,295 @@
|
||||
//! The persistent bar along the bottom: now playing, transport, extras.
|
||||
//!
|
||||
//! Until the audio engine lands the bar only knows its own toggles; `now` stays
|
||||
//! `None`, so the transport renders disabled and the seek bar is static.
|
||||
|
||||
use iced::widget::{button, column, container, row, slider, space};
|
||||
use iced::{Alignment, Element, Fill, Length};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::icons::{Icon, icon, sized};
|
||||
use crate::ui::line;
|
||||
use crate::ui::theme::{self, Tokens, radius, size};
|
||||
use crate::widgets::drawer::Panel;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum Repeat {
|
||||
#[default]
|
||||
Off,
|
||||
All,
|
||||
One,
|
||||
}
|
||||
|
||||
impl Repeat {
|
||||
fn next(self) -> Self {
|
||||
match self {
|
||||
Repeat::Off => Repeat::All,
|
||||
Repeat::All => Repeat::One,
|
||||
Repeat::One => Repeat::Off,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct NowPlaying {
|
||||
pub title: String,
|
||||
pub artists: String,
|
||||
pub position: f32,
|
||||
pub duration: f32,
|
||||
pub playing: bool,
|
||||
pub liked: bool,
|
||||
pub quality: String,
|
||||
/// Placeholder cover hues until artwork loads.
|
||||
pub hues: (f32, f32),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PlayerUi {
|
||||
pub now: Option<NowPlaying>,
|
||||
pub shuffle: bool,
|
||||
pub repeat: Repeat,
|
||||
pub volume: f32,
|
||||
pub muted: bool,
|
||||
}
|
||||
|
||||
impl Default for PlayerUi {
|
||||
fn default() -> Self {
|
||||
Self { now: None, shuffle: false, repeat: Repeat::Off, volume: 0.7, muted: false }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Action {
|
||||
ToggleShuffle,
|
||||
CycleRepeat,
|
||||
SetVolume(f32),
|
||||
ToggleMute,
|
||||
}
|
||||
|
||||
impl PlayerUi {
|
||||
pub fn apply(&mut self, action: Action) {
|
||||
match action {
|
||||
Action::ToggleShuffle => self.shuffle = !self.shuffle,
|
||||
Action::CycleRepeat => self.repeat = self.repeat.next(),
|
||||
Action::SetVolume(v) => {
|
||||
self.volume = v.clamp(0.0, 1.0);
|
||||
self.muted = self.volume == 0.0;
|
||||
}
|
||||
Action::ToggleMute => self.muted = !self.muted,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view<'a>(t: &'static Tokens, p: &'a PlayerUi, drawer: Option<Panel>) -> Element<'a, Message> {
|
||||
row![
|
||||
container(now_playing(t, p.now.as_ref())).width(Length::FillPortion(2)),
|
||||
container(transport(t, p)).width(Length::FillPortion(3)).center_x(Fill),
|
||||
container(extras(t, p, drawer)).width(Length::FillPortion(2)).align_right(Fill),
|
||||
]
|
||||
.spacing(18)
|
||||
.align_y(Alignment::Center)
|
||||
.padding([0, 18])
|
||||
.height(Fill)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn now_playing<'a>(t: &'static Tokens, now: Option<&'a NowPlaying>) -> Element<'a, Message> {
|
||||
let cover = container(space())
|
||||
.width(52)
|
||||
.height(52)
|
||||
.style(move |th| match now {
|
||||
Some(n) => theme::cover(n.hues.0, n.hues.1, radius::CONTROL)(th),
|
||||
None => iced::widget::container::Style {
|
||||
background: Some(t.raised.into()),
|
||||
border: iced::Border { radius: radius::CONTROL.into(), ..Default::default() },
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
|
||||
let Some(now) = now else {
|
||||
return row![
|
||||
cover,
|
||||
column![
|
||||
line("Nothing playing", theme::MEDIUM, size::BODY, t.fg),
|
||||
line("Pick a track to start", theme::BODY, size::META, t.muted),
|
||||
]
|
||||
.spacing(2),
|
||||
]
|
||||
.spacing(12)
|
||||
.align_y(Alignment::Center)
|
||||
.into();
|
||||
};
|
||||
|
||||
row![
|
||||
cover,
|
||||
column![
|
||||
line(&now.title, theme::MEDIUM, size::BODY, t.fg),
|
||||
line(&now.artists, theme::BODY, size::META, t.muted),
|
||||
]
|
||||
.spacing(2)
|
||||
.width(Length::Shrink),
|
||||
button(icon(
|
||||
if now.liked { Icon::HeartFilled } else { Icon::Heart },
|
||||
if now.liked { t.like } else { t.muted },
|
||||
))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None)),
|
||||
button(icon(Icon::Dislike, t.muted)).padding(8).style(theme::icon_button(None)),
|
||||
]
|
||||
.spacing(12)
|
||||
.align_y(Alignment::Center)
|
||||
.clip(true)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn transport<'a>(t: &'static Tokens, p: &'a PlayerUi) -> Element<'a, Message> {
|
||||
let has_track = p.now.is_some();
|
||||
let playing = p.now.as_ref().is_some_and(|n| n.playing);
|
||||
|
||||
let toggle = |glyph: Icon, on: bool, action: Action| {
|
||||
button(icon(glyph, if on { t.accent } else { t.muted }))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(on.then_some(t.accent)))
|
||||
.on_press(Message::Player(action))
|
||||
};
|
||||
let skip = |glyph: Icon| {
|
||||
button(icon(glyph, if has_track { t.fg } else { t.muted.scale_alpha(0.45) }))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None))
|
||||
};
|
||||
let disc_tint = if has_track { t.bg } else { t.muted };
|
||||
let disc = button(
|
||||
container(sized(if playing { Icon::Pause } else { Icon::Play }, 18.0, disc_tint)).center(40),
|
||||
)
|
||||
.width(40)
|
||||
.height(40)
|
||||
.padding(0)
|
||||
.style(theme::play_disc);
|
||||
|
||||
let ctrls = row![
|
||||
toggle(Icon::Shuffle, p.shuffle, Action::ToggleShuffle),
|
||||
skip(Icon::Previous),
|
||||
disc,
|
||||
skip(Icon::Next),
|
||||
toggle(
|
||||
if p.repeat == Repeat::One { Icon::RepeatOne } else { Icon::Repeat },
|
||||
p.repeat != Repeat::Off,
|
||||
Action::CycleRepeat,
|
||||
),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(Alignment::Center);
|
||||
|
||||
let (pos, dur) = p.now.as_ref().map_or((0.0, 0.0), |n| (n.position, n.duration));
|
||||
let fraction = if dur > 0.0 { (pos / dur).clamp(0.0, 1.0) } else { 0.0 };
|
||||
let seek = row![
|
||||
container(line(clock(pos), theme::BODY, 12.0, t.muted)).width(42).align_right(42),
|
||||
static_bar(t, fraction),
|
||||
container(line(clock(dur), theme::BODY, 12.0, t.muted)).width(42),
|
||||
]
|
||||
.spacing(10)
|
||||
.align_y(Alignment::Center)
|
||||
.width(Fill);
|
||||
|
||||
column![ctrls, seek]
|
||||
.spacing(4)
|
||||
.align_x(Alignment::Center)
|
||||
.max_width(560)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Seek bar while there is nothing to seek; becomes a slider with the engine.
|
||||
fn static_bar<'a>(t: &'static Tokens, fraction: f32) -> Element<'a, Message> {
|
||||
let part = |portion: f32, colour: iced::Color| {
|
||||
container(space())
|
||||
.width(Length::FillPortion((portion * 1000.0).round().max(0.0) as u16))
|
||||
.height(4)
|
||||
.style(move |_| iced::widget::container::Style {
|
||||
background: Some(colour.into()),
|
||||
border: iced::Border { radius: 2.0.into(), ..Default::default() },
|
||||
..Default::default()
|
||||
})
|
||||
};
|
||||
if fraction <= 0.0 {
|
||||
return part(1.0, t.raised).width(Fill).into();
|
||||
}
|
||||
row![part(fraction, t.accent), part(1.0 - fraction, t.raised)].width(Fill).into()
|
||||
}
|
||||
|
||||
fn extras<'a>(t: &'static Tokens, p: &'a PlayerUi, drawer: Option<Panel>) -> Element<'a, Message> {
|
||||
let panel_button = |glyph: Icon, panel: Panel| {
|
||||
let on = drawer == Some(panel);
|
||||
button(icon(glyph, if on { t.accent } else { t.muted }))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(on.then_some(t.accent)))
|
||||
.on_press(Message::ToggleDrawer(panel))
|
||||
};
|
||||
|
||||
let mut items = row![].spacing(4).align_y(Alignment::Center);
|
||||
if let Some(now) = &p.now {
|
||||
items = items.push(
|
||||
container(line(&now.quality, theme::MEDIUM, 11.5, t.muted))
|
||||
.padding([2, 6])
|
||||
.style(theme::badge),
|
||||
);
|
||||
}
|
||||
|
||||
let volume = if p.muted { 0.0 } else { p.volume };
|
||||
items
|
||||
.push(panel_button(Icon::Lyrics, Panel::Lyrics))
|
||||
.push(panel_button(Icon::Queue, Panel::Queue))
|
||||
.push(
|
||||
button(icon(if p.muted { Icon::Muted } else { Icon::Volume }, t.muted))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None))
|
||||
.on_press(Message::Player(Action::ToggleMute)),
|
||||
)
|
||||
.push(
|
||||
slider(0.0..=1.0, volume, |v| Message::Player(Action::SetVolume(v)))
|
||||
.step(0.01_f32)
|
||||
.width(96)
|
||||
.style(theme::volume_bar),
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// `m:ss`, or `h:mm:ss` for podcast-length items.
|
||||
pub fn clock(seconds: f32) -> String {
|
||||
let s = seconds.max(0.0) as u64;
|
||||
let (h, m, s) = (s / 3600, (s / 60) % 60, s % 60);
|
||||
if h > 0 { format!("{h}:{m:02}:{s:02}") } else { format!("{m}:{s:02}") }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn clock_formats() {
|
||||
assert_eq!(clock(0.0), "0:00");
|
||||
assert_eq!(clock(225.4), "3:45");
|
||||
assert_eq!(clock(3132.0), "52:12");
|
||||
assert_eq!(clock(3725.0), "1:02:05");
|
||||
assert_eq!(clock(-3.0), "0:00");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeat_cycles_off_all_one() {
|
||||
let mut p = PlayerUi::default();
|
||||
p.apply(Action::CycleRepeat);
|
||||
assert_eq!(p.repeat, Repeat::All);
|
||||
p.apply(Action::CycleRepeat);
|
||||
assert_eq!(p.repeat, Repeat::One);
|
||||
p.apply(Action::CycleRepeat);
|
||||
assert_eq!(p.repeat, Repeat::Off);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn volume_is_clamped_and_zero_means_muted() {
|
||||
let mut p = PlayerUi::default();
|
||||
p.apply(Action::SetVolume(1.4));
|
||||
assert_eq!(p.volume, 1.0);
|
||||
p.apply(Action::SetVolume(0.0));
|
||||
assert!(p.muted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//! Left column: wordmark, main navigation, playlists and the account chip.
|
||||
|
||||
use iced::widget::{Column, button, column, container, row, space};
|
||||
use iced::{Alignment, Element, Fill, Padding};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::route::Route;
|
||||
use crate::ui::icons::{Icon, icon};
|
||||
use crate::ui::theme::{self, Tokens, radius, shell, size};
|
||||
use crate::ui::{line, para};
|
||||
|
||||
pub fn view<'a>(t: &'static Tokens, current: Route) -> Element<'a, Message> {
|
||||
let nav = Column::with_children(Route::NAV.map(|route| nav_item(t, route, route == current)))
|
||||
.spacing(2);
|
||||
|
||||
let playlists_head = row![
|
||||
line("Playlists", theme::MEDIUM, size::SMALL, t.muted),
|
||||
space().width(Fill),
|
||||
button(icon(Icon::Plus, t.muted))
|
||||
.padding(4)
|
||||
.style(theme::icon_button(None)),
|
||||
]
|
||||
.align_y(Alignment::Center)
|
||||
.padding(Padding::default().left(10).right(2));
|
||||
|
||||
let playlists = container(para(
|
||||
"Your playlists appear here after you sign in.",
|
||||
size::META,
|
||||
t.muted,
|
||||
))
|
||||
.padding(Padding::default().left(10).right(10));
|
||||
|
||||
column![
|
||||
wordmark(t),
|
||||
nav,
|
||||
column![playlists_head, playlists].spacing(6),
|
||||
space().height(Fill),
|
||||
account(t, current),
|
||||
]
|
||||
.spacing(22)
|
||||
.padding(Padding::default().top(18).bottom(12).left(12).right(12))
|
||||
.width(shell::SIDEBAR)
|
||||
.height(Fill)
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn wordmark<'a>(t: &'static Tokens) -> Element<'a, Message> {
|
||||
row![
|
||||
line("musyx", theme::DISPLAY, size::WORDMARK, t.fg),
|
||||
container(space()).width(7).height(7).style(theme::accent_dot),
|
||||
]
|
||||
.spacing(3)
|
||||
.align_y(Alignment::End)
|
||||
.padding(Padding::default().left(10).top(4).bottom(4))
|
||||
.into()
|
||||
}
|
||||
|
||||
fn nav_item<'a>(t: &'static Tokens, route: Route, active: bool) -> Element<'a, Message> {
|
||||
let tint = if active { t.accent } else { t.muted };
|
||||
button(
|
||||
row![
|
||||
icon(route.icon(), tint),
|
||||
line(route.label(), theme::MEDIUM, size::BODY, if active { t.fg } else { t.muted }),
|
||||
]
|
||||
.spacing(12)
|
||||
.align_y(Alignment::Center),
|
||||
)
|
||||
.width(Fill)
|
||||
.padding([9, 10])
|
||||
.style(theme::nav_item(active))
|
||||
.on_press(Message::Navigate(route))
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Signed-out state; becomes the avatar, login and subscription once sign-in lands.
|
||||
fn account<'a>(t: &'static Tokens, current: Route) -> Element<'a, Message> {
|
||||
let avatar = container(line("?", theme::SEMIBOLD, size::BODY, t.muted))
|
||||
.center(32)
|
||||
.style(move |_| iced::widget::container::Style {
|
||||
background: Some(t.raised.into()),
|
||||
border: iced::Border { radius: radius::PILL.into(), ..Default::default() },
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let settings_active = current == Route::Settings;
|
||||
column![
|
||||
container(space()).width(Fill).height(1).style(theme::divider),
|
||||
row![
|
||||
avatar,
|
||||
column![
|
||||
line("Not signed in", theme::MEDIUM, 13.5, t.fg),
|
||||
button(line("Sign in", theme::MEDIUM, size::SMALL, t.accent))
|
||||
.padding(0)
|
||||
.style(theme::tab(false))
|
||||
.on_press(Message::Navigate(Route::SignIn)),
|
||||
]
|
||||
.spacing(1)
|
||||
.width(Fill),
|
||||
button(icon(Icon::Settings, if settings_active { t.accent } else { t.muted }))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None))
|
||||
.on_press(Message::Navigate(Route::Settings)),
|
||||
]
|
||||
.spacing(10)
|
||||
.align_y(Alignment::Center)
|
||||
.padding(Padding::default().left(10).right(2)),
|
||||
]
|
||||
.spacing(14)
|
||||
.into()
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//! Back button and search field above the content.
|
||||
|
||||
use iced::widget::{button, row, text_input};
|
||||
use iced::{Alignment, Element};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::icons::{Icon, icon};
|
||||
use crate::ui::theme::{self, Tokens, size, space};
|
||||
|
||||
pub const SEARCH_ID: &str = "search";
|
||||
|
||||
pub fn view<'a>(t: &'static Tokens, can_go_back: bool, query: &str) -> Element<'a, Message> {
|
||||
let back = button(icon(Icon::Back, if can_go_back { t.fg } else { t.muted }))
|
||||
.padding(8)
|
||||
.style(theme::icon_button(None))
|
||||
.on_press_maybe(can_go_back.then_some(Message::Back));
|
||||
|
||||
let search = text_input("Search artists, tracks, podcasts", query)
|
||||
.id(SEARCH_ID)
|
||||
.on_input(Message::SearchChanged)
|
||||
.on_submit(Message::SearchSubmitted)
|
||||
.font(theme::BODY)
|
||||
.size(size::BODY)
|
||||
.padding([10, 16])
|
||||
.width(420)
|
||||
.style(theme::search_field);
|
||||
|
||||
row![back, search]
|
||||
.spacing(10)
|
||||
.align_y(Alignment::Center)
|
||||
.padding([14.0, space::GUTTER])
|
||||
.into()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "ym-api"
|
||||
description = "Client for the unofficial Yandex Music API"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,4 @@
|
||||
//! Client for the unofficial Yandex Music API.
|
||||
//!
|
||||
//! Filled in by milestone 3 (sign-in) onwards; the app depends on this crate's
|
||||
//! own types only, never on whichever upstream wrapper it uses internally.
|
||||