├── .gitignore ├── .gitmodules ├── LICENSE ├── Nuage.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── Nuage.xcscheme ├── Nuage ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── AppIcon128.png │ │ ├── AppIcon128@2x.png │ │ ├── AppIcon16.png │ │ ├── AppIcon16@2x.png │ │ ├── AppIcon256.png │ │ ├── AppIcon256@2x.png │ │ ├── AppIcon32.png │ │ ├── AppIcon32@2x.png │ │ ├── AppIcon512.png │ │ ├── AppIcon512@2x.png │ │ └── Contents.json │ └── Contents.json ├── Audio │ ├── Stream.swift │ └── StreamPlayer.swift ├── Helpers.swift ├── Info.plist ├── Navigation.swift ├── Nuage.entitlements ├── NuageApp.swift ├── Preview Content │ ├── Likes.json │ └── Preview Assets.xcassets │ │ └── Contents.json ├── Preview.swift └── Views │ ├── Artwork.swift │ ├── Details │ ├── TrackDetail.swift │ ├── URLDetail.swift │ └── UserDetail.swift │ ├── FeedbackStack.swift │ ├── InfiniteView │ ├── ArrayView.swift │ ├── InfiniteGrid.swift │ ├── InfiniteList.swift │ └── PageView.swift │ ├── Lists │ ├── CommentList.swift │ ├── PostList.swift │ ├── Rows │ │ ├── CommentRow.swift │ │ ├── PlaylistRow.swift │ │ ├── PostRow.swift │ │ └── TrackRow.swift │ ├── SearchList.swift │ └── TrackList.swift │ ├── LoginView.swift │ ├── MainView.swift │ ├── PlaybackContext.swift │ ├── PlayerSlider.swift │ ├── PlayerView.swift │ ├── StatsStack.swift │ ├── TouchBar.swift │ ├── TrackContextMenu.swift │ ├── UserGrid.swift │ ├── WaveformSlider.swift │ ├── WaveformView.swift │ └── WebView.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "StackNavigationView"] 2 | path = StackNavigationView 3 | url = https://github.com/lbrndnr/StackNavigationView 4 | [submodule "SoundCloud"] 5 | path = SoundCloud 6 | url = https://github.com/lbrndnr/SoundCloud 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Nuage.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4908205025C86DD100AC92EC /* PlayerSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4908204F25C86DD100AC92EC /* PlayerSlider.swift */; }; 11 | 490857292A718FFF002D4FD0 /* PostRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 490857282A718FFF002D4FD0 /* PostRow.swift */; }; 12 | 492AF079258F877E0079035F /* PostList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 492AF078258F877E0079035F /* PostList.swift */; }; 13 | 49328ECF25C4B71500A2A34D /* SoundCloud in Frameworks */ = {isa = PBXBuildFile; productRef = 49328ECE25C4B71500A2A34D /* SoundCloud */; }; 14 | 49332BA525961A260034A161 /* TrackRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49332BA425961A260034A161 /* TrackRow.swift */; }; 15 | 49332BAE25961A3B0034A161 /* PlaylistRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49332BAD25961A3B0034A161 /* PlaylistRow.swift */; }; 16 | 49332BCF25962E910034A161 /* SearchList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49332BCE25962E910034A161 /* SearchList.swift */; }; 17 | 493AB3552A6E668C00E20656 /* FeedbackStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 493AB3542A6E668C00E20656 /* FeedbackStack.swift */; }; 18 | 4964297B25DFCF04008AFBD5 /* CommentList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4964297A25DFCF04008AFBD5 /* CommentList.swift */; }; 19 | 4964299225E054E9008AFBD5 /* CommentRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4964299125E054E9008AFBD5 /* CommentRow.swift */; }; 20 | 4969F3C9257CFA7F0048E29B /* NuageApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F3C8257CFA7F0048E29B /* NuageApp.swift */; }; 21 | 4969F3CD257CFA800048E29B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4969F3CC257CFA800048E29B /* Assets.xcassets */; }; 22 | 4969F3D0257CFA800048E29B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4969F3CF257CFA800048E29B /* Preview Assets.xcassets */; }; 23 | 4969F41E257CFB100048E29B /* Preview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F400257CFB100048E29B /* Preview.swift */; }; 24 | 4969F428257CFB100048E29B /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F40B257CFB100048E29B /* Helpers.swift */; }; 25 | 4969F42A257CFB100048E29B /* Stream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F40E257CFB100048E29B /* Stream.swift */; }; 26 | 4969F42B257CFB100048E29B /* StreamPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F40F257CFB100048E29B /* StreamPlayer.swift */; }; 27 | 4969F42C257CFB100048E29B /* TrackDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F411257CFB100048E29B /* TrackDetail.swift */; }; 28 | 4969F42E257CFB100048E29B /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F413257CFB100048E29B /* LoginView.swift */; }; 29 | 4969F431257CFB100048E29B /* TrackContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F416257CFB100048E29B /* TrackContextMenu.swift */; }; 30 | 4969F433257CFB100048E29B /* TrackList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F418257CFB100048E29B /* TrackList.swift */; }; 31 | 4969F434257CFB100048E29B /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F419257CFB100048E29B /* PlayerView.swift */; }; 32 | 4969F435257CFB100048E29B /* PageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F41A257CFB100048E29B /* PageView.swift */; }; 33 | 4969F436257CFB100048E29B /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F41B257CFB100048E29B /* MainView.swift */; }; 34 | 4969F437257CFB100048E29B /* UserGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4969F41C257CFB100048E29B /* UserGrid.swift */; }; 35 | 497F43B228F757DA0090CAD6 /* WaveformSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 497F43B128F757DA0090CAD6 /* WaveformSlider.swift */; }; 36 | 4980FD2325CD6333004640D5 /* InfiniteGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4980FD2225CD6333004640D5 /* InfiniteGrid.swift */; }; 37 | 4980FD4025CD704E004640D5 /* GridStack in Frameworks */ = {isa = PBXBuildFile; productRef = 4980FD3F25CD704E004640D5 /* GridStack */; }; 38 | 498286F825969AE800147DBE /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = 498286F725969AE800147DBE /* Introspect */; }; 39 | 4988D84625A1C62E0092BAFF /* UserDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4988D84525A1C62E0092BAFF /* UserDetail.swift */; }; 40 | 498C72F32A790AF300AA1AAF /* StatsStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 498C72F22A790AF300AA1AAF /* StatsStack.swift */; }; 41 | 4998E12125CADC8300EB986F /* Artwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4998E12025CADC8300EB986F /* Artwork.swift */; }; 42 | 4999998D25B0886700F42D9B /* WaveformView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4999998C25B0886700F42D9B /* WaveformView.swift */; }; 43 | 49A89C032A5EA1B70019648F /* Likes.json in Resources */ = {isa = PBXBuildFile; fileRef = 49A89C022A5EA12D0019648F /* Likes.json */; }; 44 | 49A99D7A2A7454EE001B8BCB /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49A99D792A7454EE001B8BCB /* Navigation.swift */; }; 45 | 49B154C525C4685D00CE9511 /* URLImage in Frameworks */ = {isa = PBXBuildFile; productRef = 49B154C425C4685D00CE9511 /* URLImage */; }; 46 | 49D0E7F72A7A4B7500F2351C /* PlaybackContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D0E7F62A7A4B7500F2351C /* PlaybackContext.swift */; }; 47 | 49D761E32A7A7E6D00735848 /* URLDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D761E22A7A7E6D00735848 /* URLDetail.swift */; }; 48 | 49E6259D25BE1E7E005BEF8C /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49E6259C25BE1E7E005BEF8C /* WebView.swift */; }; 49 | 49FA14BB2589635800CEF925 /* ArrayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49FA14BA2589635800CEF925 /* ArrayView.swift */; }; 50 | 49FA14C62589693E00CEF925 /* InfiniteList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49FA14C52589693E00CEF925 /* InfiniteList.swift */; }; 51 | 49FEEBDF2A5B56C9002C8865 /* TouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49FEEBDE2A5B56C9002C8865 /* TouchBar.swift */; }; 52 | /* End PBXBuildFile section */ 53 | 54 | /* Begin PBXFileReference section */ 55 | 4908204F25C86DD100AC92EC /* PlayerSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerSlider.swift; sourceTree = ""; }; 56 | 490857282A718FFF002D4FD0 /* PostRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostRow.swift; sourceTree = ""; }; 57 | 492AF078258F877E0079035F /* PostList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostList.swift; sourceTree = ""; }; 58 | 49328EC625C4B6F900A2A34D /* SoundCloud */ = {isa = PBXFileReference; lastKnownFileType = folder; path = SoundCloud; sourceTree = ""; }; 59 | 49332BA425961A260034A161 /* TrackRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackRow.swift; sourceTree = ""; }; 60 | 49332BAD25961A3B0034A161 /* PlaylistRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistRow.swift; sourceTree = ""; }; 61 | 49332BCE25962E910034A161 /* SearchList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchList.swift; sourceTree = ""; }; 62 | 493AB3542A6E668C00E20656 /* FeedbackStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbackStack.swift; sourceTree = ""; }; 63 | 4964297A25DFCF04008AFBD5 /* CommentList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentList.swift; sourceTree = ""; }; 64 | 4964299125E054E9008AFBD5 /* CommentRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentRow.swift; sourceTree = ""; }; 65 | 4969F3C5257CFA7F0048E29B /* Nuage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Nuage.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 4969F3C8257CFA7F0048E29B /* NuageApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NuageApp.swift; sourceTree = ""; }; 67 | 4969F3CC257CFA800048E29B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 68 | 4969F3CF257CFA800048E29B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 69 | 4969F3D1257CFA800048E29B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 4969F3D2257CFA800048E29B /* Nuage.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Nuage.entitlements; sourceTree = ""; }; 71 | 4969F400257CFB100048E29B /* Preview.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Preview.swift; sourceTree = ""; }; 72 | 4969F40B257CFB100048E29B /* Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = ""; }; 73 | 4969F40E257CFB100048E29B /* Stream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stream.swift; sourceTree = ""; }; 74 | 4969F40F257CFB100048E29B /* StreamPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StreamPlayer.swift; sourceTree = ""; }; 75 | 4969F411257CFB100048E29B /* TrackDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackDetail.swift; sourceTree = ""; }; 76 | 4969F413257CFB100048E29B /* LoginView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = ""; }; 77 | 4969F416257CFB100048E29B /* TrackContextMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackContextMenu.swift; sourceTree = ""; }; 78 | 4969F418257CFB100048E29B /* TrackList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackList.swift; sourceTree = ""; }; 79 | 4969F419257CFB100048E29B /* PlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = ""; }; 80 | 4969F41A257CFB100048E29B /* PageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageView.swift; sourceTree = ""; }; 81 | 4969F41B257CFB100048E29B /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; 82 | 4969F41C257CFB100048E29B /* UserGrid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserGrid.swift; sourceTree = ""; }; 83 | 497F43B128F757DA0090CAD6 /* WaveformSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformSlider.swift; sourceTree = ""; }; 84 | 4980FD2225CD6333004640D5 /* InfiniteGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfiniteGrid.swift; sourceTree = ""; }; 85 | 4988D84525A1C62E0092BAFF /* UserDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetail.swift; sourceTree = ""; }; 86 | 498C72F22A790AF300AA1AAF /* StatsStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsStack.swift; sourceTree = ""; }; 87 | 4998E12025CADC8300EB986F /* Artwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Artwork.swift; sourceTree = ""; }; 88 | 4999998C25B0886700F42D9B /* WaveformView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformView.swift; sourceTree = ""; }; 89 | 49A89C022A5EA12D0019648F /* Likes.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Likes.json; sourceTree = ""; }; 90 | 49A99D792A7454EE001B8BCB /* Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigation.swift; sourceTree = ""; }; 91 | 49D0E7F62A7A4B7500F2351C /* PlaybackContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackContext.swift; sourceTree = ""; }; 92 | 49D761E22A7A7E6D00735848 /* URLDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLDetail.swift; sourceTree = ""; }; 93 | 49E6259C25BE1E7E005BEF8C /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; 94 | 49FA14BA2589635800CEF925 /* ArrayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayView.swift; sourceTree = ""; }; 95 | 49FA14C52589693E00CEF925 /* InfiniteList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfiniteList.swift; sourceTree = ""; }; 96 | 49FEEBDE2A5B56C9002C8865 /* TouchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBar.swift; sourceTree = ""; }; 97 | /* End PBXFileReference section */ 98 | 99 | /* Begin PBXFrameworksBuildPhase section */ 100 | 4969F3C2257CFA7F0048E29B /* Frameworks */ = { 101 | isa = PBXFrameworksBuildPhase; 102 | buildActionMask = 2147483647; 103 | files = ( 104 | 498286F825969AE800147DBE /* Introspect in Frameworks */, 105 | 49328ECF25C4B71500A2A34D /* SoundCloud in Frameworks */, 106 | 49B154C525C4685D00CE9511 /* URLImage in Frameworks */, 107 | 4980FD4025CD704E004640D5 /* GridStack in Frameworks */, 108 | ); 109 | runOnlyForDeploymentPostprocessing = 0; 110 | }; 111 | /* End PBXFrameworksBuildPhase section */ 112 | 113 | /* Begin PBXGroup section */ 114 | 492AF0CE258FC4A10079035F /* InfiniteView */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 4969F41A257CFB100048E29B /* PageView.swift */, 118 | 49FA14BA2589635800CEF925 /* ArrayView.swift */, 119 | 49FA14C52589693E00CEF925 /* InfiniteList.swift */, 120 | 4980FD2225CD6333004640D5 /* InfiniteGrid.swift */, 121 | ); 122 | path = InfiniteView; 123 | sourceTree = ""; 124 | }; 125 | 49328EB325C4B57D00A2A34D /* Frameworks */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | ); 129 | name = Frameworks; 130 | sourceTree = ""; 131 | }; 132 | 49332BA025961A120034A161 /* Lists */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 4969F418257CFB100048E29B /* TrackList.swift */, 136 | 492AF078258F877E0079035F /* PostList.swift */, 137 | 49332BCE25962E910034A161 /* SearchList.swift */, 138 | 4964297A25DFCF04008AFBD5 /* CommentList.swift */, 139 | 49332BA925961A2A0034A161 /* Rows */, 140 | ); 141 | path = Lists; 142 | sourceTree = ""; 143 | }; 144 | 49332BA925961A2A0034A161 /* Rows */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 490857282A718FFF002D4FD0 /* PostRow.swift */, 148 | 49332BA425961A260034A161 /* TrackRow.swift */, 149 | 49332BAD25961A3B0034A161 /* PlaylistRow.swift */, 150 | 4964299125E054E9008AFBD5 /* CommentRow.swift */, 151 | ); 152 | path = Rows; 153 | sourceTree = ""; 154 | }; 155 | 4969F3BC257CFA7F0048E29B = { 156 | isa = PBXGroup; 157 | children = ( 158 | 49328EC625C4B6F900A2A34D /* SoundCloud */, 159 | 4969F3C7257CFA7F0048E29B /* Nuage */, 160 | 4969F3C6257CFA7F0048E29B /* Products */, 161 | 49328EB325C4B57D00A2A34D /* Frameworks */, 162 | ); 163 | sourceTree = ""; 164 | }; 165 | 4969F3C6257CFA7F0048E29B /* Products */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 4969F3C5257CFA7F0048E29B /* Nuage.app */, 169 | ); 170 | name = Products; 171 | sourceTree = ""; 172 | }; 173 | 4969F3C7257CFA7F0048E29B /* Nuage */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | 4969F3C8257CFA7F0048E29B /* NuageApp.swift */, 177 | 49A99D792A7454EE001B8BCB /* Navigation.swift */, 178 | 4969F410257CFB100048E29B /* Views */, 179 | 4969F40D257CFB100048E29B /* Audio */, 180 | 4969F40B257CFB100048E29B /* Helpers.swift */, 181 | 4969F400257CFB100048E29B /* Preview.swift */, 182 | 4969F3CC257CFA800048E29B /* Assets.xcassets */, 183 | 4969F3D1257CFA800048E29B /* Info.plist */, 184 | 4969F3D2257CFA800048E29B /* Nuage.entitlements */, 185 | 4969F3CE257CFA800048E29B /* Preview Content */, 186 | ); 187 | path = Nuage; 188 | sourceTree = ""; 189 | }; 190 | 4969F3CE257CFA800048E29B /* Preview Content */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 49A89C022A5EA12D0019648F /* Likes.json */, 194 | 4969F3CF257CFA800048E29B /* Preview Assets.xcassets */, 195 | ); 196 | path = "Preview Content"; 197 | sourceTree = ""; 198 | }; 199 | 4969F40D257CFB100048E29B /* Audio */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 4969F40E257CFB100048E29B /* Stream.swift */, 203 | 4969F40F257CFB100048E29B /* StreamPlayer.swift */, 204 | ); 205 | path = Audio; 206 | sourceTree = ""; 207 | }; 208 | 4969F410257CFB100048E29B /* Views */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 4969F41B257CFB100048E29B /* MainView.swift */, 212 | 492AF0CE258FC4A10079035F /* InfiniteView */, 213 | 49332BA025961A120034A161 /* Lists */, 214 | 49D761E42A7A82BC00735848 /* Details */, 215 | 4999998C25B0886700F42D9B /* WaveformView.swift */, 216 | 497F43B128F757DA0090CAD6 /* WaveformSlider.swift */, 217 | 4908204F25C86DD100AC92EC /* PlayerSlider.swift */, 218 | 4969F416257CFB100048E29B /* TrackContextMenu.swift */, 219 | 49D0E7F62A7A4B7500F2351C /* PlaybackContext.swift */, 220 | 4969F413257CFB100048E29B /* LoginView.swift */, 221 | 4969F419257CFB100048E29B /* PlayerView.swift */, 222 | 4969F41C257CFB100048E29B /* UserGrid.swift */, 223 | 49E6259C25BE1E7E005BEF8C /* WebView.swift */, 224 | 4998E12025CADC8300EB986F /* Artwork.swift */, 225 | 493AB3542A6E668C00E20656 /* FeedbackStack.swift */, 226 | 498C72F22A790AF300AA1AAF /* StatsStack.swift */, 227 | 49FEEBDE2A5B56C9002C8865 /* TouchBar.swift */, 228 | ); 229 | path = Views; 230 | sourceTree = ""; 231 | }; 232 | 49D761E42A7A82BC00735848 /* Details */ = { 233 | isa = PBXGroup; 234 | children = ( 235 | 4969F411257CFB100048E29B /* TrackDetail.swift */, 236 | 49D761E22A7A7E6D00735848 /* URLDetail.swift */, 237 | 4988D84525A1C62E0092BAFF /* UserDetail.swift */, 238 | ); 239 | path = Details; 240 | sourceTree = ""; 241 | }; 242 | /* End PBXGroup section */ 243 | 244 | /* Begin PBXNativeTarget section */ 245 | 4969F3C4257CFA7F0048E29B /* Nuage */ = { 246 | isa = PBXNativeTarget; 247 | buildConfigurationList = 4969F3EB257CFA800048E29B /* Build configuration list for PBXNativeTarget "Nuage" */; 248 | buildPhases = ( 249 | 4969F3C1257CFA7F0048E29B /* Sources */, 250 | 4969F3C2257CFA7F0048E29B /* Frameworks */, 251 | 4969F3C3257CFA7F0048E29B /* Resources */, 252 | ); 253 | buildRules = ( 254 | ); 255 | dependencies = ( 256 | 49328ECB25C4B70F00A2A34D /* PBXTargetDependency */, 257 | 49328ECD25C4B70F00A2A34D /* PBXTargetDependency */, 258 | ); 259 | name = Nuage; 260 | packageProductDependencies = ( 261 | 498286F725969AE800147DBE /* Introspect */, 262 | 49B154C425C4685D00CE9511 /* URLImage */, 263 | 49328ECE25C4B71500A2A34D /* SoundCloud */, 264 | 4980FD3F25CD704E004640D5 /* GridStack */, 265 | ); 266 | productName = Nuage; 267 | productReference = 4969F3C5257CFA7F0048E29B /* Nuage.app */; 268 | productType = "com.apple.product-type.application"; 269 | }; 270 | /* End PBXNativeTarget section */ 271 | 272 | /* Begin PBXProject section */ 273 | 4969F3BD257CFA7F0048E29B /* Project object */ = { 274 | isa = PBXProject; 275 | attributes = { 276 | BuildIndependentTargetsInParallel = YES; 277 | LastSwiftUpdateCheck = 1220; 278 | LastUpgradeCheck = 1430; 279 | TargetAttributes = { 280 | 4969F3C4257CFA7F0048E29B = { 281 | CreatedOnToolsVersion = 12.2; 282 | }; 283 | }; 284 | }; 285 | buildConfigurationList = 4969F3C0257CFA7F0048E29B /* Build configuration list for PBXProject "Nuage" */; 286 | compatibilityVersion = "Xcode 9.3"; 287 | developmentRegion = en; 288 | hasScannedForEncodings = 0; 289 | knownRegions = ( 290 | en, 291 | Base, 292 | ); 293 | mainGroup = 4969F3BC257CFA7F0048E29B; 294 | packageReferences = ( 295 | 498286F625969AE800147DBE /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */, 296 | 49B154C325C4685D00CE9511 /* XCRemoteSwiftPackageReference "url-image" */, 297 | 4980FD3E25CD704E004640D5 /* XCRemoteSwiftPackageReference "GridStack" */, 298 | ); 299 | productRefGroup = 4969F3C6257CFA7F0048E29B /* Products */; 300 | projectDirPath = ""; 301 | projectRoot = ""; 302 | targets = ( 303 | 4969F3C4257CFA7F0048E29B /* Nuage */, 304 | ); 305 | }; 306 | /* End PBXProject section */ 307 | 308 | /* Begin PBXResourcesBuildPhase section */ 309 | 4969F3C3257CFA7F0048E29B /* Resources */ = { 310 | isa = PBXResourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 4969F3D0257CFA800048E29B /* Preview Assets.xcassets in Resources */, 314 | 49A89C032A5EA1B70019648F /* Likes.json in Resources */, 315 | 4969F3CD257CFA800048E29B /* Assets.xcassets in Resources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXResourcesBuildPhase section */ 320 | 321 | /* Begin PBXSourcesBuildPhase section */ 322 | 4969F3C1257CFA7F0048E29B /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | 49332BA525961A260034A161 /* TrackRow.swift in Sources */, 327 | 4969F433257CFB100048E29B /* TrackList.swift in Sources */, 328 | 4969F435257CFB100048E29B /* PageView.swift in Sources */, 329 | 49A99D7A2A7454EE001B8BCB /* Navigation.swift in Sources */, 330 | 49FA14BB2589635800CEF925 /* ArrayView.swift in Sources */, 331 | 4969F42A257CFB100048E29B /* Stream.swift in Sources */, 332 | 49FEEBDF2A5B56C9002C8865 /* TouchBar.swift in Sources */, 333 | 4969F434257CFB100048E29B /* PlayerView.swift in Sources */, 334 | 497F43B228F757DA0090CAD6 /* WaveformSlider.swift in Sources */, 335 | 4969F42B257CFB100048E29B /* StreamPlayer.swift in Sources */, 336 | 4969F42C257CFB100048E29B /* TrackDetail.swift in Sources */, 337 | 4969F437257CFB100048E29B /* UserGrid.swift in Sources */, 338 | 49D761E32A7A7E6D00735848 /* URLDetail.swift in Sources */, 339 | 493AB3552A6E668C00E20656 /* FeedbackStack.swift in Sources */, 340 | 49E6259D25BE1E7E005BEF8C /* WebView.swift in Sources */, 341 | 4988D84625A1C62E0092BAFF /* UserDetail.swift in Sources */, 342 | 4969F431257CFB100048E29B /* TrackContextMenu.swift in Sources */, 343 | 49D0E7F72A7A4B7500F2351C /* PlaybackContext.swift in Sources */, 344 | 4908205025C86DD100AC92EC /* PlayerSlider.swift in Sources */, 345 | 4999998D25B0886700F42D9B /* WaveformView.swift in Sources */, 346 | 49332BAE25961A3B0034A161 /* PlaylistRow.swift in Sources */, 347 | 498C72F32A790AF300AA1AAF /* StatsStack.swift in Sources */, 348 | 4969F41E257CFB100048E29B /* Preview.swift in Sources */, 349 | 4980FD2325CD6333004640D5 /* InfiniteGrid.swift in Sources */, 350 | 4964297B25DFCF04008AFBD5 /* CommentList.swift in Sources */, 351 | 4969F3C9257CFA7F0048E29B /* NuageApp.swift in Sources */, 352 | 4969F436257CFB100048E29B /* MainView.swift in Sources */, 353 | 4998E12125CADC8300EB986F /* Artwork.swift in Sources */, 354 | 4969F428257CFB100048E29B /* Helpers.swift in Sources */, 355 | 49FA14C62589693E00CEF925 /* InfiniteList.swift in Sources */, 356 | 490857292A718FFF002D4FD0 /* PostRow.swift in Sources */, 357 | 4969F42E257CFB100048E29B /* LoginView.swift in Sources */, 358 | 492AF079258F877E0079035F /* PostList.swift in Sources */, 359 | 4964299225E054E9008AFBD5 /* CommentRow.swift in Sources */, 360 | 49332BCF25962E910034A161 /* SearchList.swift in Sources */, 361 | ); 362 | runOnlyForDeploymentPostprocessing = 0; 363 | }; 364 | /* End PBXSourcesBuildPhase section */ 365 | 366 | /* Begin PBXTargetDependency section */ 367 | 49328ECB25C4B70F00A2A34D /* PBXTargetDependency */ = { 368 | isa = PBXTargetDependency; 369 | productRef = 49328ECA25C4B70F00A2A34D /* SoundCloud */; 370 | }; 371 | 49328ECD25C4B70F00A2A34D /* PBXTargetDependency */ = { 372 | isa = PBXTargetDependency; 373 | productRef = 49328ECC25C4B70F00A2A34D /* StackNavigationView */; 374 | }; 375 | /* End PBXTargetDependency section */ 376 | 377 | /* Begin XCBuildConfiguration section */ 378 | 4969F3E9257CFA800048E29B /* Debug */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ALWAYS_SEARCH_USER_PATHS = NO; 382 | CLANG_ANALYZER_NONNULL = YES; 383 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 384 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 385 | CLANG_CXX_LIBRARY = "libc++"; 386 | CLANG_ENABLE_MODULES = YES; 387 | CLANG_ENABLE_OBJC_ARC = YES; 388 | CLANG_ENABLE_OBJC_WEAK = YES; 389 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 390 | CLANG_WARN_BOOL_CONVERSION = YES; 391 | CLANG_WARN_COMMA = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 394 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 395 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 396 | CLANG_WARN_EMPTY_BODY = YES; 397 | CLANG_WARN_ENUM_CONVERSION = YES; 398 | CLANG_WARN_INFINITE_RECURSION = YES; 399 | CLANG_WARN_INT_CONVERSION = YES; 400 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 401 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 402 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 403 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 404 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 405 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 406 | CLANG_WARN_STRICT_PROTOTYPES = YES; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 409 | CLANG_WARN_UNREACHABLE_CODE = YES; 410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 411 | COPY_PHASE_STRIP = NO; 412 | DEAD_CODE_STRIPPING = YES; 413 | DEBUG_INFORMATION_FORMAT = dwarf; 414 | ENABLE_STRICT_OBJC_MSGSEND = YES; 415 | ENABLE_TESTABILITY = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu11; 417 | GCC_DYNAMIC_NO_PIC = NO; 418 | GCC_NO_COMMON_BLOCKS = YES; 419 | GCC_OPTIMIZATION_LEVEL = 0; 420 | GCC_PREPROCESSOR_DEFINITIONS = ( 421 | "DEBUG=1", 422 | "$(inherited)", 423 | ); 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | MACOSX_DEPLOYMENT_TARGET = 13.0; 431 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 432 | MTL_FAST_MATH = YES; 433 | ONLY_ACTIVE_ARCH = YES; 434 | SDKROOT = macosx; 435 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 436 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 437 | }; 438 | name = Debug; 439 | }; 440 | 4969F3EA257CFA800048E29B /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_SEARCH_USER_PATHS = NO; 444 | CLANG_ANALYZER_NONNULL = YES; 445 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 446 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 447 | CLANG_CXX_LIBRARY = "libc++"; 448 | CLANG_ENABLE_MODULES = YES; 449 | CLANG_ENABLE_OBJC_ARC = YES; 450 | CLANG_ENABLE_OBJC_WEAK = YES; 451 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_COMMA = YES; 454 | CLANG_WARN_CONSTANT_CONVERSION = YES; 455 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 456 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 457 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 458 | CLANG_WARN_EMPTY_BODY = YES; 459 | CLANG_WARN_ENUM_CONVERSION = YES; 460 | CLANG_WARN_INFINITE_RECURSION = YES; 461 | CLANG_WARN_INT_CONVERSION = YES; 462 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 463 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 464 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 465 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 466 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 467 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 468 | CLANG_WARN_STRICT_PROTOTYPES = YES; 469 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 470 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 471 | CLANG_WARN_UNREACHABLE_CODE = YES; 472 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 473 | COPY_PHASE_STRIP = NO; 474 | DEAD_CODE_STRIPPING = YES; 475 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 476 | ENABLE_NS_ASSERTIONS = NO; 477 | ENABLE_STRICT_OBJC_MSGSEND = YES; 478 | GCC_C_LANGUAGE_STANDARD = gnu11; 479 | GCC_NO_COMMON_BLOCKS = YES; 480 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 481 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 482 | GCC_WARN_UNDECLARED_SELECTOR = YES; 483 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 484 | GCC_WARN_UNUSED_FUNCTION = YES; 485 | GCC_WARN_UNUSED_VARIABLE = YES; 486 | MACOSX_DEPLOYMENT_TARGET = 13.0; 487 | MTL_ENABLE_DEBUG_INFO = NO; 488 | MTL_FAST_MATH = YES; 489 | SDKROOT = macosx; 490 | SWIFT_COMPILATION_MODE = wholemodule; 491 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 492 | }; 493 | name = Release; 494 | }; 495 | 4969F3EC257CFA800048E29B /* Debug */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 499 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 500 | CODE_SIGN_ENTITLEMENTS = Nuage/Nuage.entitlements; 501 | CODE_SIGN_IDENTITY = "-"; 502 | CODE_SIGN_STYLE = Automatic; 503 | COMBINE_HIDPI_IMAGES = YES; 504 | CURRENT_PROJECT_VERSION = 1; 505 | DEAD_CODE_STRIPPING = YES; 506 | DEVELOPMENT_ASSET_PATHS = "Nuage/Preview\\ Content Nuage/Preview\\ Content/Likes.json"; 507 | ENABLE_PREVIEWS = YES; 508 | INFOPLIST_FILE = Nuage/Info.plist; 509 | INFOPLIST_KEY_CFBundleDisplayName = Nuage; 510 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; 511 | LD_RUNPATH_SEARCH_PATHS = ( 512 | "$(inherited)", 513 | "@executable_path/../Frameworks", 514 | ); 515 | MACOSX_DEPLOYMENT_TARGET = 13.0; 516 | MARKETING_VERSION = 0.0.8; 517 | PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SWIFT_VERSION = 5.0; 520 | }; 521 | name = Debug; 522 | }; 523 | 4969F3ED257CFA800048E29B /* Release */ = { 524 | isa = XCBuildConfiguration; 525 | buildSettings = { 526 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 527 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 528 | CODE_SIGN_ENTITLEMENTS = Nuage/Nuage.entitlements; 529 | CODE_SIGN_IDENTITY = "-"; 530 | CODE_SIGN_STYLE = Automatic; 531 | COMBINE_HIDPI_IMAGES = YES; 532 | CURRENT_PROJECT_VERSION = 1; 533 | DEAD_CODE_STRIPPING = YES; 534 | DEVELOPMENT_ASSET_PATHS = "Nuage/Preview\\ Content Nuage/Preview\\ Content/Likes.json"; 535 | ENABLE_PREVIEWS = YES; 536 | INFOPLIST_FILE = Nuage/Info.plist; 537 | INFOPLIST_KEY_CFBundleDisplayName = Nuage; 538 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; 539 | LD_RUNPATH_SEARCH_PATHS = ( 540 | "$(inherited)", 541 | "@executable_path/../Frameworks", 542 | ); 543 | MACOSX_DEPLOYMENT_TARGET = 13.0; 544 | MARKETING_VERSION = 0.0.8; 545 | PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | SWIFT_VERSION = 5.0; 548 | }; 549 | name = Release; 550 | }; 551 | /* End XCBuildConfiguration section */ 552 | 553 | /* Begin XCConfigurationList section */ 554 | 4969F3C0257CFA7F0048E29B /* Build configuration list for PBXProject "Nuage" */ = { 555 | isa = XCConfigurationList; 556 | buildConfigurations = ( 557 | 4969F3E9257CFA800048E29B /* Debug */, 558 | 4969F3EA257CFA800048E29B /* Release */, 559 | ); 560 | defaultConfigurationIsVisible = 0; 561 | defaultConfigurationName = Release; 562 | }; 563 | 4969F3EB257CFA800048E29B /* Build configuration list for PBXNativeTarget "Nuage" */ = { 564 | isa = XCConfigurationList; 565 | buildConfigurations = ( 566 | 4969F3EC257CFA800048E29B /* Debug */, 567 | 4969F3ED257CFA800048E29B /* Release */, 568 | ); 569 | defaultConfigurationIsVisible = 0; 570 | defaultConfigurationName = Release; 571 | }; 572 | /* End XCConfigurationList section */ 573 | 574 | /* Begin XCRemoteSwiftPackageReference section */ 575 | 4980FD3E25CD704E004640D5 /* XCRemoteSwiftPackageReference "GridStack" */ = { 576 | isa = XCRemoteSwiftPackageReference; 577 | repositoryURL = "https://github.com/pietropizzi/GridStack"; 578 | requirement = { 579 | kind = upToNextMajorVersion; 580 | minimumVersion = 0.4.1; 581 | }; 582 | }; 583 | 498286F625969AE800147DBE /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { 584 | isa = XCRemoteSwiftPackageReference; 585 | repositoryURL = "https://github.com/siteline/SwiftUI-Introspect"; 586 | requirement = { 587 | kind = upToNextMajorVersion; 588 | minimumVersion = 0.1.2; 589 | }; 590 | }; 591 | 49B154C325C4685D00CE9511 /* XCRemoteSwiftPackageReference "url-image" */ = { 592 | isa = XCRemoteSwiftPackageReference; 593 | repositoryURL = "https://github.com/dmytro-anokhin/url-image"; 594 | requirement = { 595 | kind = upToNextMajorVersion; 596 | minimumVersion = 2.2.1; 597 | }; 598 | }; 599 | /* End XCRemoteSwiftPackageReference section */ 600 | 601 | /* Begin XCSwiftPackageProductDependency section */ 602 | 49328ECA25C4B70F00A2A34D /* SoundCloud */ = { 603 | isa = XCSwiftPackageProductDependency; 604 | productName = SoundCloud; 605 | }; 606 | 49328ECC25C4B70F00A2A34D /* StackNavigationView */ = { 607 | isa = XCSwiftPackageProductDependency; 608 | productName = StackNavigationView; 609 | }; 610 | 49328ECE25C4B71500A2A34D /* SoundCloud */ = { 611 | isa = XCSwiftPackageProductDependency; 612 | productName = SoundCloud; 613 | }; 614 | 4980FD3F25CD704E004640D5 /* GridStack */ = { 615 | isa = XCSwiftPackageProductDependency; 616 | package = 4980FD3E25CD704E004640D5 /* XCRemoteSwiftPackageReference "GridStack" */; 617 | productName = GridStack; 618 | }; 619 | 498286F725969AE800147DBE /* Introspect */ = { 620 | isa = XCSwiftPackageProductDependency; 621 | package = 498286F625969AE800147DBE /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; 622 | productName = Introspect; 623 | }; 624 | 49B154C425C4685D00CE9511 /* URLImage */ = { 625 | isa = XCSwiftPackageProductDependency; 626 | package = 49B154C325C4685D00CE9511 /* XCRemoteSwiftPackageReference "url-image" */; 627 | productName = URLImage; 628 | }; 629 | /* End XCSwiftPackageProductDependency section */ 630 | }; 631 | rootObject = 4969F3BD257CFA7F0048E29B /* Project object */; 632 | } 633 | -------------------------------------------------------------------------------- /Nuage.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Nuage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Nuage.xcodeproj/xcshareddata/xcschemes/Nuage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "45", 9 | "green" : "87", 10 | "red" : "255" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon128.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon128@2x.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon16.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon16@2x.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon256.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon256@2x.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon32.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon32@2x.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon512.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lbrndnr/nuage-macos/d1f7553e19626ffbd0b7fc5ebff6b8104e3fcf76/Nuage/Assets.xcassets/AppIcon.appiconset/AppIcon512@2x.png -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "AppIcon16.png", 5 | "idiom" : "mac", 6 | "scale" : "1x", 7 | "size" : "16x16" 8 | }, 9 | { 10 | "filename" : "AppIcon16@2x.png", 11 | "idiom" : "mac", 12 | "scale" : "2x", 13 | "size" : "16x16" 14 | }, 15 | { 16 | "filename" : "AppIcon32.png", 17 | "idiom" : "mac", 18 | "scale" : "1x", 19 | "size" : "32x32" 20 | }, 21 | { 22 | "filename" : "AppIcon32@2x.png", 23 | "idiom" : "mac", 24 | "scale" : "2x", 25 | "size" : "32x32" 26 | }, 27 | { 28 | "filename" : "AppIcon128.png", 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "filename" : "AppIcon128@2x.png", 35 | "idiom" : "mac", 36 | "scale" : "2x", 37 | "size" : "128x128" 38 | }, 39 | { 40 | "filename" : "AppIcon256.png", 41 | "idiom" : "mac", 42 | "scale" : "1x", 43 | "size" : "256x256" 44 | }, 45 | { 46 | "filename" : "AppIcon256@2x.png", 47 | "idiom" : "mac", 48 | "scale" : "2x", 49 | "size" : "256x256" 50 | }, 51 | { 52 | "filename" : "AppIcon512.png", 53 | "idiom" : "mac", 54 | "scale" : "1x", 55 | "size" : "512x512" 56 | }, 57 | { 58 | "filename" : "AppIcon512@2x.png", 59 | "idiom" : "mac", 60 | "scale" : "2x", 61 | "size" : "512x512" 62 | } 63 | ], 64 | "info" : { 65 | "author" : "xcode", 66 | "version" : 1 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Nuage/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Nuage/Audio/Stream.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Stream.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 26.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import AVFoundation 10 | import Combine 11 | import SoundCloud 12 | 13 | struct NoStreamError: Error {} 14 | 15 | extension Track: Streamable { 16 | 17 | func prepare() -> AnyPublisher { 18 | guard let url = streamURL else { return Fail(error: NoStreamError()).eraseToAnyPublisher() } 19 | return SoundCloud.shared.get(.audioFile(url)) 20 | .map { AVURLAsset(url: $0) } 21 | .eraseToAnyPublisher() 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Nuage/Audio/StreamPlayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StreamPlayer.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 25.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import AppKit 10 | import SwiftUI 11 | import AVFoundation 12 | import Combine 13 | import MediaPlayer 14 | import URLImage 15 | import SoundCloud 16 | 17 | protocol Streamable { 18 | 19 | func prepare() -> AnyPublisher 20 | 21 | } 22 | 23 | private let volumeKey = "volume" 24 | 25 | class StreamPlayer: ObservableObject { 26 | 27 | private var subscriptions = Set() 28 | 29 | private var player: AVPlayer 30 | private(set) var queue = [Track]() { 31 | didSet { 32 | reloadQueueOrder() 33 | } 34 | } 35 | private var queueOrder = [Int]() 36 | private(set) var currentStreamIndex: Int? { 37 | didSet { 38 | currentStream = self.currentStreamIndex.map { queue[queueOrder[$0]] } 39 | } 40 | } 41 | 42 | @Published private(set) var currentStream: Track? 43 | 44 | @AppStorage("shuffleQueue") var shuffleQueue: Bool = false { 45 | didSet { 46 | // Here we have to unravel the index again 47 | // So that we end up in the same spot of the queue 48 | // This should not trigger $currentStream, since it's the same track 49 | let index = currentStreamIndex.map { queueOrder[$0] } 50 | 51 | reloadQueueOrder() 52 | 53 | if let index = index { 54 | currentStreamIndex = queueOrder.firstIndex(of: index) 55 | } 56 | } 57 | } 58 | @AppStorage("repeatQueue") var repeatQueue: Bool = false 59 | 60 | @Published var volume: Float = 0.5 { 61 | didSet { 62 | if volume > 1 { volume = 1 } 63 | else if volume < 0 { volume = 0 } 64 | 65 | player.volume = volume 66 | UserDefaults.standard.set(volume, forKey: volumeKey) 67 | } 68 | } 69 | 70 | private var shouldSeek = true 71 | @Published var progress: TimeInterval = 0.0 { 72 | didSet { 73 | if shouldSeek { 74 | let time = CMTime(seconds: progress, preferredTimescale: 1) 75 | player.seek(to: time) 76 | updateNowPlayingInfo(with: time) 77 | } 78 | } 79 | } 80 | 81 | @Published private(set) var isPlaying = false 82 | 83 | // MARK: - Initialization 84 | 85 | init() { 86 | self.player = AVPlayer() 87 | self.player.allowsExternalPlayback = false 88 | 89 | let defaults = UserDefaults.standard 90 | if defaults.object(forKey: volumeKey) != nil { 91 | self.volume = defaults.float(forKey: volumeKey) 92 | } 93 | 94 | let interval = CMTime(value: 1, timescale: 1) 95 | player.addPeriodicTimeObserver(forInterval: interval, queue: .main) { [weak self] time in 96 | guard let self = self else { return } 97 | self.shouldSeek = false 98 | self.progress = time.seconds 99 | self.shouldSeek = true 100 | } 101 | 102 | player.publisher(for: \.timeControlStatus) 103 | .map { $0 != .paused } 104 | .assign(to: \.isPlaying, on: self) 105 | .store(in: &subscriptions) 106 | 107 | player.publisher(for: \.timeControlStatus) 108 | .sink { _ in self.updateNowPlayingInfo() } 109 | .store(in: &subscriptions) 110 | 111 | addRemoteCommandTargets() 112 | } 113 | 114 | deinit { 115 | NotificationCenter.default.removeObserver(self) 116 | } 117 | 118 | // MARK: - Playback 119 | 120 | func restartPlayback() { 121 | player.seek(to: .zero) 122 | player.play() 123 | } 124 | 125 | func togglePlayback() { 126 | if isPlaying { 127 | pause() 128 | } 129 | else { 130 | resume() 131 | } 132 | } 133 | 134 | func resume(from startIndex: Int? = nil) { 135 | guard let idx = startIndex ?? currentStreamIndex, idx < queue.count else { return } 136 | 137 | let newStream = queue[queueOrder[idx]] 138 | if currentStream == newStream { 139 | player.play() 140 | } 141 | else { 142 | self.currentStreamIndex = idx 143 | self.shouldSeek = false 144 | self.progress = 0 145 | self.shouldSeek = true 146 | 147 | let track = currentStream! 148 | track.prepare() 149 | .receive(on: RunLoop.main) 150 | .sink(receiveCompletion: { completion in 151 | if case let .failure(error) = completion { 152 | print("Failed to stream track: \(error)") 153 | } 154 | }, receiveValue: { [weak self] asset in 155 | guard let self = self else { return } 156 | 157 | let item = AVPlayerItem(asset: asset) 158 | 159 | self.player.replaceCurrentItem(with: item) 160 | self.player.play() 161 | 162 | NotificationCenter.default.addObserver(self, selector: #selector(self.advanceForward), name: Notification.Name.AVPlayerItemDidPlayToEndTime, object: item) 163 | 164 | self.updateNowPlayingInfo() 165 | }).store(in: &subscriptions) 166 | } 167 | } 168 | 169 | func pause() { 170 | player.pause() 171 | } 172 | 173 | func play(_ tracks: [Track], from idx: Int) { 174 | guard !(currentStreamIndex == idx && queue == tracks) else { 175 | restartPlayback() 176 | return 177 | } 178 | 179 | pause() 180 | queue = tracks 181 | 182 | // If we're in shuffle mode, we first have to unravel `idx` 183 | // Otherwise we start playing a random track 184 | let start = shuffleQueue ? queueOrder.firstIndex(of: idx) : idx 185 | resume(from: start) 186 | } 187 | 188 | @objc func advanceForward() { 189 | guard let idx = currentStreamIndex else { return } 190 | player.replaceCurrentItem(with: nil) 191 | if queue.count > idx + 1 { 192 | resume(from: idx + 1) 193 | } 194 | else if repeatQueue { 195 | resume(from: 0) 196 | } 197 | else { 198 | queue = [] 199 | pause() 200 | } 201 | } 202 | 203 | func advanceBackward() { 204 | guard let idx = currentStreamIndex else { return } 205 | 206 | if player.currentTime() < CMTime(value: 15, timescale: 1) { 207 | player.replaceCurrentItem(with: nil) 208 | if idx > 0 { 209 | resume(from: idx - 1) 210 | } 211 | else { 212 | currentStreamIndex = nil 213 | } 214 | } 215 | else { 216 | restartPlayback() 217 | } 218 | } 219 | 220 | func seekForward() { 221 | progress += 15 222 | } 223 | 224 | func seekBackward() { 225 | progress -= 15 226 | } 227 | 228 | func reset() { 229 | pause() 230 | player.replaceCurrentItem(with: nil) 231 | queue = [] 232 | currentStreamIndex = nil 233 | } 234 | 235 | func enqueue(_ streams: [Track], playNext: Bool = false) { 236 | guard streams.count > 0 else { return } 237 | 238 | if playNext { 239 | queue = streams + queue 240 | } 241 | else { 242 | queue = queue + streams 243 | } 244 | } 245 | 246 | private func reloadQueueOrder() { 247 | queueOrder = Array(0..(time: Time) -> String { 25 | return durationFormatter.string(from: TimeInterval(time)) ?? "00:00:00" 26 | // guard var text = durationFormatter.string(from: TimeInterval(time)) else { 27 | // return "00:00" 28 | // } 29 | // 30 | // let idx = text.index(text.startIndex, offsetBy: 3) 31 | // if text.prefix(upTo: idx) == "00:" { 32 | // text = String(text.suffix(from: idx)) 33 | // } 34 | // 35 | // return text 36 | } 37 | 38 | extension AnyCancellable { 39 | 40 | func store(in dictionary: inout Dictionary, key: T) { 41 | dictionary[key] = self 42 | } 43 | 44 | } 45 | 46 | protocol Filterable { 47 | 48 | func contains(_ text: String) -> Bool 49 | 50 | } 51 | 52 | extension User: Filterable { 53 | 54 | func contains(_ text: String) -> Bool { 55 | return username.containsCaseInsensitive(text) || name.containsCaseInsensitive(text) 56 | } 57 | 58 | } 59 | 60 | extension Track: Filterable { 61 | 62 | func contains(_ text: String) -> Bool { 63 | return title.containsCaseInsensitive(text) || (description?.containsCaseInsensitive(text) ?? false) 64 | } 65 | 66 | } 67 | 68 | extension Post: Filterable { 69 | 70 | func contains(_ text: String) -> Bool { 71 | return user.contains(text) || tracks.contains { $0.contains(text) } 72 | } 73 | 74 | } 75 | 76 | extension UserPlaylist: Filterable { 77 | 78 | func contains(_ text: String) -> Bool { 79 | let contained = title.containsCaseInsensitive(text) || (description?.containsCaseInsensitive(text) ?? false) 80 | if let tracks = tracks { 81 | return contained || tracks.contains { $0.contains(text) } 82 | } 83 | return contained 84 | 85 | } 86 | } 87 | 88 | extension SystemPlaylist: Filterable { 89 | 90 | func contains(_ text: String) -> Bool { 91 | let contained = title.containsCaseInsensitive(text) || (description?.containsCaseInsensitive(text) ?? false) 92 | if let tracks = tracks { 93 | return contained || tracks.contains { $0.contains(text) } 94 | } 95 | return contained 96 | 97 | } 98 | } 99 | 100 | extension Like: Filterable where T: Filterable { 101 | 102 | func contains(_ text: String) -> Bool { 103 | return item.contains(text) 104 | } 105 | 106 | } 107 | 108 | extension Some: Filterable { 109 | 110 | func contains(_ text: String) -> Bool { 111 | switch self { 112 | case .track(let track): return track.contains(text) 113 | case .userPlaylist(let playlist): return playlist.contains(text) 114 | case .systemPlaylist(let playlist): return playlist.contains(text) 115 | case .user(let user): return user.contains(text) 116 | } 117 | } 118 | 119 | } 120 | 121 | extension Comment: Filterable { 122 | 123 | func contains(_ text: String) -> Bool { 124 | return body.contains(text) || user.contains(text) 125 | } 126 | 127 | } 128 | 129 | extension HistoryItem: Filterable { 130 | 131 | func contains(_ text: String) -> Bool { 132 | return track.contains(text) 133 | } 134 | 135 | } 136 | 137 | extension Recommendation: Filterable { 138 | 139 | func contains(_ text: String) -> Bool { 140 | return user.contains(text) 141 | } 142 | 143 | } 144 | 145 | extension String { 146 | 147 | fileprivate func containsCaseInsensitive(_ text: String) -> Bool { 148 | return range(of: text, options: .caseInsensitive) != nil 149 | } 150 | 151 | } 152 | 153 | protocol DateComparable: Comparable { 154 | 155 | var date: Date { get } 156 | 157 | } 158 | 159 | extension DateComparable { 160 | 161 | public static func < (lhs: Self, rhs: Self) -> Bool { 162 | return lhs.date < rhs.date 163 | } 164 | 165 | } 166 | 167 | extension HistoryItem: DateComparable {} 168 | extension Post: DateComparable {} 169 | extension Track: DateComparable {} 170 | extension UserPlaylist: DateComparable {} 171 | 172 | @ViewBuilder func RemoteImage(url: URL?, cornerRadius: CGFloat) -> some View { 173 | let placeholder = Rectangle() 174 | .foregroundColor(Color(NSColor.underPageBackgroundColor)) 175 | .cornerRadius(cornerRadius) 176 | 177 | if let url = url { 178 | URLImage(url: url, 179 | empty: { placeholder }, 180 | inProgress: { _ in placeholder }, 181 | failure: { _, _ in placeholder }, 182 | content: { image in 183 | image.resizable() 184 | .cornerRadius(cornerRadius) 185 | }) 186 | .id(url) 187 | } 188 | else { 189 | placeholder 190 | } 191 | } 192 | 193 | extension Color { 194 | 195 | init(hex: UInt, alpha: Double = 1) { 196 | let red = Double((hex >> 16) & 0xff) / 255 197 | let green = Double((hex >> 08) & 0xff) / 255 198 | let blue = Double((hex >> 00) & 0xff) / 255 199 | self.init(.sRGB, red: red, green: green, blue: blue, opacity: alpha) 200 | } 201 | 202 | } 203 | 204 | extension View { 205 | 206 | @ViewBuilder func `if`(_ condition: Bool, transform: (Self) -> Content) -> some View { 207 | if condition { 208 | transform(self) 209 | } else { 210 | self 211 | } 212 | } 213 | 214 | } 215 | 216 | extension String { 217 | 218 | func withAttributedLinks(useAppURLScheme: Bool = true) -> AttributedString { 219 | var linkRanges = [(NSRange, URL)]() 220 | var handleRanges = [(NSRange, URL)]() 221 | do { 222 | let detector = try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) 223 | detector.enumerateMatches(in: self, range: NSMakeRange(0, count)) { result, _, _ in 224 | if let match = result, 225 | var url = match.url { 226 | if url.absoluteString.contains("soundcloud") && useAppURLScheme { 227 | var components = URLComponents(url: url, resolvingAgainstBaseURL: true) 228 | components?.scheme = "nuage" 229 | url = components?.url ?? url 230 | } 231 | linkRanges.append((match.range, url)) 232 | } 233 | } 234 | 235 | let handle = /@([a-zA-Z0-9_-]{3,})/ 236 | for match in self.matches(of: handle) { 237 | let range = NSRange(match.range, in: self) 238 | let username = match.output.1 239 | let scheme = useAppURLScheme ? "nuage" : "https" 240 | let url = URL(string: "\(scheme)://soundcloud.com/\(username)")! 241 | 242 | handleRanges.append((range, url)) 243 | } 244 | } 245 | catch { 246 | print("Failed to parse text: \(error)") 247 | } 248 | 249 | let attributedText = NSMutableAttributedString(string: self) 250 | for (range, url) in (linkRanges + handleRanges) { 251 | let attributes: [NSAttributedString.Key: Any] = [ 252 | .link: url, 253 | .foregroundColor: NSColor.controlAccentColor, 254 | ] 255 | 256 | attributedText.addAttributes(attributes, range: range) 257 | } 258 | 259 | return AttributedString(attributedText) 260 | } 261 | 262 | } 263 | -------------------------------------------------------------------------------- /Nuage/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleURLTypes 20 | 21 | 22 | CFBundleTypeRole 23 | Viewer 24 | CFBundleURLName 25 | ch.laurinbrandner.nuage 26 | CFBundleURLSchemes 27 | 28 | nuage 29 | 30 | 31 | 32 | CFBundleVersion 33 | $(CURRENT_PROJECT_VERSION) 34 | LSMinimumSystemVersion 35 | $(MACOSX_DEPLOYMENT_TARGET) 36 | NSAppTransportSecurity 37 | 38 | NSAllowsArbitraryLoads 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Nuage/Navigation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Navigation.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 28.07.23. 6 | // 7 | 8 | import SoundCloud 9 | 10 | private let userPlaylistSeparator = "@@USERPLAYLIST@@" 11 | private let systemPlaylistSeparator = "@@SYSTEMPLAYLIST@@" 12 | 13 | enum SidebarItem: RawRepresentable { 14 | case stream 15 | case likes 16 | case history 17 | case following 18 | case userPlaylist(String, String) 19 | case systemPlaylist(String, String) 20 | 21 | init?(rawValue: String) { 22 | switch rawValue { 23 | case "stream": self = .stream 24 | case "likes": self = .likes 25 | case "history": self = .history 26 | case "following": self = .following 27 | default: 28 | if rawValue.contains(userPlaylistSeparator) { 29 | let components = rawValue.split(separator: userPlaylistSeparator) 30 | guard components.count == 2 else { return nil } 31 | 32 | self = .userPlaylist(String(components[0]), String(components[1])) 33 | } 34 | else { 35 | let components = rawValue.split(separator: systemPlaylistSeparator) 36 | guard components.count == 2 else { return nil } 37 | 38 | self = .systemPlaylist(String(components[0]), String(components[1])) 39 | } 40 | } 41 | } 42 | 43 | var rawValue: String { 44 | switch self { 45 | case .stream: return "stream" 46 | case .likes: return "likes" 47 | case .history: return "history" 48 | case .following: return "following" 49 | case .userPlaylist(let name, let id): return name+userPlaylistSeparator+id 50 | case .systemPlaylist(let name, let id): return name+systemPlaylistSeparator+id 51 | } 52 | } 53 | 54 | var title: String { 55 | switch self { 56 | case .userPlaylist(let name, _): return name 57 | case .systemPlaylist(let name, _): return name 58 | default: return rawValue.capitalized 59 | } 60 | } 61 | 62 | var imageName: String? { 63 | switch self { 64 | case .stream: return "bolt.horizontal.fill" 65 | case .likes: return "heart.fill" 66 | case .history: return "clock.fill" 67 | case .following: return "person.2.fill" 68 | default: return nil 69 | } 70 | } 71 | 72 | } 73 | 74 | extension SidebarItem: Hashable { 75 | 76 | func hash(into hasher: inout Hasher) { 77 | hasher.combine(title.hashValue) 78 | if case .userPlaylist(_, let id) = self { 79 | hasher.combine(id.hashValue) 80 | } 81 | else if case .systemPlaylist(_, let urn) = self { 82 | hasher.combine(urn.hashValue) 83 | } 84 | } 85 | 86 | } 87 | 88 | extension SidebarItem: Identifiable { 89 | 90 | var id: String { 91 | if case .userPlaylist(_, let id) = self { 92 | return id 93 | } 94 | if case .systemPlaylist(_, let urn) = self { 95 | return urn 96 | } 97 | return title 98 | } 99 | 100 | } 101 | 102 | enum Station: Hashable { 103 | case track(Track) 104 | case artist(User) 105 | } 106 | -------------------------------------------------------------------------------- /Nuage/Nuage.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | com.apple.security.network.client 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Nuage/NuageApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NuageApp.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 06.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | private let accessTokenKey = "accessToken" 13 | private let accessTokenExpiryDateKey = "accessTokenExpiryDate" 14 | private let userKey = "user" 15 | private let playlistsKey = "playlists" 16 | private let likesKey = "likes" 17 | private let postsKey = "posts" 18 | 19 | private struct ShowCreatedPlaylistsKey: EnvironmentKey { 20 | 21 | static let defaultValue = true 22 | 23 | } 24 | 25 | private struct ShowLikedPlaylistsKey: EnvironmentKey { 26 | 27 | static let defaultValue = true 28 | 29 | } 30 | 31 | private struct PlaylistKey: EnvironmentKey { 32 | 33 | static let defaultValue = [AnyPlaylist]() 34 | 35 | } 36 | 37 | private struct LikesKey: EnvironmentKey { 38 | 39 | static let defaultValue = [Track]() 40 | 41 | } 42 | 43 | private struct PostsKey: EnvironmentKey { 44 | 45 | static let defaultValue = [Post]() 46 | 47 | } 48 | 49 | 50 | private struct ToggleLikeTrackKey: EnvironmentKey { 51 | 52 | static let defaultValue: (Track) -> () -> () = { _ in return { fatalError("Did not set the toggleLike action") } } 53 | 54 | } 55 | 56 | private struct ToggleRepostTrackKey: EnvironmentKey { 57 | 58 | static let defaultValue: (Track) -> () -> () = { _ in return { fatalError("Did not set the toggleRepost action") } } 59 | 60 | } 61 | 62 | 63 | private struct ToggleLikePlaylistKey: EnvironmentKey { 64 | 65 | static let defaultValue: (AnyPlaylist) -> () -> () = { _ in return { fatalError("Did not set the toggleLike action") } } 66 | 67 | } 68 | 69 | private struct ToggleRepostPlaylistKey: EnvironmentKey { 70 | 71 | static let defaultValue: (UserPlaylist) -> () -> () = { _ in return { fatalError("Did not set the toggleRepost action") } } 72 | 73 | } 74 | 75 | extension EnvironmentValues { 76 | 77 | var showCreatedPlaylists: Bool { 78 | get { self[ShowCreatedPlaylistsKey.self] } 79 | set { self[ShowCreatedPlaylistsKey.self] = newValue } 80 | } 81 | 82 | var showLikedPlaylists: Bool { 83 | get { self[ShowLikedPlaylistsKey.self] } 84 | set { self[ShowLikedPlaylistsKey.self] = newValue } 85 | } 86 | 87 | var playlists: [AnyPlaylist] { 88 | get { self[PlaylistKey.self] } 89 | set { self[PlaylistKey.self] = newValue } 90 | } 91 | 92 | var likes: [Track] { 93 | get { self[LikesKey.self] } 94 | set { self[LikesKey.self] = newValue } 95 | } 96 | 97 | var posts: [Post] { 98 | get { self[PostsKey.self] } 99 | set { self[PostsKey.self] = newValue } 100 | } 101 | 102 | var toggleLikeTrack: (Track) -> () -> () { 103 | get { self[ToggleLikeTrackKey.self] } 104 | set { self[ToggleLikeTrackKey.self] = newValue } 105 | } 106 | 107 | var toggleRepostTrack: (Track) -> () -> () { 108 | get { self[ToggleRepostTrackKey.self] } 109 | set { self[ToggleRepostTrackKey.self] = newValue } 110 | } 111 | 112 | var toggleLikePlaylist: (AnyPlaylist) -> () -> () { 113 | get { self[ToggleLikePlaylistKey.self] } 114 | set { self[ToggleLikePlaylistKey.self] = newValue } 115 | } 116 | 117 | var toggleRepostPlaylist: (UserPlaylist) -> () -> () { 118 | get { self[ToggleRepostPlaylistKey.self] } 119 | set { self[ToggleRepostPlaylistKey.self] = newValue } 120 | } 121 | 122 | } 123 | 124 | 125 | class CommandSubject: ObservableObject { 126 | 127 | var filter = PassthroughSubject<(), Never>() 128 | var search = PassthroughSubject<(), Never>() 129 | 130 | } 131 | 132 | @main 133 | struct NuageApp: App { 134 | 135 | @StateObject private var player = StreamPlayer() 136 | private var commandSubjects = CommandSubject() 137 | 138 | @State private var showCreatedPlaylists = true 139 | @State private var showLikedPlaylists = true 140 | 141 | @State private var playlists: [AnyPlaylist] 142 | @State private var likes: [Track] 143 | @State private var posts: [Post] 144 | @State private var loggedIn: Bool 145 | @State private var subscriptions = Set() 146 | 147 | var body: some Scene { 148 | WindowGroup { 149 | if loggedIn { 150 | MainView() 151 | .frame(minWidth: 800, minHeight: 400) 152 | .environmentObject(player) 153 | .environmentObject(commandSubjects) 154 | .environment(\.showCreatedPlaylists, showCreatedPlaylists) 155 | .environment(\.showLikedPlaylists, showLikedPlaylists) 156 | .environment(\.playlists, playlists) 157 | .environment(\.likes, likes) 158 | .environment(\.posts, posts) 159 | .environment(\.toggleLikeTrack, toggleLike) 160 | .environment(\.toggleRepostTrack, toggleRepost) 161 | .environment(\.toggleLikePlaylist, toggleLike) 162 | .environment(\.toggleRepostPlaylist, toggleRepost) 163 | .onAppear { 164 | reloadLibrary() 165 | reloadLikes() 166 | reloadPosts() 167 | 168 | // Whenever the current stream changes, add it to the SoundCloud history 169 | player.$currentStream 170 | .filter { $0 != nil} 171 | .flatMap { SoundCloud.shared.perform(.addToHistory($0!)) } 172 | .sink(receiveCompletion: { completion in 173 | if case let .failure(error) = completion { 174 | print("Failed to add track to history: \(error)") 175 | } 176 | }, receiveValue: { _ in }) 177 | .store(in: &subscriptions) 178 | } 179 | } 180 | else { 181 | LoginView { accessToken, expiryDate in 182 | let defaults = UserDefaults.standard 183 | defaults.set(accessToken, forKey: accessTokenKey) 184 | defaults.set(expiryDate, forKey: accessTokenExpiryDateKey) 185 | SoundCloud.shared.accessToken = accessToken 186 | loggedIn = true 187 | } 188 | } 189 | } 190 | .defaultSize(width: 800, height: 400) 191 | .commands(content: commands) 192 | } 193 | 194 | @CommandsBuilder private func commands() -> some Commands { 195 | CommandGroup(after: .textEditing) { 196 | Button("Filter") { 197 | commandSubjects.filter.send() 198 | }.keyboardShortcut("f", modifiers: .command) 199 | Button("Search") { 200 | commandSubjects.search.send() 201 | }.keyboardShortcut("l", modifiers: .command) 202 | } 203 | CommandGroup(before: .toolbar) { 204 | Menu("Playlists") { 205 | Toggle("Show Created", isOn: $showCreatedPlaylists) 206 | Toggle("Show Liked", isOn: $showLikedPlaylists) 207 | } 208 | } 209 | playbackMenu() 210 | } 211 | 212 | @CommandsBuilder private func playbackMenu() -> some Commands { 213 | CommandMenu("Playback") { 214 | let playbackToggleTitle = player.isPlaying ? "Pause" : "Play" 215 | Button(playbackToggleTitle, action: player.togglePlayback) 216 | 217 | Divider() 218 | 219 | playbackControls() 220 | 221 | Divider() 222 | 223 | Toggle("Shuffle", isOn: $player.shuffleQueue) 224 | .keyboardShortcut("s", modifiers: [.command]) 225 | 226 | Toggle("Repeat", isOn: $player.repeatQueue) 227 | .keyboardShortcut("r", modifiers: [.command]) 228 | 229 | Divider() 230 | 231 | Button("Volume Up") { 232 | player.volume += 0.05 233 | } 234 | .keyboardShortcut(.upArrow, modifiers: [.command]) 235 | 236 | Button("Volume Down") { 237 | player.volume -= 0.05 238 | } 239 | .keyboardShortcut(.downArrow, modifiers: [.command]) 240 | } 241 | } 242 | 243 | @ViewBuilder private func playbackControls() -> some View { 244 | Button("Next", action: player.advanceForward) 245 | .keyboardShortcut(.rightArrow, modifiers: .command) 246 | 247 | Button("Previous", action: player.advanceBackward) 248 | .keyboardShortcut(.leftArrow, modifiers: .command) 249 | 250 | Button("Seek Forward", action: player.seekForward) 251 | .keyboardShortcut(.rightArrow, modifiers: [.command, .shift]) 252 | 253 | Button("Seek Backward", action: player.seekBackward) 254 | .keyboardShortcut(.leftArrow, modifiers: [.command, .shift]) 255 | } 256 | 257 | init() { 258 | let MB = 1024*1024 259 | URLCache.shared = URLCache(memoryCapacity: 10*MB, diskCapacity: 20*MB) 260 | URLSession.shared.configuration.requestCachePolicy = .returnCacheDataElseLoad 261 | 262 | let defaults = UserDefaults.standard 263 | if let data = defaults.data(forKey: userKey) { 264 | do { 265 | SoundCloud.shared.user = try JSONDecoder().decode(User.self, from: data) 266 | } 267 | catch { 268 | defaults.removeObject(forKey: userKey) 269 | print("Failed to load user from UserDefaults: \(error)") 270 | } 271 | } 272 | let token = defaults.object(forKey: accessTokenKey) 273 | let expiryDate = defaults.object(forKey: accessTokenExpiryDateKey) 274 | 275 | _loggedIn = State(initialValue: false) 276 | if let token = token as? String { 277 | if let exipryDate = expiryDate as? Date, exipryDate < Date() { 278 | defaults.set(nil, forKey: accessTokenKey) 279 | defaults.set(nil, forKey: accessTokenExpiryDateKey) 280 | } 281 | else { 282 | SoundCloud.shared.accessToken = token 283 | _loggedIn = State(initialValue: true) 284 | } 285 | } 286 | 287 | if let data = defaults.data(forKey: playlistsKey) { 288 | playlists = try! JSONDecoder().decode([AnyPlaylist].self, from: data) 289 | } 290 | else { 291 | playlists = [] 292 | } 293 | 294 | if let data = defaults.data(forKey: likesKey) { 295 | likes = try! JSONDecoder().decode([Track].self, from: data) 296 | } 297 | else { 298 | likes = [] 299 | } 300 | 301 | if let data = defaults.data(forKey: postsKey) { 302 | posts = try! JSONDecoder().decode([Post].self, from: data) 303 | } 304 | else { 305 | posts = [] 306 | } 307 | 308 | playlists.publisher.sink { playlists in 309 | let data = try! JSONEncoder().encode(playlists) 310 | defaults.set(data, forKey: playlistsKey) 311 | } 312 | .store(in: &subscriptions) 313 | 314 | likes.publisher.sink { likes in 315 | let data = try! JSONEncoder().encode(likes) 316 | defaults.set(data, forKey: likesKey) 317 | } 318 | .store(in: &subscriptions) 319 | 320 | posts.publisher.sink { posts in 321 | let data = try! JSONEncoder().encode(posts) 322 | defaults.set(data, forKey: postsKey) 323 | } 324 | .store(in: &subscriptions) 325 | 326 | SoundCloud.shared.$user.sink { user in 327 | if let user = user { 328 | let data = try! JSONEncoder().encode(user) 329 | defaults.set(data, forKey: userKey) 330 | } 331 | else { 332 | defaults.set(nil, forKey: userKey) 333 | } 334 | } 335 | .store(in: &subscriptions) 336 | } 337 | 338 | private func reloadLibrary() { 339 | SoundCloud.shared.get(all: .library()) 340 | .map { $0.map { $0.item } } 341 | .replaceError(with: playlists) 342 | .receive(on: RunLoop.main) 343 | .assign(to: \.playlists, on: self) 344 | .store(in: &subscriptions) 345 | } 346 | 347 | private func reloadLikes() { 348 | SoundCloud.shared.$user 349 | .filter { $0 != nil} 350 | .flatMap { SoundCloud.shared.get(all: .trackLikes(of: $0!)) } 351 | .map { $0.map { $0.item } } 352 | .replaceError(with: likes) 353 | .receive(on: RunLoop.main) 354 | .assign(to: \.likes, on: self) 355 | .store(in: &subscriptions) 356 | } 357 | 358 | private func reloadPosts() { 359 | SoundCloud.shared.$user 360 | .filter { $0 != nil} 361 | .flatMap { SoundCloud.shared.get(all: .stream(of: $0!)) } 362 | .replaceError(with: posts) 363 | .receive(on: RunLoop.main) 364 | .assign(to: \.posts, on: self) 365 | .store(in: &subscriptions) 366 | } 367 | 368 | private func toggleLike(_ track: Track) -> () -> () { 369 | return { 370 | let shouldUnlike = likes.contains(track) 371 | let request: APIRequest = shouldUnlike ? .unlike(track) : .like(track) 372 | 373 | return SoundCloud.shared.perform(request) 374 | .receive(on: RunLoop.main) 375 | .sink(receiveCompletion: { completion in 376 | if case let .failure(error) = completion { 377 | print("Failed to like track: \(error)") 378 | } 379 | }, receiveValue: { 380 | if shouldUnlike { 381 | likes.removeAll { $0 == track } 382 | } 383 | else { 384 | likes.append(track) 385 | } 386 | }) 387 | .store(in: &subscriptions) 388 | } 389 | } 390 | 391 | private func toggleLike(_ playlist: AnyPlaylist) -> () -> () { 392 | return { 393 | let shouldUnlike = playlists.contains(playlist) 394 | let request: APIRequest = shouldUnlike ? .unlike(playlist) : .like(playlist) 395 | 396 | return SoundCloud.shared.perform(request) 397 | .receive(on: RunLoop.main) 398 | .sink(receiveCompletion: { completion in 399 | if case let .failure(error) = completion { 400 | print("Failed to like playlist: \(error)") 401 | } 402 | }, receiveValue: { 403 | if shouldUnlike { 404 | playlists.removeAll { $0 == playlist } 405 | } 406 | else { 407 | playlists.append(playlist) 408 | } 409 | }) 410 | .store(in: &subscriptions) 411 | } 412 | } 413 | 414 | private func toggleRepost(_ track: Track) -> () -> () { 415 | return { 416 | let shouldDeleteRepost = posts.filter { $0.isRepost && $0.isTrack } 417 | .map { $0.tracks.first! } 418 | .contains(track) 419 | let request: APIRequest = shouldDeleteRepost ? .unrepost(track) : .repost(track) 420 | 421 | return SoundCloud.shared.perform(request) 422 | .receive(on: RunLoop.main) 423 | .sink(receiveCompletion: { completion in 424 | if case let .failure(error) = completion { 425 | print("Failed to repost track: \(error)") 426 | } 427 | }, receiveValue: { reloadPosts() }) 428 | .store(in: &subscriptions) 429 | } 430 | } 431 | 432 | private func toggleRepost(_ playlist: UserPlaylist) -> () -> () { 433 | return { 434 | let shouldDeleteRepost = posts.filter { $0.isRepost && !$0.isTrack } 435 | .compactMap { $0.playlist } 436 | .contains(playlist) 437 | 438 | let request: APIRequest = shouldDeleteRepost ? .unrepost(playlist) : .repost(playlist) 439 | 440 | return SoundCloud.shared.perform(request) 441 | .receive(on: RunLoop.main) 442 | .sink(receiveCompletion: { completion in 443 | if case let .failure(error) = completion { 444 | print("Failed to repost playlist: \(error)") 445 | } 446 | }, receiveValue: { reloadPosts() }) 447 | .store(in: &subscriptions) 448 | } 449 | } 450 | 451 | } 452 | -------------------------------------------------------------------------------- /Nuage/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Nuage/Preview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Preview.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 23.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Combine 11 | import SoundCloud 12 | 13 | struct Preview { 14 | 15 | static let user = User(id: "139004098", username: "lerboe", firstName: "la", lastName: "la", avatarURL: URL(string: "https://i1.sndcdn.com/avatars-000322614854-ttkl8d-large.jpg")!) 16 | 17 | static let likes: [Like] = load("Likes.json") 18 | static let likePublisher = publisher(of: likes) 19 | 20 | static let tracks: [Track] = likes.map { $0.item } 21 | static let trackPublisher = publisher(of: tracks) 22 | 23 | } 24 | 25 | struct PreviewError: Error {} 26 | 27 | func publisher(of data: [T]) -> AnyPublisher { 28 | return data.publisher 29 | .mapError { _ in PreviewError() } 30 | .eraseToAnyPublisher() 31 | } 32 | 33 | private func load(_ filename: String) -> T { 34 | let data: Data 35 | 36 | guard let file = Bundle.main.url(forResource: filename, withExtension: nil) 37 | else { 38 | fatalError("Couldn't find \(filename) in main bundle.") 39 | } 40 | 41 | do { 42 | data = try Data(contentsOf: file) 43 | } catch { 44 | fatalError("Couldn't load \(filename) from main bundle:\n\(error)") 45 | } 46 | 47 | do { 48 | let formatter = DateFormatter() 49 | formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" 50 | 51 | let decoder = JSONDecoder() 52 | decoder.dateDecodingStrategy = .formatted(formatter) 53 | 54 | return try decoder.decode(T.self, from: data) 55 | } catch { 56 | fatalError("Couldn't parse \(filename) as \(T.self):\n\(error)") 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Nuage/Views/Artwork.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Artwork.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 03.02.21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct Artwork: View { 11 | 12 | private var url: URL? 13 | @State private var showingPlayButton = false 14 | private var onPlay: () -> () 15 | 16 | var body: some View { 17 | ZStack { 18 | RemoteImage(url: url, cornerRadius: 6) 19 | 20 | if showingPlayButton { 21 | Button(action: onPlay) { 22 | Image(systemName: "play.fill") 23 | .resizable() 24 | .offset(x: 2) 25 | .padding(12.5) 26 | .frame(width: 50, height: 50) 27 | 28 | } 29 | .buttonStyle(.borderless) 30 | .background(.regularMaterial, in: Circle()) 31 | .transition(.opacity) 32 | } 33 | } 34 | .onHover { inside in 35 | withAnimation { showingPlayButton = inside } 36 | } 37 | } 38 | 39 | init(url: URL?, onPlay: @escaping () -> ()) { 40 | self.url = url 41 | self.onPlay = onPlay 42 | } 43 | 44 | } 45 | 46 | struct Artwork_Previews: PreviewProvider { 47 | 48 | static var previews: some View { 49 | let url = URL(string: "https://i1.sndcdn.com/artworks-o1nyZOY2zZQNqnb3-JbBChA-t120x120.jpg") 50 | let onPlay = { } 51 | let artwork = Artwork(url: url, onPlay: onPlay) 52 | 53 | return artwork 54 | .frame(width: 200, height: 200) 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Nuage/Views/Details/TrackDetail.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackDetail.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 18.11.20. 6 | // Copyright © 2020 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | struct TrackDetail: View { 14 | 15 | var track: Track 16 | 17 | @State private var subscriptions = Set() 18 | 19 | @Environment(\.onPlay) private var onPlay: () -> () 20 | 21 | var body: some View { 22 | let duration = format(time: track.duration) 23 | let url = track.artworkURL ?? track.user.avatarURL 24 | 25 | VStack(alignment: .leading) { 26 | Text(track.title) 27 | .font(.title) 28 | .lineLimit(2) 29 | 30 | Spacer() 31 | .frame(height: 2) 32 | 33 | HStack { 34 | NavigationLink(value: track.user) { 35 | Text(track.user.username) 36 | .foregroundColor(.secondary) 37 | .font(.title2) 38 | } 39 | .buttonStyle(.plain) 40 | 41 | Spacer() 42 | .frame(width: 16) 43 | 44 | StatsStack(for: track) 45 | .foregroundColor(.secondary) 46 | } 47 | 48 | HStack(alignment: .center, spacing: 10) { 49 | Artwork(url: url, onPlay: onPlay) 50 | .frame(width: 100, height: 100) 51 | 52 | WaveformView(url: track.waveformURL) 53 | .foregroundColor(.secondary) 54 | .frame(height: 80) 55 | } 56 | 57 | FeedbackStack(for: track) 58 | 59 | Text(duration) 60 | .foregroundColor(Color(NSColor.secondaryLabelColor)) 61 | Spacer() 62 | .frame(height: 8) 63 | 64 | Divider() 65 | 66 | CommentList(for: SoundCloud.shared.get(.comments(of: track))) 67 | .header { 68 | if let description = track.description { 69 | Text(description.withAttributedLinks()) 70 | } 71 | } 72 | } 73 | .toolbar { 74 | ToolbarItem(placement: .secondaryAction) { 75 | NavigationLink(value: Station.track(track)) { 76 | Image(systemName: "dot.radiowaves.left.and.right") 77 | } 78 | } 79 | } 80 | .padding(16) 81 | .navigationTitle(track.title) 82 | } 83 | 84 | } 85 | 86 | struct TrackDetail_Previews: PreviewProvider { 87 | 88 | static var previews: some View { 89 | let player: StreamPlayer = { 90 | let player = StreamPlayer() 91 | player.enqueue(Preview.tracks) 92 | 93 | return player 94 | }() 95 | 96 | TrackDetail(track: Preview.tracks.first!) 97 | .environmentObject(player) 98 | .environmentObject(CommandSubject()) 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Nuage/Views/Details/URLDetail.swift: -------------------------------------------------------------------------------- 1 | // 2 | // URLDetail.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 02.08.23. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | import Combine 11 | 12 | struct URLDetail: View { 13 | 14 | var url: URL 15 | @State private var item: Some? 16 | 17 | @State private var subscriptions = Set() 18 | 19 | var body: some View { 20 | switch item { 21 | case nil: loadingIndicator() 22 | case .track(let track): TrackDetail(track: track) 23 | .playbackContext([track]) 24 | .playbackStart(at: track) 25 | case .user(let user): UserDetail(user: user) 26 | case .userPlaylist(let playlist): TrackList(request: .userPlaylist(playlist.id)) 27 | case .systemPlaylist(let playlist): TrackList(request: .systemPlaylist(playlist.urn)) 28 | } 29 | } 30 | 31 | @ViewBuilder private func loadingIndicator() -> some View { 32 | ProgressView() 33 | .progressViewStyle(.circular) 34 | .onAppear { 35 | SoundCloud.shared.get(.resolve(url)) 36 | .map { Optional($0) } 37 | .replaceError(with: nil) 38 | .receive(on: RunLoop.main) 39 | .assign(to: \.item, on: self) 40 | .store(in: &subscriptions) 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Nuage/Views/Details/UserDetail.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserDetail.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 03.01.21. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct UserDetail: View { 13 | 14 | @State var user: User 15 | @State private var loadedUser: User? 16 | @State private var selection: Tab = .stream 17 | @State private var subscriptions = Set() 18 | 19 | var body: some View { 20 | let currentUser = loadedUser ?? user 21 | VStack(spacing: 0) { 22 | HStack(alignment: .top, spacing: 20) { 23 | RemoteImage(url: currentUser.avatarURL, cornerRadius: 50) 24 | .frame(width: 100, height: 100) 25 | 26 | VStack(alignment: .leading) { 27 | Text(user.username) 28 | .font(.title) 29 | .lineLimit(1) 30 | 31 | HStack { 32 | Text("\(currentUser.followerCount ?? 0) Followers") 33 | Text("\(currentUser.followingCount ?? 0) Following") 34 | } 35 | 36 | if let description = currentUser.description { 37 | Text(description.withAttributedLinks()) 38 | } 39 | } 40 | .frame(maxWidth: .infinity, alignment: .leading) 41 | } 42 | .padding() 43 | 44 | HStack(spacing: 40) { 45 | button(for: .stream) 46 | button(for: .likes) 47 | button(for: .following) 48 | button(for: .followers) 49 | } 50 | .buttonStyle(.plain) 51 | 52 | Divider() 53 | .padding(.top, 8) 54 | 55 | stream(for: selection) 56 | } 57 | .toolbar { 58 | ToolbarItem(placement: .secondaryAction) { 59 | NavigationLink(value: Station.artist(user)) { 60 | Image(systemName: "dot.radiowaves.left.and.right") 61 | } 62 | } 63 | } 64 | .navigationTitle(user.username) 65 | .onAppear { 66 | SoundCloud.shared.get(.user(with: user.id)) 67 | .replaceError(with: user) 68 | .map { Optional($0) } 69 | .receive(on: RunLoop.main) 70 | .assign(to: \.loadedUser, on: self) 71 | .store(in: &subscriptions) 72 | } 73 | } 74 | 75 | @ViewBuilder private func button(for tab: Tab) -> some View { 76 | Button(action: { selection = tab }, label: { 77 | let color: Color = selection == tab ? .primary : .secondary 78 | 79 | Text(tab.rawValue.capitalized) 80 | .font(.title2) 81 | .foregroundColor(color) 82 | }) 83 | } 84 | 85 | @ViewBuilder private func stream(for selection: Tab) -> some View { 86 | switch selection { 87 | case .stream: PostList(for: SoundCloud.shared.get(.stream(of: user))) 88 | case .likes: TrackList(for: SoundCloud.shared.get(.trackLikes(of: user))) 89 | case .following: UserGrid(for: SoundCloud.shared.get(.followings(of: user))) 90 | case .followers: UserGrid(for: SoundCloud.shared.get(.followers(of: user))) 91 | } 92 | } 93 | 94 | } 95 | 96 | extension UserDetail { 97 | 98 | enum Tab: String { 99 | case stream 100 | case likes 101 | case following 102 | case followers 103 | } 104 | 105 | } 106 | 107 | struct UserDetail_Previews: PreviewProvider { 108 | 109 | static var previews: some View { 110 | UserDetail(user: Preview.tracks.first!.user) 111 | .environmentObject(StreamPlayer()) 112 | .environmentObject(CommandSubject()) 113 | } 114 | 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Nuage/Views/FeedbackStack.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FeedbackStack.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 24.07.23. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | 11 | struct FeedbackStack: View { 12 | 13 | private var item: T? 14 | private var horizontal: Bool 15 | 16 | private var isLiked: Bool { 17 | if let track = item as? Track { 18 | return likes.contains(track) 19 | } 20 | else if let playlist = item as? (any Playlist) { 21 | return playlists.contains(playlist.eraseToAnyPlaylist()) 22 | } 23 | else { 24 | return false 25 | } 26 | } 27 | 28 | private var isRepost: Bool? { 29 | if let track = item as? Track { 30 | return posts 31 | .filter { $0.isTrack && $0.isRepost } 32 | .map { $0.tracks.first! } 33 | .contains(track) 34 | } 35 | else if let playlist = item as? (any Playlist) { 36 | guard let playlist = playlist as? UserPlaylist else { 37 | return nil 38 | } 39 | return posts 40 | .filter { !$0.isTrack && $0.isRepost} 41 | .compactMap { $0.playlist } 42 | .contains(playlist) 43 | } 44 | else { 45 | return false 46 | } 47 | } 48 | 49 | private var toggleLike: () -> () { 50 | if let track = item as? Track { 51 | return toggleLikeTrack(track) 52 | } 53 | else if let playlist = item as? (any Playlist) { 54 | return toggleLikePlaylist(playlist.eraseToAnyPlaylist()) 55 | } 56 | else { 57 | return {} 58 | } 59 | } 60 | 61 | private var toggleRepost: () -> () { 62 | if let track = item as? Track { 63 | return toggleRepostTrack(track) 64 | } 65 | else if let playlist = item as? UserPlaylist { 66 | return toggleRepostPlaylist(playlist) 67 | } 68 | else { 69 | return {} 70 | } 71 | } 72 | 73 | @Environment(\.likes) private var likes: [Track] 74 | @Environment(\.playlists) private var playlists: [AnyPlaylist] 75 | @Environment(\.posts) private var posts: [Post] 76 | 77 | @Environment(\.toggleLikeTrack) private var toggleLikeTrack: (Track) -> () -> () 78 | @Environment(\.toggleRepostTrack) private var toggleRepostTrack: (Track) -> () -> () 79 | @Environment(\.toggleLikePlaylist) private var toggleLikePlaylist: (AnyPlaylist) -> () -> () 80 | @Environment(\.toggleRepostPlaylist) private var toggleRepostPlaylist: (UserPlaylist) -> () -> () 81 | 82 | var body: some View { 83 | if horizontal { 84 | HStack(content: content) 85 | } 86 | else { 87 | VStack(content: content) 88 | } 89 | } 90 | 91 | @ViewBuilder private func content() -> some View { 92 | Button(action: toggleLike) { 93 | let name = isLiked ? "heart.fill" : "heart" 94 | Image(systemName: name) 95 | } 96 | .disabled(item == nil) 97 | .buttonStyle(.borderless) 98 | 99 | if let isRepost = isRepost { 100 | Button(action: toggleRepost) { 101 | let name = isRepost ? "arrow.triangle.2.circlepath.circle.fill" : "arrow.triangle.2.circlepath.circle" 102 | Image(systemName: name) 103 | } 104 | .disabled(item == nil) 105 | .buttonStyle(.borderless) 106 | } 107 | } 108 | 109 | @ViewBuilder private func resizableImage(name: String, height: CGFloat? = 16, width: CGFloat? = 16) -> some View { 110 | Image(systemName: name) 111 | .resizable() 112 | .aspectRatio(contentMode: .fit) 113 | .frame(width: width, height: height) 114 | } 115 | 116 | init(for playlist: T, horizontal: Bool = true) where T: Playlist { 117 | self.item = playlist 118 | self.horizontal = horizontal 119 | } 120 | 121 | init(for track: T?, horizontal: Bool = true) where T == Track { 122 | self.item = track 123 | self.horizontal = horizontal 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /Nuage/Views/InfiniteView/ArrayView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArrayView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 15.12.20. 6 | // 7 | 8 | import Combine 9 | import SwiftUI 10 | 11 | private let idSubcription = -1 12 | 13 | struct ArrayView: View { 14 | 15 | @State private var ids = [ID]() 16 | @State private var elements = [Element]() 17 | @State private var elementRange = 0..<16 18 | 19 | private var arrayPublisher: AnyPublisher<[ID], Error> 20 | private var pagePublisher: ([ID]) -> AnyPublisher<[Element], Error> 21 | @State private var subscriptions = [Int: AnyCancellable]() 22 | 23 | private var content: ([Element], @escaping () -> ()) -> ContentView 24 | 25 | var body: some View { 26 | Group { 27 | if elements.isEmpty { 28 | ProgressView() 29 | .progressViewStyle(.circular) 30 | .frame(maxWidth: .infinity, maxHeight: .infinity) 31 | } 32 | else { 33 | content(elements, getNextPage) 34 | } 35 | } 36 | .onAppear { 37 | arrayPublisher.receive(on: RunLoop.main) 38 | .replaceError(with: []) 39 | .sink { elementIDs in 40 | ids = elementIDs 41 | getNextPage() 42 | } 43 | .store(in: &subscriptions, key: idSubcription) 44 | 45 | getNextPage() 46 | } 47 | } 48 | 49 | init(arrayPublisher: AnyPublisher<[ID], Error>, 50 | pagePublisher: @escaping ([ID]) -> AnyPublisher<[Element], Error>, 51 | @ViewBuilder content: @escaping ([Element], @escaping () -> ()) -> ContentView) { 52 | self.arrayPublisher = arrayPublisher 53 | self.pagePublisher = pagePublisher 54 | self.content = content 55 | } 56 | 57 | private func getNextPage() { 58 | let range = elementRange.clamped(to: 0.. 0 else { return } 60 | guard subscriptions[elements.count] == nil else { return } 61 | 62 | let page = Array(ids[range]) 63 | 64 | pagePublisher(page) 65 | .receive(on: RunLoop.main) 66 | .sink(receiveCompletion: { _ in }, receiveValue: { page in 67 | elements.insert(contentsOf: page, at: range.startIndex) 68 | elementRange = range.endIndex..: View { 12 | 13 | private var publisher: InfinitePublisher 14 | private var item: ([Element], Int) -> Item 15 | @State private var filter = "" 16 | @State private var isSearching = false 17 | 18 | @EnvironmentObject private var commands: CommandSubject 19 | 20 | var body: some View { 21 | if case let .page(publisher) = publisher { 22 | PageView(publisher: publisher, content: grid) 23 | } 24 | else if case let .array(arrayPublisher, pagePublisher) = publisher { 25 | ArrayView(arrayPublisher: arrayPublisher, pagePublisher: pagePublisher, content: grid) 26 | } 27 | } 28 | 29 | @ViewBuilder func grid(for elements: [Element], getNextPage: @escaping () -> ()) -> some View { 30 | let displayedElements = (filter.count > 0) ? elements.filter { $0.contains(filter) } : elements 31 | 32 | VStack { 33 | if isSearching { 34 | TextField("Filter", text: $filter) 35 | .onChange(of: filter, perform: { _ in 36 | getNextPage() 37 | }) 38 | .textFieldStyle(RoundedBorderTextFieldStyle()) 39 | .padding() 40 | .introspectTextField { $0.becomeFirstResponder() } 41 | .onExitCommand(perform: stopFiltering) 42 | } 43 | 44 | GridStack(minCellWidth: 100, spacing: 20, numItems: displayedElements.count, alignment: .leading) { idx, width in 45 | item(displayedElements, idx) 46 | .id(idx) 47 | .onAppear { 48 | if idx == elements.count/2 { 49 | getNextPage() 50 | } 51 | } 52 | } 53 | .onReceive(commands.filter) { withAnimation { isSearching = true } } 54 | .onExitCommand(perform: stopFiltering) 55 | } 56 | } 57 | 58 | init(publisher: InfinitePublisher, @ViewBuilder item: @escaping ([Element], Int) -> Item) { 59 | self.publisher = publisher 60 | self.item = item 61 | } 62 | 63 | private func stopFiltering() { 64 | withAnimation { 65 | isSearching = false 66 | filter = "" 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Nuage/Views/InfiniteView/InfiniteList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteList.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 15.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import Introspect 11 | import AppKit 12 | import SoundCloud 13 | 14 | enum InfinitePublisher { 15 | case page(AnyPublisher, Error>) 16 | case array(AnyPublisher<[String], Error>, ([String]) -> AnyPublisher<[Element], Error>) 17 | } 18 | 19 | struct InfiniteList: View { 20 | 21 | private var publisher: InfinitePublisher 22 | private var row: (Element) -> Row 23 | 24 | @State private var filter = "" 25 | @State private var isSearching = false 26 | 27 | @Environment(\.header) private var header: AnyView 28 | @EnvironmentObject private var commands: CommandSubject 29 | 30 | var body: some View { 31 | if case let .page(publisher) = publisher { 32 | PageView(publisher: publisher, content: list) 33 | } 34 | else if case let .array(arrayPublisher, pagePublisher) = publisher { 35 | ArrayView(arrayPublisher: arrayPublisher, pagePublisher: pagePublisher, content: list) 36 | } 37 | } 38 | 39 | @ViewBuilder func list(for elements: [Element], getNextPage: @escaping () -> ()) -> some View { 40 | let displayedElements = (filter.count > 0) ? elements.filter { $0.contains(filter) } : elements 41 | 42 | VStack { 43 | if isSearching { 44 | TextField("Filter", text: $filter) 45 | .onChange(of: filter, perform: { _ in 46 | getNextPage() 47 | }) 48 | .textFieldStyle(RoundedBorderTextFieldStyle()) 49 | .padding() 50 | .introspectTextField { $0.becomeFirstResponder() } 51 | .onExitCommand(perform: stopFiltering) 52 | } 53 | ScrollView { 54 | LazyVStack(alignment: .leading, spacing: 0) { 55 | ForEach(0.., @ViewBuilder row: @escaping (Element) -> Row) { 93 | self.publisher = publisher 94 | self.row = row 95 | } 96 | 97 | } 98 | 99 | extension View { 100 | 101 | func header(@ViewBuilder _ content: () -> Content) -> some View { 102 | self.environment(\.header, AnyView(content())) 103 | } 104 | 105 | } 106 | 107 | struct HeaderKey: EnvironmentKey { 108 | 109 | static let defaultValue = AnyView(EmptyView()) 110 | 111 | } 112 | 113 | extension EnvironmentValues { 114 | 115 | var header: AnyView { 116 | get { self[HeaderKey.self] } 117 | set { self[HeaderKey.self] = newValue } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /Nuage/Views/InfiniteView/PageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PageView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 03.12.20. 6 | // Copyright © 2020 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import Combine 10 | import SwiftUI 11 | import SoundCloud 12 | 13 | private let subjectSubcription = -1 14 | private let initialPageSubscription = 0 15 | 16 | struct PageView: View { 17 | 18 | var elements: [Element] { 19 | return pages?.map { $0.collection } 20 | .reduce([], +) ?? [] 21 | } 22 | @State private var pages: [Page]? 23 | 24 | private var publisher: AnyPublisher, Error> 25 | @State private var subscriptions = [Int: AnyCancellable]() 26 | 27 | private var content: ([Element], @escaping () -> ()) -> ContentView 28 | 29 | var body: some View { 30 | Group { 31 | if let pages = pages { 32 | if pages.isEmpty { 33 | Text("Empty") 34 | .font(.title2) 35 | .foregroundColor(.secondary) 36 | } 37 | else { 38 | content(elements, getNextPage) 39 | } 40 | } 41 | else { 42 | ProgressView() 43 | .progressViewStyle(.circular) 44 | .frame(maxWidth: .infinity, maxHeight: .infinity) 45 | } 46 | } 47 | .onAppear { 48 | publisher.receive(on: RunLoop.main) 49 | .sink(receiveCompletion: { completion in 50 | if case .failure(_) = completion { 51 | pages = [] 52 | } 53 | }, receiveValue: { page in 54 | pages = [page] 55 | }) 56 | .store(in: &subscriptions, key: initialPageSubscription) 57 | } 58 | } 59 | 60 | init(publisher: AnyPublisher, Error>, 61 | @ViewBuilder content: @escaping ([Element], @escaping () -> ()) -> ContentView) { 62 | self.publisher = publisher 63 | self.content = content 64 | } 65 | 66 | private func getNextPage() { 67 | guard subscriptions[elements.count] == nil else { return } 68 | 69 | let currentPagePublisher = (pages ?? []).publisher 70 | .last() 71 | .mapError { $0 as Error } 72 | 73 | publisher.merge(with: currentPagePublisher) 74 | .first() 75 | .flatMap { SoundCloud.shared.get(next: $0) } 76 | .receive(on: RunLoop.main) 77 | .sink(receiveCompletion: { _ in }, receiveValue: { page in 78 | pages?.append(page) 79 | }) 80 | .store(in: &subscriptions, key: elements.count) 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/CommentList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommentList.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 19.02.21. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct CommentList: View { 13 | 14 | var publisher: InfinitePublisher 15 | 16 | @EnvironmentObject private var player: StreamPlayer 17 | 18 | var body: some View { 19 | InfiniteList(publisher: publisher) { comment in 20 | CommentRow(comment: comment) 21 | } 22 | } 23 | 24 | init(for publisher: AnyPublisher, Error>) { 25 | self.publisher = .page(publisher) 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/PostList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PostList.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 20.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct PostList: View { 13 | 14 | private var publisher: InfinitePublisher 15 | 16 | @EnvironmentObject private var player: StreamPlayer 17 | 18 | var body: some View { 19 | InfiniteList(publisher: publisher) { post in 20 | PostRow(post: post) 21 | .playbackStart(at: post) 22 | } 23 | } 24 | 25 | init(for publisher: AnyPublisher, Error>) { 26 | self.publisher = .page(publisher) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/Rows/CommentRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommentRow.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 19.02.21. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct CommentRow: View { 13 | 14 | var comment: Comment 15 | 16 | @State private var subscriptions = Set() 17 | 18 | var body: some View { 19 | HStack { 20 | NavigationLink(value: comment.user) { 21 | RemoteImage(url: comment.user.avatarURL, cornerRadius: 25) 22 | .frame(width: 50, height: 50, alignment: .center) 23 | } 24 | .buttonStyle(.plain) 25 | 26 | VStack(alignment: .leading) { 27 | let time = format(time: comment.timestamp) 28 | Text("\(comment.user.username) at \(time)") 29 | .bold() 30 | Text(comment.body) 31 | } 32 | } 33 | .padding(6) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/Rows/PlaylistRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlaylistRow.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 25.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | 11 | struct PlaylistRow: View { 12 | 13 | var playlist: T 14 | @Environment(\.onPlay) private var onPlay: () -> () 15 | 16 | var body: some View { 17 | let artworkURL = playlist.artworkURL ?? playlist.tracks?.first?.artworkURL 18 | 19 | return HStack(alignment: .top, spacing: 10) { 20 | VStack(alignment: .leading) { 21 | Artwork(url: artworkURL, onPlay: onPlay) 22 | .frame(width: 100, height: 100) 23 | FeedbackStack(for: playlist) 24 | } 25 | .padding(.bottom, 16) 26 | 27 | VStack(alignment: .leading) { 28 | Text(playlist.title) 29 | .font(.title3) 30 | .bold() 31 | .lineLimit(1) 32 | NavigationLink(playlist.user.username, value: playlist.user) 33 | .buttonStyle(.plain) 34 | Spacer() 35 | .frame(height: 8) 36 | 37 | if let description = playlist.description { 38 | let text = description 39 | .trimmingCharacters(in: .whitespacesAndNewlines) 40 | .replacingOccurrences(of: "\n", with: " ") 41 | .withAttributedLinks() 42 | 43 | Text(text).lineLimit(3) 44 | } 45 | 46 | if let tracks = playlist.tracks { 47 | ForEach(tracks) { track in 48 | Divider() 49 | HStack { 50 | Text(track.title) 51 | StatsStack(for: track) 52 | } 53 | } 54 | .foregroundColor(.secondary) 55 | } 56 | 57 | Spacer() 58 | .frame(height: 8) 59 | } 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/Rows/PostRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PostRow.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 26.07.23. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct PostRow: View { 13 | 14 | var post: Post 15 | 16 | @State private var subscriptions = Set() 17 | 18 | var body: some View { 19 | VStack(alignment: .leading) { 20 | HStack(spacing: 10) { 21 | NavigationLink(value: post.user) { 22 | RemoteImage(url: post.user.avatarURL, cornerRadius: 15) 23 | .frame(width: 30, height: 30) 24 | 25 | let title: AttributedString = { 26 | var attributes = AttributeContainer() 27 | attributes.font = .body.bold() 28 | attributes.foregroundColor = .primary 29 | let username = AttributedString(post.user.username, attributes: attributes) 30 | 31 | let action = post.isRepost ? " reposted" : " posted" 32 | attributes = AttributeContainer() 33 | attributes.foregroundColor = .secondary 34 | return username + AttributedString(action, attributes: attributes) 35 | }() 36 | 37 | Text(title) 38 | } 39 | .buttonStyle(.plain) 40 | } 41 | Spacer() 42 | .frame(height: 18) 43 | 44 | if case let .track(track) = post.item { 45 | TrackRow(track: track) 46 | .trackContextMenu(with: track) 47 | } 48 | else if case let .playlist(playlist) = post.item { 49 | PlaylistRow(playlist: playlist) 50 | } 51 | } 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/Rows/TrackRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackRow.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 25.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct TrackRow: View { 13 | 14 | var track: Track 15 | 16 | @State private var subscriptions = Set() 17 | 18 | @Environment(\.onPlay) private var onPlay: () -> () 19 | 20 | var body: some View { 21 | let duration = format(time: track.duration) 22 | 23 | HStack(alignment: .top, spacing: 10) { 24 | VStack(alignment: .leading) { 25 | Artwork(url: track.artworkURL ?? track.user.avatarURL, onPlay: onPlay) 26 | .frame(width: 100, height: 100) 27 | FeedbackStack(for: track) 28 | } 29 | .padding(.bottom, 8) 30 | 31 | VStack(alignment: .leading) { 32 | PlaybackNavigationLink(value: track) { 33 | Text(track.title) 34 | .font(.title3) 35 | .bold() 36 | .lineLimit(1) 37 | } 38 | .buttonStyle(.plain) 39 | NavigationLink(track.user.username, value: track.user) 40 | .buttonStyle(.plain) 41 | 42 | StatsStack(for: track) 43 | .foregroundColor(.secondary) 44 | Text(duration) 45 | .foregroundColor(.secondary) 46 | 47 | Spacer() 48 | .frame(height: 8) 49 | 50 | if let description = track.description { 51 | let text = description 52 | .trimmingCharacters(in: .whitespacesAndNewlines) 53 | .replacingOccurrences(of: "\n", with: " ") 54 | .withAttributedLinks() 55 | 56 | Text(text) 57 | .lineLimit(3) 58 | } 59 | } 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/SearchList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SearchList.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 25.12.20. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | private enum SearchSection: String { 13 | case users 14 | case tracks 15 | case playlists 16 | } 17 | 18 | struct SearchList: View { 19 | 20 | var publisher: AnyPublisher, Error> 21 | 22 | private var userPublisher: AnyPublisher<[User], Error> { 23 | publisher.map { page in 24 | return page.collection.compactMap { elem in 25 | switch elem { 26 | case .user(let user): return user 27 | default: return nil 28 | } 29 | } 30 | } 31 | .eraseToAnyPublisher() 32 | } 33 | 34 | private var trackPublisher: AnyPublisher<[Track], Error> { 35 | publisher.map { page in 36 | return page.collection.compactMap { elem in 37 | switch elem { 38 | case .track(let track): return track 39 | default: return nil 40 | } 41 | } 42 | } 43 | .eraseToAnyPublisher() 44 | } 45 | 46 | private var playlistPublisher: AnyPublisher<[UserPlaylist], Error> { 47 | publisher.map { page in 48 | return page.collection.compactMap { elem in 49 | switch elem { 50 | case .userPlaylist(let playlist): return playlist 51 | default: return nil 52 | } 53 | } 54 | } 55 | .eraseToAnyPublisher() 56 | } 57 | 58 | @State private var users = [User]() 59 | @State private var tracks = [Track]() 60 | @State private var playlists = [UserPlaylist]() 61 | 62 | @State private var subscriptions = Set() 63 | 64 | var body: some View { 65 | Group { 66 | if users.isEmpty && tracks.isEmpty && playlists.isEmpty { 67 | ProgressView() 68 | .progressViewStyle(.circular) 69 | } 70 | else { 71 | ScrollView { 72 | LazyVStack(alignment: .leading) { 73 | if !users.isEmpty { 74 | Section(content: { 75 | HStack(alignment: .top) { 76 | ForEach(users) { UserItem(user: $0) } 77 | } 78 | }, header: header(for: .users), footer: footer) 79 | } 80 | if !tracks.isEmpty { 81 | Section(content: { 82 | VStack(alignment: .leading) { 83 | ForEach(tracks) { track in 84 | TrackRow(track: track) 85 | .playbackStart(at: track) 86 | } 87 | } 88 | .playbackContext(tracks) 89 | }, header: header(for: .tracks), footer: footer) 90 | } 91 | if !playlists.isEmpty { 92 | Section(content: { 93 | VStack(alignment: .leading) { 94 | ForEach(playlists) { playlist in 95 | PlaylistRow(playlist: playlist) 96 | } 97 | } 98 | .playbackContext(playlists) 99 | }, header: header(for: .playlists), footer: footer) 100 | } 101 | } 102 | .padding() 103 | } 104 | } 105 | } 106 | .navigationTitle("Search") 107 | .onAppear { 108 | userPublisher.replaceError(with: []) 109 | .receive(on: RunLoop.main) 110 | .assign(to: \.users, on: self) 111 | .store(in: &subscriptions) 112 | 113 | trackPublisher.replaceError(with: []) 114 | .receive(on: RunLoop.main) 115 | .assign(to: \.tracks, on: self) 116 | .store(in: &subscriptions) 117 | 118 | playlistPublisher.replaceError(with: []) 119 | .receive(on: RunLoop.main) 120 | .assign(to: \.playlists, on: self) 121 | .store(in: &subscriptions) 122 | } 123 | } 124 | 125 | private func header(for section: SearchSection) -> () -> some View { 126 | @ViewBuilder func buildHeader() -> some View { 127 | Text(section.rawValue.capitalized) 128 | .font(.title) 129 | } 130 | return buildHeader 131 | } 132 | 133 | @ViewBuilder private func footer() -> some View { 134 | Spacer(minLength: 20) 135 | Divider() 136 | Spacer(minLength: 20) 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /Nuage/Views/Lists/TrackList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackList.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 23.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | struct TrackList: View { 14 | 15 | private var publisher: InfinitePublisher 16 | private var transform: (Element) -> Track 17 | 18 | @EnvironmentObject private var player: StreamPlayer 19 | 20 | var body: some View { 21 | InfiniteList(publisher: publisher) { elem in 22 | let track = transform(elem) 23 | TrackRow(track: track) 24 | .playbackStart(at: elem) { [transform($0)] } 25 | .trackContextMenu(with: track) 26 | } 27 | } 28 | 29 | } 30 | 31 | extension TrackList where Element == Track { 32 | 33 | init(for publisher: AnyPublisher, Error>) { 34 | self.init(publisher: .page(publisher)) { $0 } 35 | } 36 | 37 | init(for arrayPublisher: AnyPublisher<[String], Error>, 38 | page pagePublisher: @escaping ([String]) -> AnyPublisher<[Track], Error>) { 39 | self.init(publisher: .array(arrayPublisher, pagePublisher), transform: { $0 }) 40 | } 41 | 42 | init(request: APIRequest

) { 43 | let ids = SoundCloud.shared.get(request) 44 | .map { $0.trackIDs ?? [] } 45 | .eraseToAnyPublisher() 46 | let page = { ids in 47 | return SoundCloud.shared.get(.tracks(ids)) 48 | } 49 | self.init(for: ids, page: page) 50 | } 51 | 52 | } 53 | 54 | extension TrackList where Element == Like { 55 | 56 | init(for publisher: AnyPublisher>, Error>) { 57 | self.init(publisher: .page(publisher)) { $0.item } 58 | } 59 | 60 | } 61 | 62 | extension TrackList where Element == HistoryItem { 63 | 64 | init(for publisher: AnyPublisher, Error>) { 65 | self.init(publisher: .page(publisher)) { $0.track } 66 | } 67 | 68 | } 69 | 70 | //struct TrackList_Previews: PreviewProvider { 71 | // static var previews: some View { 72 | // TrackList(publisher: previewTrackPublisher.collect().eraseToAnyPublisher()) 73 | // } 74 | //} 75 | -------------------------------------------------------------------------------- /Nuage/Views/LoginView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoginView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 04.12.20. 6 | // Copyright © 2020 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | 12 | struct LoginView: View { 13 | 14 | private var onLogin: (String, Date?) -> () 15 | 16 | var body: some View { 17 | WebView(url: URL(string: "https://soundcloud.com/signin")!) 18 | .cookie(name: "oauth_token") { cookie in 19 | onLogin(cookie.value, cookie.expiresDate) 20 | } 21 | .frame(minWidth: 1000, minHeight: 700) 22 | .navigationTitle("Login") 23 | } 24 | 25 | init(onLogin: @escaping (String, Date?) -> ()) { 26 | self.onLogin = onLogin 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Nuage/Views/MainView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 26.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | struct MainView: View { 14 | 15 | @ObservedObject private var soundCloud = SoundCloud.shared 16 | 17 | @AppStorage("sidebarSelection") private var sidebarSelection: SidebarItem = .stream 18 | @State private var navigationPath = NavigationPath() 19 | @State private var blockingNavigationPath: NavigationPath? 20 | 21 | @State private var searchQuery = "" 22 | @State private var subscriptions = Set() 23 | 24 | // @EnvironmentObject private var commands: Commands 25 | @EnvironmentObject private var player: StreamPlayer 26 | @Environment(\.playlists) private var playlists: [AnyPlaylist] 27 | 28 | @Environment(\.showLikedPlaylists) private var showLikedPlaylists: Bool 29 | @Environment(\.showCreatedPlaylists) private var showCreatedPlaylists: Bool 30 | 31 | var body: some View { 32 | VStack(spacing: 0) { 33 | NavigationSplitView(sidebar: sidebar) { 34 | NavigationStack(path: $navigationPath) { 35 | let presentSearch: Binding = Binding( 36 | get: { searchQuery.count > 0 }, 37 | set: { if !$0 { searchQuery = "" } } 38 | ) 39 | 40 | root(for: sidebarSelection) 41 | .navigationDestinationWithPlaybackContext(for: Track.self) { TrackDetail(track: $0) } 42 | .navigationDestination(for: User.self) { UserDetail(user: $0) } 43 | .navigationDestination(for: URL.self) { URLDetail(url: $0) } 44 | .navigationDestination(for: Station.self) { station in 45 | switch station { 46 | case .track(let track): TrackList(request: .trackStation(basedOn: track)) 47 | case .artist(let user): TrackList(request: .artistStation(basedOn: user)) 48 | } 49 | } 50 | .navigationDestination(isPresented: presentSearch) { 51 | let search = soundCloud.get(.search(searchQuery)) 52 | SearchList(publisher: search) 53 | .id(searchQuery) 54 | } 55 | } 56 | } 57 | if player.queue.count > 0 { 58 | Divider() 59 | PlayerView { 60 | if let track = player.currentStream, navigationPath != blockingNavigationPath { 61 | navigationPath.append(track, with: player.queue, startPlaybackAt: track, player: player) 62 | blockingNavigationPath = navigationPath 63 | } 64 | } 65 | } 66 | } 67 | .toolbarRole(.editor) 68 | .toolbar(content: toolbar) 69 | .touchBar { TouchBar() } 70 | .onOpenURL { url in 71 | guard var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return } 72 | 73 | components.scheme = "https" 74 | guard let newURL = components.url else { return } 75 | navigationPath.append(newURL) 76 | } 77 | .handlesExternalEvents(preferring: ["*"], allowing: ["*"]) 78 | } 79 | 80 | @ViewBuilder private func sidebar() -> some View { 81 | List(selection: $sidebarSelection) { 82 | sidebarMenu(for: .stream) 83 | sidebarMenu(for: .likes) 84 | sidebarMenu(for: .history) 85 | sidebarMenu(for: .following) 86 | 87 | if (showLikedPlaylists || showCreatedPlaylists) && !playlists.isEmpty { 88 | Section(header: Text("Playlists")) { 89 | ForEach(playlists) { playlist in 90 | let isLiked = (playlist.userPlaylist?.secretToken == nil) 91 | 92 | if (isLiked && showLikedPlaylists) || (!isLiked && showCreatedPlaylists) { 93 | if let playlist = playlist.userPlaylist { 94 | sidebarMenu(for: .userPlaylist(playlist.title, playlist.id)) 95 | } 96 | else if let playlist = playlist.systemPlaylist { 97 | sidebarMenu(for: .systemPlaylist(playlist.title, playlist.id)) 98 | } 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | 106 | @ViewBuilder private func sidebarMenu(for detail: SidebarItem) -> some View { 107 | NavigationLink(value: detail) { 108 | HStack { 109 | if let imageName = detail.imageName { 110 | Image(systemName: imageName) 111 | .frame(width: 20, alignment: .center) 112 | } 113 | Text(detail.title) 114 | } 115 | } 116 | } 117 | 118 | @ViewBuilder private func root(for item: SidebarItem) -> some View { 119 | Group { 120 | switch item { 121 | case .stream: 122 | let stream = SoundCloud.shared.get(.stream(), count: 50) 123 | PostList(for: stream) 124 | case .likes: 125 | let likes = SoundCloud.shared.$user.filter { $0 != nil} 126 | .flatMap { SoundCloud.shared.get(.trackLikes(of: $0!), count: 50) } 127 | .eraseToAnyPublisher() 128 | TrackList(for: likes) 129 | case .history: 130 | let history = SoundCloud.shared.get(.history(), count: 50) 131 | TrackList(for: history) 132 | case .following: 133 | let following = SoundCloud.shared.$user.filter { $0 != nil } 134 | .flatMap { SoundCloud.shared.get(.followings(of: $0!), count: 50) } 135 | .eraseToAnyPublisher() 136 | UserGrid(for: following) 137 | case .userPlaylist(_, let id): 138 | TrackList(request: .userPlaylist(id)) 139 | case .systemPlaylist(_, let urn): 140 | TrackList(request: .systemPlaylist(urn)) 141 | } 142 | } 143 | .navigationTitle(item.title) 144 | .id(item.id) // Set id so that SwiftUI knows when to render new view 145 | } 146 | 147 | @ToolbarContentBuilder private func toolbar() -> some ToolbarContent { 148 | ToolbarItem(placement: .principal) { 149 | TextField("Search", text: $searchQuery) 150 | .textFieldStyle(.roundedBorder) 151 | .frame(width: 250) 152 | } 153 | ToolbarItemGroup { 154 | Spacer() 155 | Button { 156 | if let user = soundCloud.user { 157 | navigationPath.append(user) 158 | } 159 | } label: { 160 | RemoteImage(url: SoundCloud.shared.user?.avatarURL, cornerRadius: 15) 161 | .frame(width: 30, height: 30) 162 | } 163 | .buttonStyle(.plain) 164 | } 165 | } 166 | 167 | } 168 | 169 | struct MainView_Previews: PreviewProvider { 170 | 171 | static var previews: some View { 172 | let player: StreamPlayer = { 173 | let player = StreamPlayer() 174 | player.enqueue(Preview.tracks) 175 | return player 176 | }() 177 | 178 | MainView() 179 | .environmentObject(player) 180 | // .environmentObject(Commands()) 181 | } 182 | 183 | } 184 | -------------------------------------------------------------------------------- /Nuage/Views/PlaybackContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlaybackContext.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 02.08.23. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | 11 | private func createOnPlay(playbackContext: [AnyHashable], 12 | start: T, 13 | transform: @escaping (T) -> [Track], 14 | player: StreamPlayer) -> () -> () { 15 | return { 16 | guard let elements = playbackContext as? [T] else { 17 | print("Tried to play an element of type \(T.self) in an non-matching playback context.") 18 | return 19 | } 20 | 21 | guard !playbackContext.isEmpty else { 22 | print("Tried to play a track with an empty playback context.") 23 | return 24 | } 25 | 26 | var queue = [Track]() 27 | var startIndex: Int? 28 | for elem in elements { 29 | if elem == start && startIndex == nil { 30 | startIndex = queue.count 31 | } 32 | 33 | queue += transform(elem) 34 | } 35 | 36 | guard let startIndex = startIndex else { 37 | print("Tried to play a track that is not in the current playback context.") 38 | return 39 | } 40 | 41 | let animation = player.queue.isEmpty ? Animation.default : nil 42 | withAnimation(animation) { 43 | player.play(queue, from: startIndex) 44 | } 45 | } 46 | } 47 | 48 | struct OnPlayKey: EnvironmentKey { 49 | 50 | static let defaultValue: () -> () = { } 51 | 52 | } 53 | 54 | private struct PlaybackContextKey: EnvironmentKey { 55 | 56 | static let defaultValue = [AnyHashable]() 57 | 58 | } 59 | 60 | extension EnvironmentValues { 61 | 62 | var playbackContext: [AnyHashable] { 63 | get { self[PlaybackContextKey.self] } 64 | set { self[PlaybackContextKey.self] = newValue } 65 | } 66 | 67 | var onPlay: () -> () { 68 | get { self[OnPlayKey.self] } 69 | set { self[OnPlayKey.self] = newValue } 70 | } 71 | 72 | } 73 | 74 | private struct PlaybackStart: ViewModifier { 75 | 76 | var element: T 77 | var transform: (T) -> [Track] 78 | 79 | @Environment(\.playbackContext) private var playbackContext: [AnyHashable] 80 | @EnvironmentObject private var player: StreamPlayer 81 | 82 | func body(content: Content) -> some View { 83 | content 84 | .environment(\.onPlay, onPlay) 85 | } 86 | 87 | private func onPlay() { 88 | createOnPlay(playbackContext: playbackContext, start: element, transform: transform, player: player)() 89 | } 90 | 91 | } 92 | 93 | extension View { 94 | 95 | func playbackContext(_ elements: [AnyHashable]) -> some View { 96 | return environment(\.playbackContext, elements) 97 | } 98 | 99 | func playbackStart(at element: T, transform: @escaping (T) -> [Track]) -> some View { 100 | return modifier(PlaybackStart(element: element, transform: transform)) 101 | } 102 | 103 | func playbackStart(at track: Track) -> some View { 104 | return modifier(PlaybackStart(element: track, transform: { [$0] })) 105 | } 106 | 107 | func playbackStart(at post: Post) -> some View { 108 | return modifier(PlaybackStart(element: post, transform: { $0.tracks })) 109 | } 110 | 111 | } 112 | 113 | private struct PlaybackPathComponent: Hashable { 114 | 115 | var value: V 116 | var playbackContext: [AnyHashable] 117 | var onPlay: () -> () 118 | 119 | static func == (lhs: PlaybackPathComponent, rhs: PlaybackPathComponent) -> Bool { 120 | return lhs.value == rhs.value && lhs.playbackContext == rhs.playbackContext 121 | } 122 | 123 | func hash(into hasher: inout Hasher) { 124 | hasher.combine(value.hashValue) 125 | hasher.combine(playbackContext.hashValue) 126 | } 127 | 128 | } 129 | 130 | struct PlaybackNavigationLink : View where Value: Hashable, Label : View { 131 | 132 | private var value: Value 133 | private var label: Label 134 | 135 | @Environment(\.playbackContext) private var playbackContext: [AnyHashable] 136 | @Environment(\.onPlay) private var onPlay: () -> () 137 | 138 | var body: some View { 139 | let pathValue = PlaybackPathComponent(value: value, playbackContext: playbackContext, onPlay: onPlay) 140 | NavigationLink(value: pathValue) { label } 141 | } 142 | 143 | init(value: Value, @ViewBuilder label: () -> Label) { 144 | self.value = value 145 | self.label = label() 146 | } 147 | 148 | } 149 | 150 | extension View { 151 | 152 | func navigationDestinationWithPlaybackContext(for data: D.Type, @ViewBuilder destination: @escaping (D) -> C) -> some View where D : Hashable, C : View { 153 | return navigationDestination(for: PlaybackPathComponent.self) { comp in 154 | destination(comp.value) 155 | .environment(\.playbackContext, comp.playbackContext) 156 | .environment(\.onPlay, comp.onPlay) 157 | } 158 | } 159 | 160 | } 161 | 162 | extension NavigationPath { 163 | 164 | mutating func append(_ value: V, 165 | with playbackContext: [AnyHashable], 166 | startPlaybackAt start: V, 167 | transform: @escaping (V) -> [Track], 168 | player: StreamPlayer) where V : Hashable & SoundCloudIdentifiable { 169 | let onPlay = createOnPlay(playbackContext: playbackContext, 170 | start: start, 171 | transform: transform, 172 | player: player) 173 | let pathValue = PlaybackPathComponent(value: value, playbackContext: playbackContext, onPlay: onPlay) 174 | append(pathValue) 175 | } 176 | 177 | mutating func append(_ value: V, 178 | with playbackContext: [AnyHashable], 179 | startPlaybackAt start: V, 180 | player: StreamPlayer) where V == Track { 181 | append(value, 182 | with: playbackContext, 183 | startPlaybackAt: start, 184 | transform: { [$0] }, 185 | player: player) 186 | } 187 | 188 | } 189 | -------------------------------------------------------------------------------- /Nuage/Views/PlayerSlider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayerSlider.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 01.02.21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct PlayerSlider: View { 11 | 12 | enum UpdateStrategy { 13 | case continuous 14 | case incremental(Value) 15 | case onCommit 16 | } 17 | 18 | private enum ValueLabel { 19 | case constant(Content) 20 | case variable((Value) -> Content) 21 | } 22 | 23 | @Binding private var value: Value 24 | @State private var updatingValue: Value? 25 | @GestureState private var highlighted = false 26 | private var range: ClosedRange 27 | private var updateStrategy: UpdateStrategy 28 | 29 | private var minValueLabel: ValueLabel 30 | private var maxValueLabel: ValueLabel 31 | 32 | @Environment(\.colorScheme) private var colorScheme 33 | 34 | var body: some View { 35 | HStack { 36 | valueLabel(for: minValueLabel) 37 | slider() 38 | valueLabel(for: maxValueLabel) 39 | } 40 | } 41 | 42 | @ViewBuilder private func slider() -> some View { 43 | let knobRadius: CGFloat = 13 44 | 45 | GeometryReader { geometry in 46 | let currentValue = updatingValue ?? value 47 | let rangeWidth = range.upperBound - range.lowerBound 48 | let relativeValue = rangeWidth > 0 ? CGFloat(currentValue/rangeWidth) : CGFloat(0) 49 | let barValue = geometry.size.width * relativeValue 50 | let knobValue = (geometry.size.width - knobRadius) * relativeValue 51 | let currentKnobColor = highlighted ? highlightedKnobColor : knobColor 52 | 53 | let drag = DragGesture(minimumDistance: 0, coordinateSpace: .local).onChanged { gesture in 54 | var newValue = Value(gesture.location.x/geometry.size.width) * rangeWidth + range.lowerBound 55 | newValue = min(max(newValue, range.lowerBound), range.upperBound) 56 | 57 | withAnimation(.linear(duration: 0.01)) { 58 | switch updateStrategy { 59 | case .continuous: value = newValue 60 | case .incremental(let delta): 61 | updatingValue = newValue 62 | value = round(newValue/delta)*delta 63 | case .onCommit: updatingValue = newValue 64 | } 65 | } 66 | }.onEnded { gesture in 67 | value = updatingValue ?? value 68 | updatingValue = nil 69 | } 70 | .updating($highlighted) { _, highlighted, _ in 71 | highlighted = true 72 | } 73 | 74 | ZStack(alignment: Alignment(horizontal: .leading, vertical: .center)) { 75 | HStack(spacing: 0) { 76 | Rectangle() 77 | .foregroundColor(barForegroundColor) 78 | .frame(width: barValue) 79 | Rectangle() 80 | .foregroundColor(barBackgroundColor) 81 | .frame(width: geometry.size.width-barValue) 82 | } 83 | .cornerRadius(1.5) 84 | .frame(height: 3) 85 | Circle() 86 | .strokeBorder(knobBorderColor, lineWidth: 1) 87 | .background(Circle().foregroundColor(currentKnobColor)) 88 | .frame(width: knobRadius, height: knobRadius) 89 | .offset(x: knobValue) 90 | } 91 | .contentShape(Rectangle()) 92 | .gesture(drag) 93 | }.frame(height: knobRadius) 94 | } 95 | 96 | private func valueLabel(for label: ValueLabel) -> Content { 97 | switch label { 98 | case .constant(let content): return content 99 | case .variable(let buildContent): return buildContent(updatingValue ?? value) 100 | } 101 | } 102 | 103 | private var knobColor: Color { colorScheme == .light ? .white : Color(hex: 0x1A1A1A) } 104 | 105 | private var highlightedKnobColor: Color { colorScheme == .light ? Color(hex: 0xE5E5E5) : Color(hex: 0x3E3E3E) } 106 | 107 | private var knobBorderColor: Color { colorScheme == .light ? Color(hex: 0xBFBFBF) : Color(hex: 0x5A5A5A) } 108 | 109 | private var barForegroundColor: Color { colorScheme == .light ? Color(hex: 0xBFBFBF) : Color(hex: 0x5F5F5F) } 110 | 111 | private var barBackgroundColor: Color { colorScheme == .light ? Color(hex: 0xF2F2F2) : Color(hex: 0x2C2C2C) } 112 | 113 | init(value: Binding, in range: ClosedRange, updateStrategy: UpdateStrategy = .continuous) where MinValueLabel == EmptyView, MaxValueLabel == EmptyView { 114 | self.init(value: value, in: range, updateStrategy: updateStrategy, minValueLabel: .constant(EmptyView()), maxValueLabel: .constant(EmptyView())) 115 | } 116 | 117 | init(value: Binding, in range: ClosedRange, updateStrategy: UpdateStrategy = .continuous, @ViewBuilder minValueLabel: () -> MinValueLabel, @ViewBuilder maxValueLabel: () -> MaxValueLabel) { 118 | self.init(value: value, in: range, updateStrategy: updateStrategy, minValueLabel: .constant(minValueLabel()), maxValueLabel: .constant(maxValueLabel())) 119 | } 120 | 121 | init(value: Binding, in range: ClosedRange, updateStrategy: UpdateStrategy = .continuous, @ViewBuilder minValueLabel: @escaping (Value) -> MinValueLabel, @ViewBuilder maxValueLabel: () -> MaxValueLabel) { 122 | self.init(value: value, in: range, updateStrategy: updateStrategy, minValueLabel: .variable(minValueLabel), maxValueLabel: .constant(maxValueLabel())) 123 | } 124 | 125 | private init(value: Binding, in range: ClosedRange, updateStrategy: UpdateStrategy, minValueLabel: ValueLabel, maxValueLabel: ValueLabel) { 126 | self._value = value 127 | self.range = range 128 | self.updateStrategy = updateStrategy 129 | self.minValueLabel = minValueLabel 130 | self.maxValueLabel = maxValueLabel 131 | 132 | if case let .incremental(delta) = updateStrategy { 133 | assert(delta > 0, "The delta must be strictly larger than 0") 134 | } 135 | } 136 | 137 | // func minValueLabel(@ViewBuilder view: @escaping (Value) -> Content) -> PlayerSlider { 138 | // return PlayerSlider(value: $value, in: range, updateStrategy: updateStrategy, minValueLabel: .variable(view), maxValueLabel: maxValueLabel) 139 | // } 140 | 141 | } 142 | 143 | struct PlayerSlider_Previews: PreviewProvider { 144 | 145 | static var previews: some View { 146 | let value = Binding(get: { return 0.8 }, 147 | set: { _ in }) 148 | PlayerSlider(value: value, in: 0...1) 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /Nuage/Views/PlayerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayerView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 26.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | struct NoTrackError: Error {} 14 | 15 | struct PlayerView: View { 16 | 17 | var onTrackDetailTap: () -> () 18 | 19 | @State private var showingVolumeControls = false 20 | @State private var showingQueue = false 21 | @State private var subscriptions = Set() 22 | 23 | @EnvironmentObject private var player: StreamPlayer 24 | @Environment(\.colorScheme) private var colorScheme 25 | 26 | var body: some View { 27 | ZStack { 28 | let url = player.currentStream?.artworkURL ?? player.currentStream?.user.avatarURL 29 | RemoteImage(url: url, cornerRadius: 0) 30 | 31 | HStack { 32 | Button(action: onTrackDetailTap) { 33 | artwork() 34 | .aspectRatio(1.0, contentMode: .fit) 35 | .padding(.vertical, 8) 36 | 37 | trackDetails() 38 | } 39 | .frame(width: 150, alignment: .leading) 40 | .buttonStyle(.plain) 41 | 42 | FeedbackStack(for: player.currentStream, horizontal: false) 43 | 44 | Spacer() 45 | .frame(width: 8) 46 | 47 | progressSlider() 48 | .padding(.vertical) 49 | 50 | Spacer() 51 | .frame(width: 8) 52 | 53 | playbackControls() 54 | 55 | Spacer() 56 | .frame(width: 8) 57 | } 58 | .padding(.horizontal, 8) 59 | .background(.thinMaterial) 60 | } 61 | .frame(height: 60) 62 | } 63 | 64 | @ViewBuilder private func artwork() -> some View { 65 | if let track = player.currentStream { 66 | let url = track.artworkURL ?? player.currentStream?.user.avatarURL 67 | RemoteImage(url: url, cornerRadius: 3) 68 | .onTapGesture(perform: onTrackDetailTap) 69 | } 70 | else { 71 | RemoteImage(url: nil, cornerRadius: 3) 72 | } 73 | } 74 | 75 | @ViewBuilder private func trackDetails() -> some View { 76 | if let track = player.currentStream { 77 | VStack(alignment: .leading, spacing: 4) { 78 | Text(track.user.username) 79 | .bold() 80 | .lineLimit(1) 81 | Text(track.title) 82 | .lineLimit(1) 83 | .truncationMode(.tail) 84 | .foregroundColor(.secondary) 85 | } 86 | } 87 | else { 88 | Spacer() 89 | } 90 | } 91 | 92 | @ViewBuilder private func progressSlider() -> some View { 93 | let duration = TimeInterval(player.currentStream?.duration ?? 0) 94 | let font = Font.system(size: 14).monospacedDigit() 95 | 96 | WaveformSlider(url: player.currentStream?.waveformURL, value: $player.progress, in: 0...duration, minValueLabel: { progress in 97 | Text(format(time: progress)) 98 | .font(font) 99 | .frame(width: 70, alignment: .trailing) 100 | }, maxValueLabel: { _ in 101 | Text(format(time: duration)) 102 | .font(font) 103 | .frame(width: 70, alignment: .leading) 104 | }) 105 | .id(player.currentStream?.waveformURL) 106 | } 107 | 108 | @ViewBuilder private func playbackControls() -> some View { 109 | HStack(spacing: 16) { 110 | Button(action: player.advanceBackward) { 111 | resizableImage(name: "backward.fill") 112 | } 113 | .buttonStyle(.borderless) 114 | 115 | Button(action: player.togglePlayback) { 116 | let playStateImageName = player.isPlaying ? "pause.fill" : "play.fill" 117 | resizableImage(name: playStateImageName) 118 | } 119 | .buttonStyle(.borderless) 120 | .keyboardShortcut(.space, modifiers: []) 121 | 122 | Button(action: player.advanceForward) { 123 | resizableImage(name: "forward.fill") 124 | } 125 | .buttonStyle(.borderless) 126 | 127 | Button(action: { 128 | showingVolumeControls = true 129 | }) { 130 | resizableImage(name: "speaker.wave.2.fill") 131 | } 132 | .buttonStyle(.borderless) 133 | .if(showingVolumeControls) { $0.foregroundColor(.primary) } 134 | .popover(isPresented: $showingVolumeControls, content: volumeControls) 135 | 136 | Button(action: { self.showingQueue.toggle() }) { 137 | resizableImage(name: "text.line.first.and.arrowtriangle.forward") 138 | } 139 | .buttonStyle(.borderless) 140 | .if(showingQueue) { $0.foregroundColor(.primary) } 141 | .popover(isPresented: $showingQueue, content: queue) 142 | } 143 | } 144 | 145 | @ViewBuilder private func volumeControls() -> some View { 146 | HStack(spacing: 6) { 147 | Button(action: { 148 | player.volume = 0 149 | }, label: { 150 | resizableImage(name: "speaker.fill", height: 13, width: nil) 151 | }) 152 | .focusable(false) 153 | .buttonStyle(.borderless) 154 | 155 | PlayerSlider(value: $player.volume, in: 0...1, updateStrategy: .incremental(0.05)) 156 | .frame(width: 100) 157 | 158 | Button(action: { 159 | player.volume = 1 160 | }, label: { 161 | resizableImage(name: "speaker.wave.3.fill", height: 13, width: nil) 162 | }) 163 | .focusable(false) 164 | .buttonStyle(.borderless) 165 | }.padding() 166 | } 167 | 168 | @ViewBuilder private func queue() -> some View { 169 | let currentStreamIndex = player.currentStreamIndex ?? 0 170 | 171 | ScrollViewReader { proxy in 172 | List { 173 | if currentStreamIndex > 0 { 174 | let prefix = player.queue.prefix(upTo: currentStreamIndex) 175 | Section(header: Text("Previous")) { 176 | queueRows(for: prefix) 177 | } 178 | } 179 | 180 | Section(header: Text("Now Playing")) { 181 | queueRows(for: [player.queue[currentStreamIndex]]) 182 | } 183 | 184 | if currentStreamIndex < player.queue.count - 1 { 185 | let suffix = player.queue.suffix(from: currentStreamIndex+1) 186 | Section(header: Text("Up Next")) { 187 | queueRows(for: suffix) 188 | } 189 | } 190 | } 191 | .onAppear { 192 | if let id = player.currentStream?.id { 193 | proxy.scrollTo(id, anchor: .top) 194 | } 195 | } 196 | } 197 | } 198 | 199 | @ViewBuilder private func queueRows(for tracks: T) -> some View where T.Element == Track { 200 | ForEach(Array(tracks.enumerated()), id: \.element.id) { idx, track in 201 | HStack { 202 | Artwork(url: track.artworkURL ?? track.user.avatarURL, onPlay: { 203 | player.play(Array(tracks), from: idx) 204 | }) 205 | .frame(width: 60, height: 60) 206 | VStack(alignment: .leading) { 207 | Text(track.user.username) 208 | .bold() 209 | Text(track.title) 210 | .foregroundColor(.secondary) 211 | } 212 | } 213 | Divider() 214 | } 215 | } 216 | 217 | @ViewBuilder private func resizableImage(name: String, height: CGFloat? = 15, width: CGFloat? = 15) -> some View { 218 | Image(systemName: name) 219 | .resizable() 220 | .aspectRatio(contentMode: .fit) 221 | .frame(width: width, height: height) 222 | } 223 | 224 | } 225 | 226 | struct PlayerView_Previews: PreviewProvider { 227 | 228 | static var previews: some View { 229 | let player = StreamPlayer() 230 | player.enqueue(Preview.tracks) 231 | 232 | return PlayerView(onTrackDetailTap: {}).environmentObject(player) 233 | } 234 | 235 | } 236 | -------------------------------------------------------------------------------- /Nuage/Views/StatsStack.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StatsStack.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 01.08.23. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | 11 | struct StatsStack: View { 12 | 13 | private var track: Track 14 | 15 | var body: some View { 16 | HStack(spacing: 4) { 17 | Image(systemName: "play.fill") 18 | Text(String(track.playbackCount)) 19 | 20 | Spacer().frame(width: 2) 21 | 22 | Image(systemName: "heart.fill") 23 | Text(String(track.likeCount)) 24 | 25 | Spacer().frame(width: 2) 26 | 27 | Image(systemName: "arrow.triangle.2.circlepath") 28 | Text(String(track.repostCount)) 29 | } 30 | } 31 | 32 | init(for track: Track) { 33 | self.track = track 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Nuage/Views/TouchBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TouchBar.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 09.07.23. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | struct TouchBar: View { 13 | 14 | @State private var subscriptions = Set() 15 | 16 | @EnvironmentObject private var player: StreamPlayer 17 | @Environment(\.colorScheme) private var colorScheme 18 | 19 | var body: some View { 20 | if let track = player.currentStream { 21 | let font = Font.system(size: 12) 22 | .monospacedDigit() 23 | HStack { 24 | VStack(alignment: .leading) { 25 | Text(track.user.username) 26 | .bold() 27 | .lineLimit(1) 28 | .font(font) 29 | Text(track.title) 30 | .lineLimit(1) 31 | .font(font) 32 | .truncationMode(.tail) 33 | .foregroundColor(.secondary) 34 | } 35 | .frame(maxWidth: 200) 36 | progressSlider(for: track) 37 | } 38 | } 39 | } 40 | 41 | @ViewBuilder private func progressSlider(for track: Track) -> some View { 42 | let duration = TimeInterval(player.currentStream?.duration ?? 0) 43 | let font = Font.system(size: 14).monospacedDigit() 44 | 45 | WaveformSlider(url: track.waveformURL, value: $player.progress, in: 0...duration, minValueLabel: { progress in 46 | Text(format(time: progress)) 47 | .font(font) 48 | .frame(width: 70, alignment: .trailing) 49 | }, maxValueLabel: { _ in 50 | Text(format(time: duration)) 51 | .font(font) 52 | .frame(width: 70, alignment: .leading) 53 | }, knobColor: Color(hex: 0x1A1A1A), knobBorderColor: Color(hex: 0x5A5A5A)) 54 | .frame(minWidth: 440) 55 | .foregroundColor(.white) 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Nuage/Views/TrackContextMenu.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackContextMenu.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 04.12.20. 6 | // Copyright © 2020 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | private struct TrackContextMenu: ViewModifier { 14 | 15 | @ObservedObject private var soundCloud = SoundCloud.shared 16 | 17 | var track: Track 18 | 19 | @State private var subscriptions = Set() 20 | 21 | @EnvironmentObject private var player: StreamPlayer 22 | @Environment(\.playlists) private var playlists: [AnyPlaylist] 23 | @Environment(\.toggleLikeTrack) private var toggleLike: (Track) -> () -> () 24 | @Environment(\.toggleRepostTrack) private var toggleRepost: (Track) -> () -> () 25 | @Environment(\.onPlay) private var onPlay: () -> () 26 | 27 | func body(content: Content) -> some View { 28 | content.contextMenu { 29 | Button("Play", action: onPlay) 30 | Button("Add to Queue") { 31 | player.enqueue([track]) 32 | } 33 | Divider() 34 | Button("Go to User") { 35 | print("haha") 36 | } 37 | Divider() 38 | Button("Like", action: toggleLike(track)) 39 | Button("Repost", action: toggleRepost(track)) 40 | Menu("Add to Playlist") { 41 | Button("New Playlist") { 42 | print("new playlist lel") 43 | } 44 | 45 | let playlists = playlists 46 | .compactMap { $0.userPlaylist } 47 | .filter { $0.secretToken != nil } 48 | if playlists.count > 0 { 49 | Divider() 50 | ForEach(playlists, id: \.id) { playlist in 51 | Button(playlist.title) { 52 | let newTrackID = Int(track.id)! 53 | 54 | soundCloud.get(.userPlaylist(playlist.id)) 55 | .map { ($0.trackIDs ?? []).map { Int($0)! } } 56 | .flatMap { soundCloud.get(.set(playlist, trackIDs: $0 + [newTrackID])) } 57 | .receive(on: RunLoop.main) 58 | .sink(receiveCompletion: { _ in 59 | }, receiveValue: { success in 60 | print("added track to playlist: \(success)") 61 | }).store(in: &subscriptions) 62 | } 63 | } 64 | } 65 | } 66 | Divider() 67 | Button("Copy Link") { 68 | let text = track.permalinkURL.absoluteString 69 | NSPasteboard.general.declareTypes([.string], owner: nil) 70 | NSPasteboard.general.setString(text, forType: .string) 71 | } 72 | } 73 | } 74 | 75 | } 76 | 77 | extension View { 78 | 79 | func trackContextMenu(with track: Track) -> some View { 80 | return modifier(TrackContextMenu(track: track)) 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Nuage/Views/UserGrid.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserGrid.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 27.12.19. 6 | // Copyright © 2019 Laurin Brandner. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Combine 11 | import SoundCloud 12 | 13 | struct UserGrid: View { 14 | 15 | var publisher: InfinitePublisher 16 | private var transform: (Element) -> User 17 | 18 | var body: some View { 19 | InfiniteGrid(publisher: publisher) { users, idx in 20 | let user = transform(users[idx]) 21 | NavigationLink(value: user) { 22 | UserItem(user: user) 23 | } 24 | .buttonStyle(.plain) 25 | } 26 | } 27 | 28 | } 29 | 30 | extension UserGrid where Element == User { 31 | 32 | init(for publisher: AnyPublisher, Error>) { 33 | self.init(publisher: .page(publisher)) { $0 } 34 | } 35 | 36 | } 37 | 38 | extension UserGrid where Element == Recommendation { 39 | 40 | init(for publisher: AnyPublisher, Error>) { 41 | self.init(publisher: .page(publisher)) { $0.user } 42 | } 43 | 44 | } 45 | 46 | struct UserItem: View { 47 | 48 | var user: User 49 | 50 | var body: some View { 51 | VStack(alignment: .center) { 52 | RemoteImage(url: user.avatarURL, cornerRadius: 50) 53 | .frame(width: 100, height: 100) 54 | 55 | Text(user.username) 56 | .bold() 57 | .lineLimit(1) 58 | 59 | HStack(spacing: 2) { 60 | Text(String(user.followerCount ?? 0)) 61 | Image(systemName: "person.2.fill") 62 | 63 | Spacer() 64 | .frame(width: 8) 65 | 66 | Text(String(user.trackCount ?? 0)) 67 | Image(systemName: "waveform") 68 | } 69 | .foregroundColor(.secondary) 70 | } 71 | } 72 | 73 | } 74 | 75 | //struct UserList_Previews: PreviewProvider { 76 | // static var previews: some View { 77 | // UserList() 78 | // } 79 | //} 80 | -------------------------------------------------------------------------------- /Nuage/Views/WaveformSlider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WaveformSlider.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 12.10.22. 6 | // 7 | 8 | import SwiftUI 9 | import SoundCloud 10 | 11 | struct WaveformSlider: View { 12 | 13 | var url: URL? 14 | @Binding private var value: Value 15 | @State private var updatingValue: Value? 16 | 17 | @GestureState private var highlighted = false 18 | 19 | private var range: ClosedRange 20 | 21 | private var minValueLabel: (Value) -> MinValueLabel 22 | private var maxValueLabel: (Value) -> MaxValueLabel 23 | 24 | private var knobColor: Color? 25 | private var knobBorderColor: Color 26 | private var waveformForegroundColor: Color 27 | private var waveformBackgroundColor: Color 28 | 29 | var body: some View { 30 | HStack { 31 | minValueLabel(updatingValue ?? value) 32 | slider() 33 | maxValueLabel(updatingValue ?? value) 34 | } 35 | } 36 | 37 | @ViewBuilder private func slider() -> some View { 38 | let knobDiameter: CGFloat = 13 39 | 40 | GeometryReader { geometry in 41 | let currentValue = updatingValue ?? value 42 | let rangeWidth = range.upperBound - range.lowerBound 43 | let relativeValue = rangeWidth > 0 ? CGFloat(currentValue/rangeWidth) : CGFloat(0) 44 | let barValue = geometry.size.width * relativeValue 45 | let knobValue = geometry.size.width * relativeValue - knobDiameter/2.0 46 | 47 | let drag = DragGesture(minimumDistance: 0, coordinateSpace: .local).onChanged { gesture in 48 | var newValue = Value(gesture.location.x/geometry.size.width) * rangeWidth + range.lowerBound 49 | newValue = min(max(newValue, range.lowerBound), range.upperBound) 50 | 51 | withAnimation(.linear(duration: 0.01)) { 52 | updatingValue = newValue 53 | } 54 | }.onEnded { gesture in 55 | value = updatingValue ?? value 56 | updatingValue = nil 57 | } 58 | .updating($highlighted) { _, highlighted, _ in 59 | highlighted = true 60 | } 61 | 62 | HStack(alignment: .center) { 63 | ZStack(alignment: Alignment(horizontal: .leading, vertical: .center)) { 64 | HStack(spacing: 0) { 65 | Rectangle() 66 | .foregroundColor(waveformForegroundColor) 67 | .frame(width: barValue) 68 | Rectangle() 69 | .foregroundColor(waveformBackgroundColor) 70 | .frame(width: max(0, geometry.size.width-barValue)) 71 | } 72 | .mask(WaveformView(url: url)) 73 | 74 | knob() 75 | .frame(width: knobDiameter, height: knobDiameter) 76 | .offset(x: knobValue) 77 | } 78 | }.gesture(drag) 79 | } 80 | } 81 | 82 | @ViewBuilder private func knob() -> some View { 83 | let knob = Circle() 84 | .strokeBorder(knobBorderColor, lineWidth: 1) 85 | 86 | if let knobColor = knobColor { 87 | knob.background(Circle().foregroundColor(knobColor)) 88 | } 89 | else { 90 | knob.background(.ultraThinMaterial, in: Circle()) 91 | } 92 | } 93 | 94 | init(url: URL?, value: Binding, in range: ClosedRange, @ViewBuilder minValueLabel: @escaping (Value) -> MinValueLabel, @ViewBuilder maxValueLabel: @escaping (Value) -> MaxValueLabel, knobColor: Color? = nil, knobBorderColor: Color? = nil, waveformForegroundColor: Color? = nil, waveformBackgroundColor: Color? = nil) { 95 | self.url = url 96 | self._value = value 97 | self.range = range 98 | self.minValueLabel = minValueLabel 99 | self.maxValueLabel = maxValueLabel 100 | 101 | self.knobColor = knobColor 102 | self.knobBorderColor = knobBorderColor ?? .primary.opacity(0.4) 103 | self.waveformForegroundColor = waveformForegroundColor ?? .primary 104 | self.waveformBackgroundColor = knobColor ?? .primary.opacity(0.2) 105 | } 106 | 107 | } 108 | 109 | //struct WaveformSlider_Previews: PreviewProvider { 110 | // static var previews: some View { 111 | // let half = Array(1...50) 112 | // let samples = half.reversed() + half 113 | // let waveform = Waveform(width: 100, height: 50, samples: samples) 114 | // WaveformSlider(waveform: waveform) 115 | // .frame(width: 400, height: 100) 116 | // } 117 | //} 118 | -------------------------------------------------------------------------------- /Nuage/Views/WaveformView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WaveformView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 14.01.21. 6 | // 7 | 8 | import SwiftUI 9 | import Combine 10 | import SoundCloud 11 | 12 | private let spacing: CGFloat = 3 13 | private let barWidth: CGFloat = 3 14 | private let emptyWaveform = Waveform(samples: Array(repeating: 2, count: 100)) 15 | 16 | struct WaveformView: View { 17 | 18 | var url: URL? 19 | @State private var waveform = emptyWaveform 20 | 21 | @State private var subscriptions = Set() 22 | 23 | var body: some View { 24 | GeometryReader { geometry in 25 | let numberOfBars = CGFloat(geometry.size.width+spacing)/CGFloat(spacing+barWidth) 26 | let samplesPerBar = floor(CGFloat(waveform.samples.count)/numberOfBars) 27 | let bars = Array(0.. CGFloat in 29 | let idx = CGFloat(bar)*samplesPerBar 30 | let sample = interpolate(from: idx, to: idx+samplesPerBar)/CGFloat(waveform.maxHeight) 31 | return CGFloat(pow(sample, 3)) 32 | } 33 | let shouldScale = (self.waveform != emptyWaveform) 34 | let maxBar = bars.max() ?? 1.0 35 | 36 | HStack(alignment: .center, spacing: spacing) { 37 | ForEach(Array(bars.enumerated()), id: \.offset) { _, bar in 38 | let height = shouldScale ? (bar / maxBar) * geometry.size.height : bar 39 | 40 | Rectangle() 41 | .frame(width: barWidth, height: height) 42 | .cornerRadius(barWidth/2) 43 | } 44 | } 45 | .frame(minHeight: 0, maxHeight: .infinity) 46 | .animation(.spring(), value: waveform) 47 | } 48 | .onAppear { 49 | guard let url = url else { return } 50 | SoundCloud.shared.get(.waveform(url)) 51 | .replaceError(with: emptyWaveform) 52 | .receive(on: RunLoop.main) 53 | .sink { waveform in 54 | withAnimation { 55 | self.waveform = waveform 56 | } 57 | } 58 | .store(in: &subscriptions) 59 | } 60 | } 61 | 62 | private func interpolate(from: CGFloat, to: CGFloat) -> CGFloat { 63 | let lhs = max(Int(round(from)), 0) 64 | let rhs = min(Int(round(to)), waveform.samples.count-1) 65 | let sum = waveform.samples[lhs...rhs].reduce(0, +) 66 | let cnt = rhs-lhs+1 67 | 68 | return CGFloat(sum)/CGFloat(cnt) 69 | } 70 | 71 | } 72 | 73 | //struct WaveformView_Previews: PreviewProvider { 74 | // static var previews: some View { 75 | // let half = Array(1...50) 76 | // let samples = half.reversed() + half 77 | // let waveform = Waveform(samples: samples) 78 | // WaveformView(with: waveform) 79 | // .frame(width: 400, height: 100) 80 | // .foregroundColor(.accentColor) 81 | // } 82 | //} 83 | -------------------------------------------------------------------------------- /Nuage/Views/WebView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WebView.swift 3 | // Nuage 4 | // 5 | // Created by Laurin Brandner on 24.01.21. 6 | // 7 | 8 | import SwiftUI 9 | import AppKit 10 | import WebKit 11 | import Combine 12 | 13 | typealias CookieHandler = ((HTTPCookie) -> ()) 14 | 15 | struct WebView: NSViewRepresentable { 16 | 17 | private var url: URL 18 | private var coordinator = WebViewCoordinator() 19 | 20 | init(url: URL) { 21 | self.url = url 22 | } 23 | 24 | func makeCoordinator() -> WebViewCoordinator { 25 | return coordinator 26 | } 27 | 28 | func makeNSView(context: Self.Context) -> WKWebView { 29 | let conf = WKWebViewConfiguration() 30 | conf.websiteDataStore = WKWebsiteDataStore.nonPersistent() 31 | 32 | let view = WKWebView(frame: .zero, configuration: conf) 33 | view.load(URLRequest(url: url)) 34 | view.navigationDelegate = context.coordinator 35 | view.uiDelegate = context.coordinator 36 | 37 | coordinator.webView = view 38 | 39 | return view 40 | } 41 | 42 | func updateNSView(_ nsView: WKWebView, context: Context) {} 43 | 44 | func cookie(name: String, handler: @escaping CookieHandler) -> WebView { 45 | coordinator.handlers.append((name, handler)) 46 | return self 47 | } 48 | 49 | } 50 | 51 | class WebViewCoordinator: NSObject, WKNavigationDelegate, WKUIDelegate, ObservableObject { 52 | 53 | var handlers = [(String, CookieHandler)]() 54 | var webView: WKWebView? { 55 | didSet { 56 | webView?.publisher(for: \.url) 57 | .sink { _ in self.scanCookiesForAccessToken() } 58 | .store(in: &cancellables) 59 | } 60 | } 61 | private var cancellables = Set() 62 | 63 | func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { 64 | scanCookiesForAccessToken() 65 | decisionHandler(.allow) 66 | } 67 | 68 | func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { 69 | let view = WKWebView(frame: .zero, configuration: configuration) 70 | view.navigationDelegate = self 71 | view.uiDelegate = self 72 | 73 | let size = NSSize(width: windowFeatures.width?.doubleValue ?? 500, height: windowFeatures.height?.doubleValue ?? 500) 74 | let window = NSWindow(contentRect: NSRect(origin: .zero, size: size), styleMask: [.closable, .titled], backing: .buffered, defer: false) 75 | window.isReleasedWhenClosed = false 76 | window.contentView = view 77 | window.makeKeyAndOrderFront(nil) 78 | window.center() 79 | 80 | return view 81 | } 82 | 83 | func webViewDidClose(_ webView: WKWebView) { 84 | webView.window?.close() 85 | } 86 | 87 | private func scanCookiesForAccessToken() { 88 | guard let webView = webView else { return } 89 | let store = webView.configuration.websiteDataStore 90 | 91 | store.httpCookieStore.getAllCookies { cookies in 92 | for cookie in cookies { 93 | for (name, handler) in self.handlers { 94 | if name == cookie.name { 95 | handler(cookie) 96 | } 97 | } 98 | } 99 | } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

Nuage

6 |

A native SoundCloud app for macOS, written in SwiftUI

7 | 8 | --- 9 | 10 | [![Twitter: @lbrndnr](https://img.shields.io/badge/Twitter-@lbrndnr-blue.svg?style=flat)](https://twitter.com/lbrndnr) 11 | [![Twitter: @lbrndnr](https://img.shields.io/badge/Mastodon-@lerboe@mastodon.social-purple.svg?style=flat)](https://mastodon.social/@lerboe) 12 | [![SoundCloud: @lerboe](https://img.shields.io/badge/SoundCloud-@lerboe-orange.svg?style=flat)](https://soundcloud.com/lerboe) 13 | [![License](http://img.shields.io/badge/license-GPL--3.0-green.svg?style=flat)](https://github.com/lbrndnr/nuage-macos/blob/master/LICENSE) 14 | 15 | ## About 16 | Nuage is an independent and open-source project to build a native SoundCloud client for macOS using SwiftUI. Its overall goal is to make listening to tracks on SoundCloud more enjoyable by providing a light-weight and beautiful interface. As of now, the app is still very much in development, lots of features are still missing and the UI needs a lot of work too. So if you want to learn a little bit of SwiftUI or if you have a suggestion regarding the user experience, feel free to open an issue or a merge request. 17 | 18 | Nuage Main View 19 | 20 | Note that Nuage is not affiliated in any way to SoundCloud. Nuage uses private APIs which I have not been granted access to, so functionality may break in the future. 21 | 22 | ## Installation 23 | 24 | You can install Nuage using brew: 25 | ```console 26 | $ brew install --cask nuage 27 | ``` 28 | or by downloading the latest version right [here](https://github.com/lbrndnr/nuage-macos/releases). Note that Nuage is still in heavy development and on top of that written in SwiftUI, a very young framework. If you encounter a bug or miss a feature, don't hesitate to open a pull request. 29 | 30 | ## Dependencies 31 | 32 | Nuage uses [SoundCloud](https://github.com/lbrndnr/soundcloud) to access SoundCloud's private API. 33 | 34 | ## Code & Design 35 | Developed by [Laurin Brandner](https://twitter.com/lbrndnr), icon designed by [Yannick Lung](https://twitter.com/yannicklu). 36 | 37 | ## License 38 | Nuage is licensed under GPL-3.0. You can use Nuage's code as long as your app is also licensed as GPL-3.0. For all other applications please [contact me](https://twitter.com/lbrndnr). 39 | --------------------------------------------------------------------------------