├── .gitignore ├── Iris.plist ├── LICENSE ├── Makefile ├── Media ├── 1-Mockup.png ├── 10-Mockup.png ├── 2-Mockup.png ├── 3-Mockup.png ├── 4-1.png ├── 4-2.png ├── 4-Mockup.png ├── 5-Mockup.png ├── 6-Mockup.png ├── 7-Mockup.png ├── 8-Mockup.png ├── 9-Mockup.png ├── Banner.png ├── Dark.png ├── Iris Demo.mov ├── Iris.png ├── Iris.rotato └── Light.png ├── Preferences ├── Iris-Bridging-Header.h ├── IrisFlagTagSelectionViewController.h ├── IrisFlagTagSelectionViewController.m ├── IrisRootListController.h ├── IrisRootListController.m ├── Makefile ├── Resources │ ├── Info.plist │ ├── Root.plist │ ├── icon-large.png │ ├── icon.png │ ├── icon@2x.png │ └── icon@3x.png ├── entry.plist └── src ├── README.md ├── layout └── DEBIAN │ ├── control │ ├── postinst │ └── postrm └── src ├── Objective-C ├── Categories │ ├── NSString+Compatibility.h │ ├── NSString+Compatibility.m │ └── UIKit+Private.h ├── Controller │ ├── IrisTagCreationAlertCollectionViewController.h │ ├── IrisTagCreationAlertCollectionViewController.x │ ├── IrisTagCreationAlertController.h │ ├── IrisTagCreationAlertController.x │ ├── IrisTagListTableViewController.h │ └── IrisTagListTableViewController.m ├── Globals.h ├── Globals.m ├── Iris-Bridging-Header.h ├── Model │ ├── IrisConversationFlag.h │ ├── IrisConversationTag.h │ └── IrisConversationTag.m ├── Tweak │ ├── Tweak.h │ └── Tweak.x └── View │ ├── IrisAvatarCollectionViewCell.h │ ├── IrisAvatarCollectionViewCell.x │ ├── IrisRoundedBorderLayer.h │ └── IrisRoundedBorderLayer.m └── Swift ├── Extensions └── UIView+allSubviews.swift ├── Model ├── IrisButtonModel.swift ├── IrisFlagTagButtonCollectionControlModel.swift └── IrisFlagTagButtonModel.swift ├── Protocols ├── BadgeView.swift └── IrisMenuButtonDelegate.swift └── View ├── IrisButton.swift ├── IrisButtonCollectionViewCell.swift ├── IrisFlagTagButton.swift ├── IrisFlagTagButtonCollectionControl.swift ├── IrisFlagTagButtonCollectionControlCell.swift ├── IrisFlagTagButtonCollectionView.swift ├── IrisFlagTagButtonCollectionViewCell.swift ├── IrisMenuButton.swift ├── IrisMenuButtonDimmingView.swift └── IrisMenuCollectionView.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .theos/ 3 | packages/ -------------------------------------------------------------------------------- /Iris.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.MobileSMS", "com.apple.imagent", "com.apple.tccd", "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 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 Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export ARCHS = arm64 arm64e 2 | export TARGET := iphone::13.0:13.0 3 | export ADDITIONAL_CFLAGS = -DTHEOS_LEAN_AND_MEAN # -DMOCKUP 4 | INSTALL_TARGET_PROCESSES = SpringBoard imagent tccd 5 | 6 | include $(THEOS)/makefiles/common.mk 7 | 8 | TWEAK_NAME = Iris 9 | Iris_FILES = $(wildcard src/Objective-C/**/*.x) $(wildcard src/Objective-C/*m) $(wildcard src/Objective-C/**/*.m) $(wildcard src/Swift/**/*.*) 10 | Iris_SWIFT_BRIDGING_HEADER = src/Objective-C/Iris-Bridging-Header.h 11 | Iris_EXTRA_FRAMEWORKS = libJCX Alderis 12 | Iris_CFLAGS = -fobjc-arc 13 | 14 | include $(THEOS_MAKE_PATH)/tweak.mk 15 | 16 | SUBPROJECTS = Preferences 17 | include $(THEOS_MAKE_PATH)/aggregate.mk 18 | -------------------------------------------------------------------------------- /Media/1-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/1-Mockup.png -------------------------------------------------------------------------------- /Media/10-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/10-Mockup.png -------------------------------------------------------------------------------- /Media/2-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/2-Mockup.png -------------------------------------------------------------------------------- /Media/3-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/3-Mockup.png -------------------------------------------------------------------------------- /Media/4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/4-1.png -------------------------------------------------------------------------------- /Media/4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/4-2.png -------------------------------------------------------------------------------- /Media/4-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/4-Mockup.png -------------------------------------------------------------------------------- /Media/5-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/5-Mockup.png -------------------------------------------------------------------------------- /Media/6-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/6-Mockup.png -------------------------------------------------------------------------------- /Media/7-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/7-Mockup.png -------------------------------------------------------------------------------- /Media/8-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/8-Mockup.png -------------------------------------------------------------------------------- /Media/9-Mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/9-Mockup.png -------------------------------------------------------------------------------- /Media/Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Banner.png -------------------------------------------------------------------------------- /Media/Dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Dark.png -------------------------------------------------------------------------------- /Media/Iris Demo.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Iris Demo.mov -------------------------------------------------------------------------------- /Media/Iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Iris.png -------------------------------------------------------------------------------- /Media/Iris.rotato: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Iris.rotato -------------------------------------------------------------------------------- /Media/Light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Media/Light.png -------------------------------------------------------------------------------- /Preferences/Iris-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | ../Objective-C/Iris-Bridging-Header.h -------------------------------------------------------------------------------- /Preferences/IrisFlagTagSelectionViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IrisPreferences-Swift.h" 3 | 4 | @interface IrisFlagTagSelectionViewController : UITableViewController 5 | @property (nonatomic, retain) NSMutableArray * _Nonnull list; 6 | @property (nonatomic, retain) NSString * _Nonnull defaults; 7 | @property (nonatomic, retain) NSString * _Nullable navBarTitle; 8 | @property (nonatomic, retain) NSString * _Nullable selectedTagUUID; 9 | @property (nonatomic) IrisConversationFlag selectedFlag; 10 | + (instancetype _Nonnull)controllerWithTitle:(NSString * _Nullable)title defaults:(NSString * _Nonnull)defaults; 11 | - (instancetype _Nonnull)initWithTitle:(NSString * _Nullable)title defaults:(NSString * _Nonnull)defaults; 12 | - (void)loadList; 13 | - (void)saveList; 14 | @end -------------------------------------------------------------------------------- /Preferences/IrisFlagTagSelectionViewController.m: -------------------------------------------------------------------------------- 1 | #import "IrisFlagTagSelectionViewController.h" 2 | #import 3 | #import "src/Objective-C/Globals.h" 4 | 5 | @implementation IrisFlagTagSelectionViewController 6 | + (instancetype _Nonnull)controllerWithTitle:(NSString * _Nullable)title defaults:(NSString * _Nonnull)defaults { 7 | return [[self alloc] initWithTitle:title defaults:defaults]; 8 | } 9 | - (instancetype _Nonnull)initWithTitle:(NSString * _Nullable)title defaults:(NSString * _Nonnull)defaults { 10 | if (self = [super initWithStyle:UITableViewStyleGrouped]) { 11 | _navBarTitle = title; 12 | _defaults = defaults; 13 | [self loadList]; 14 | } 15 | return self; 16 | } 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.navigationItem.title = _navBarTitle; 20 | } 21 | - (void)viewDidDisappear:(BOOL)animated { 22 | [super viewDidDisappear:animated]; 23 | [self saveList]; 24 | } 25 | - (void)loadList { 26 | NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:_defaults]; 27 | NSData *tagsArrayData = [userDefaults dataForKey:tagsArrayKey]; 28 | NSMutableArray *tagsArray = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[[NSMutableArray class], [IrisConversationTag class], [NSUUID class], [NSString class], [UIColor class]]] fromData:tagsArrayData error:nil]; 29 | _list = tagsArray ? generateButtonModelsWithTags(tagsArray, false, false) : [NSMutableArray new]; 30 | _selectedFlag = [userDefaults objectForKey:defaultFlagKey] ? [[userDefaults objectForKey:defaultFlagKey] unsignedIntegerValue] : Shown; 31 | _selectedTagUUID = [userDefaults stringForKey:defaultTagUUIDKey]; 32 | } 33 | - (void)saveList { 34 | NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:_defaults]; 35 | [userDefaults setObject:@(_selectedFlag) forKey:defaultFlagKey]; 36 | [userDefaults setObject:_selectedTagUUID forKey:defaultTagUUIDKey]; 37 | [[JCXNotificationCentre centre] postNotificationWithName:userDefaultsDidUpdateNotificationName to:[NSDistributedNotificationCenter defaultCenter]]; 38 | } 39 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 40 | return _list.count; 41 | } 42 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 43 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"entryCell"]; 44 | IrisFlagTagButtonModel *buttonModel = _list[indexPath.row]; 45 | cell.textLabel.text = buttonModel.name; 46 | cell.imageView.image = buttonModel.image; 47 | cell.imageView.tintColor = buttonModel.tintColour; 48 | cell.accessoryType = buttonModel.conversationFlag == _selectedFlag && ((!buttonModel.conversationTag && !_selectedTagUUID) || [buttonModel.conversationTag.uuid.UUIDString isEqualToString:_selectedTagUUID]) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; 49 | return cell; 50 | } 51 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 52 | [tableView deselectRowAtIndexPath:indexPath animated:true]; 53 | IrisFlagTagButtonModel *buttonModel = _list[indexPath.row]; 54 | _selectedFlag = buttonModel.conversationFlag; 55 | _selectedTagUUID = buttonModel.conversationTag.uuid.UUIDString; 56 | [tableView reloadData]; 57 | [self saveList]; 58 | } 59 | @end -------------------------------------------------------------------------------- /Preferences/IrisRootListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IrisRootListController : JCXRootListController 4 | - (void)killall; 5 | - (void)pushFlagTagSelectionViewController; 6 | @end 7 | -------------------------------------------------------------------------------- /Preferences/IrisRootListController.m: -------------------------------------------------------------------------------- 1 | #import "IrisRootListController.h" 2 | #import "IrisFlagTagSelectionViewController.h" 3 | #import "src/Objective-C/Globals.h" 4 | 5 | @implementation IrisRootListController 6 | - (void)viewDidLoad { 7 | [super viewDidLoad]; 8 | UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Apply" style:UIBarButtonItemStylePlain target:self action:@selector(killall)]; 9 | self.navigationItem.rightBarButtonItem = button; 10 | } 11 | - (void)killall { 12 | NSTask *killallIMAgent = [NSTask new]; 13 | [killallIMAgent setLaunchPath:@"/usr/bin/killall"]; 14 | [killallIMAgent setArguments:@[@"-9", @"imagent"]]; 15 | [killallIMAgent launch]; 16 | NSTask *killallTCCd = [NSTask new]; 17 | [killallTCCd setLaunchPath:@"/usr/bin/killall"]; 18 | [killallTCCd setArguments:@[@"-9", @"tccd"]]; 19 | [killallTCCd launch]; 20 | NSTask *killallSpringBoard = [NSTask new]; 21 | [killallSpringBoard setLaunchPath:@"/usr/bin/killall"]; 22 | [killallSpringBoard setArguments:@[@"-9", @"SpringBoard"]]; 23 | [killallSpringBoard launch]; 24 | } 25 | - (void)pushFlagTagSelectionViewController { 26 | IrisFlagTagSelectionViewController *viewController = [IrisFlagTagSelectionViewController controllerWithTitle:@"Select Default List" defaults:@"com.apple.MobileSMS"]; 27 | [self.navigationController pushViewController:viewController animated:true]; 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /Preferences/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | BUNDLE_NAME = IrisPreferences 4 | IrisPreferences_FILES = $(wildcard *.m) $(wildcard src/Swift/Model/*ButtonModel.swift) src/Objective-C/Model/IrisConversationTag.m src/Objective-C/Globals.m 5 | IrisPreferences_SWIFT_BRIDGING_HEADER = src/Objective-C/Iris-Bridging-Header.h 6 | IrisPreferences_INSTALL_PATH = /Library/PreferenceBundles 7 | IrisPreferences_PRIVATE_FRAMEWORKS = Preferences 8 | IrisPreferences_EXTRA_FRAMEWORKS += libJCX 9 | IrisPreferences_CFLAGS = -fobjc-arc -DIS_PREFS 10 | 11 | include $(THEOS_MAKE_PATH)/bundle.mk 12 | 13 | internal-stage:: 14 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 15 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/IrisPreferences.plist$(ECHO_END) 16 | -------------------------------------------------------------------------------- /Preferences/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | IrisPreferences 9 | CFBundleIdentifier 10 | com.jacobcxdev.iris.preferences 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | IrisRootListController 23 | IrisPackageBundleID 24 | com.jacobcxdev.iris 25 | 26 | 27 | -------------------------------------------------------------------------------- /Preferences/Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cellClass 9 | JCXGradientHeaderCell 10 | subtitle 11 | By {Author} — v{Version} 12 | prefsBundle 13 | com.jacobcxdev.iris.preferences 14 | tweakBundle 15 | com.jacobcxdev.iris 16 | icon 17 | icon-large.png 18 | colours 19 | #BBFFFF,#BBBBFF,#FFBBFF 20 | darkColours 21 | #99DDDD,#9999DD,#DD99DD 22 | animated 23 | 24 | 25 | 26 | cellClass 27 | JCXEtymologyCell 28 | word 29 | Iris (mythology) 30 | information 31 | (/ˈaɪrɪs/; Greek: Ίρις Ancient Greek: [îːris]) 32 | definition 33 | The personification and goddess of the rainbow and messenger of the gods. 34 | linkURL 35 | https://en.wikipedia.org/wiki/Iris_(mythology) 36 | tweakBundle 37 | com.jacobcxdev.iris 38 | 39 | 40 | cell 41 | PSGroupCell 42 | label 43 | Main Preferences 44 | 45 | 46 | cell 47 | PSSwitchCell 48 | default 49 | 50 | defaults 51 | com.jacobcxdev.iris 52 | key 53 | enabled 54 | label 55 | Enabled 56 | 57 | 58 | cell 59 | PSGroupCell 60 | label 61 | Default List Preferences 62 | footerText 63 | Choose the default conversation list. 64 | 65 | 66 | cellClass 67 | JCXDisclosureCell 68 | action 69 | pushFlagTagSelectionViewController 70 | label 71 | Default List 72 | 73 | 74 | cell 75 | PSGroupCell 76 | footerText 77 | Show the default conversation list (instead of the previously shown conversation list) when you launch the Messages application. 78 | 79 | 80 | cell 81 | PSSwitchCell 82 | default 83 | 84 | defaults 85 | com.jacobcxdev.iris 86 | key 87 | shouldOpenWithDefaults 88 | label 89 | Open with Default List 90 | 91 | 92 | cell 93 | PSGroupCell 94 | label 95 | Activation Preferences 96 | footerText 97 | Show the Iris button in the navigation bar inside Messages. 98 | 99 | 100 | cell 101 | PSSwitchCell 102 | default 103 | 104 | defaults 105 | com.jacobcxdev.iris 106 | key 107 | shouldShowButton 108 | label 109 | Show Iris Button 110 | 111 | 112 | cell 113 | PSGroupCell 114 | footerText 115 | Toggle between the default and hidden conversation lists by shaking your device. 116 | 117 | 118 | cell 119 | PSSwitchCell 120 | default 121 | 122 | defaults 123 | com.jacobcxdev.iris 124 | key 125 | shouldToggleWhenShaken 126 | label 127 | Toggle with Shake 128 | 129 | 130 | cell 131 | PSGroupCell 132 | footerText 133 | Toggle between the default and hidden conversation lists by pressing both volume buttons simultaneously. 134 | 135 | 136 | cell 137 | PSSwitchCell 138 | default 139 | 140 | defaults 141 | com.jacobcxdev.iris 142 | key 143 | shouldToggleWhenVolumePressedSimultaneously 144 | label 145 | Toggle with Volume Buttons 146 | 147 | 148 | cell 149 | PSGroupCell 150 | footerText 151 | Toggle between the default and hidden conversation lists by toggling your device's ringer switch 3 times. 152 | 153 | 154 | cell 155 | PSSwitchCell 156 | default 157 | 158 | defaults 159 | com.jacobcxdev.iris 160 | key 161 | shouldToggleWhenRingerSwitched 162 | label 163 | Toggle with Ringer Switch 164 | 165 | 166 | cell 167 | PSGroupCell 168 | label 169 | Filtering Preferences 170 | footerText 171 | Automatically hide conversations from unknown senders. 172 | 173 | 174 | cell 175 | PSSwitchCell 176 | default 177 | 178 | defaults 179 | com.jacobcxdev.iris 180 | key 181 | shouldHideUnknownSenders 182 | label 183 | Hide Unknown Senders 184 | 185 | 186 | cell 187 | PSGroupCell 188 | label 189 | Badge Preferences 190 | footerText 191 | Prevent unread messages from the hidden conversation list from contributing to the Messages app badge count. 192 | 193 | 194 | cell 195 | PSSwitchCell 196 | default 197 | 198 | defaults 199 | com.jacobcxdev.iris 200 | key 201 | shouldHideHiddenUnreadCountFromSBBadge 202 | label 203 | Hide Badges from Hidden Conversations 204 | 205 | 206 | cell 207 | PSGroupCell 208 | footerText 209 | Allow muted conversations to contribute to badge counts. 210 | 211 | 212 | cell 213 | PSSwitchCell 214 | default 215 | 216 | defaults 217 | com.jacobcxdev.iris 218 | key 219 | shouldShowMutedUnreadCountInBadges 220 | label 221 | Show Badges from Muted Conversations 222 | 223 | 224 | cell 225 | PSGroupCell 226 | footerText 227 | Hide the badge from the Iris button inside Messages. 228 | 229 | 230 | cell 231 | PSSwitchCell 232 | default 233 | 234 | defaults 235 | com.jacobcxdev.iris 236 | key 237 | shouldHideButtonBadge 238 | label 239 | Hide Iris Button Badge 240 | 241 | 242 | cell 243 | PSGroupCell 244 | label 245 | Security Preferences 246 | footerText 247 | Require Face ID, Touch ID, or passcode to view the hidden conversation list. 248 | 249 | 250 | cell 251 | PSSwitchCell 252 | default 253 | 254 | defaults 255 | com.jacobcxdev.iris 256 | key 257 | shouldSecureHiddenList 258 | label 259 | Secure Hidden Conversation List 260 | 261 | 262 | cell 263 | PSGroupCell 264 | footerText 265 | Temporarily show the Iris button after having authenticated successfully. The Iris button will hide again when messages enters the background. 266 | 267 | 268 | cell 269 | PSSwitchCell 270 | default 271 | 272 | defaults 273 | com.jacobcxdev.iris 274 | key 275 | shouldShowButtonAfterAuthentication 276 | label 277 | Show Iris Button after Authentication 278 | 279 | 280 | cell 281 | PSGroupCell 282 | footerText 283 | Automatically hide the hidden conversation list when Messages enters the background. 284 | 285 | 286 | cell 287 | PSSwitchCell 288 | default 289 | 290 | defaults 291 | com.jacobcxdev.iris 292 | key 293 | shouldAutoHideHiddenList 294 | label 295 | Auto-Hide Hidden Conversation List 296 | 297 | 298 | cell 299 | PSGroupCell 300 | footerText 301 | Hide the leading swipe actions which are added by Iris. 302 | 303 | 304 | cell 305 | PSSwitchCell 306 | default 307 | 308 | defaults 309 | com.jacobcxdev.iris 310 | key 311 | shouldHideSwipeActions 312 | label 313 | Hide Swipe Actions 314 | 315 | 316 | cell 317 | PSGroupCell 318 | label 319 | Quick Switch Preferences 320 | footerText 321 | Enable quick switching between pinned conversations from the Messages plugin switcher. 322 | 323 | 324 | cell 325 | PSSwitchCell 326 | default 327 | 328 | defaults 329 | com.jacobcxdev.iris 330 | key 331 | isQuickSwitchEnabled 332 | label 333 | Enable Quick Switch 334 | 335 | 336 | cell 337 | PSGroupCell 338 | label 339 | Developer 340 | footerText 341 | Copyright © 2020 JacobCXDev. All rights reserved. 342 | footerAlignment 343 | 1 344 | 345 | 346 | cellClass 347 | JCXTwitterCell 348 | label 349 | Follow me on Twitter 350 | username 351 | jcxdev 352 | avatarURL 353 | https://github.com/jacobcxdev.png 354 | shouldDisplayAvatar 355 | 356 | 357 | 358 | cellClass 359 | JCXPayPalCell 360 | label 361 | Donate to me via PayPal 362 | username 363 | jacobcxdev 364 | shouldDisplayAvatar 365 | 366 | 367 | 368 | cellClass 369 | JCXCashAppCell 370 | label 371 | Donate to me via CashApp 372 | cashTag 373 | £JacobCXDev 374 | shouldDisplayAvatar 375 | 376 | 377 | 378 | cellClass 379 | JCXMailCell 380 | label 381 | Email me for support 382 | emailAddress 383 | jacobcxdev@gmail.com 384 | shouldDisplayAvatar 385 | 386 | 387 | 388 | cellClass 389 | JCXGitHubCell 390 | label 391 | View the source code on GitHub 392 | remote 393 | jacobcxdev/Iris 394 | shouldDisplayAvatar 395 | 396 | 397 | 398 | title 399 | Iris 400 | 401 | 402 | -------------------------------------------------------------------------------- /Preferences/Resources/icon-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Preferences/Resources/icon-large.png -------------------------------------------------------------------------------- /Preferences/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Preferences/Resources/icon.png -------------------------------------------------------------------------------- /Preferences/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Preferences/Resources/icon@2x.png -------------------------------------------------------------------------------- /Preferences/Resources/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobcxdev/Iris/eee8088150cbb1bfe9d48f270e3c3fb9a7371509/Preferences/Resources/icon@3x.png -------------------------------------------------------------------------------- /Preferences/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | IrisPreferences 9 | cell 10 | PSLinkCell 11 | detail 12 | IrisRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | Iris 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Preferences/src: -------------------------------------------------------------------------------- 1 | ../src -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Banner](https://user-images.githubusercontent.com/27970288/86540852-c4728980-beff-11ea-94d3-f3cc5f5d0b5d.png) 2 | 3 | # [Iris](https://en.wikipedia.org/wiki/Iris_(mythology)) 4 | > #### *(/ˈaɪrɪs/; Greek: Ίρις Ancient Greek: [îːris])* 5 | > The personification and goddess of the rainbow and messenger of the gods. 6 | 7 | Put the sparkle back in 'i'Message! 8 | 9 | ## [Preview Video](https://youtu.be/OwSOB6Do9Yk) 10 | Watch [here](https://youtu.be/OwSOB6Do9Yk). 11 | 12 | ## Features 13 | * Swipe right on a conversation to hide/unhide 14 | * Swipe right on a conversation to block/unblock 15 | * Swipe left on a conversation to pin/unpin 16 | * Reorder pinned conversations 17 | * Create conversation tags 18 | * Edit conversation tags 19 | * Reorder conversation tags 20 | * 3D/Haptic Touch on a conversation to tag 21 | * Secure the hidden conversation list with Face ID, Touch ID, or passcode 22 | * Switch between different lists with either the Iris button or activation actions 23 | * View all conversations with unread messages in a separate list 24 | * Automatically hide conversations from unknown senders 25 | * Automatically sync all lists to iCloud 26 | * Quick switch between conversations 27 | * …and more! 28 | 29 | ## Configuration Options 30 | 31 | ### Main Preferences 32 | * Enabled 33 | 34 | ### Default List Preferences 35 | * Default List 36 | * Open with Default List 37 | 38 | ### Activation Preferences 39 | * Show Iris Button 40 | * Toggle with Shake 41 | * Toggle with Volume Buttons 42 | * Toggle with Ringer Switch 43 | 44 | ### Filtering Preferences 45 | * Hide Unknown Senders 46 | 47 | ### Badge Preferences 48 | * Hide Badges from Hidden Conversations 49 | * Show Badges from Muted Conversations 50 | * Hide Iris Button Badge 51 | 52 | ### Security Preferences 53 | * Secure Hidden Conversation List 54 | * Show Iris Button after Authentication 55 | * Auto-Hide Hidden Conversation List 56 | * Hide Swipe Actions 57 | 58 | ### Quick Switch Preferences 59 | * Enable Quick Switch 60 | 61 | ## [Donate](https://paypal.me/jacobcxdev) 62 | If you would like to donate to me, please donate [via PayPal](https://paypal.me/jacobcxdev) — it really helps! 63 | 64 | ## Screenshots 65 | *Tip: If the screenshots are too large, zoom out by pressing `ctrl + -` / `command + -`. Press `ctrl + 0` / `command + 0` to return to the default zoom level.* 66 | ![1-Mockup](https://user-images.githubusercontent.com/27970288/83982004-bf2f1880-a91a-11ea-84a5-c8a86f8c65a1.png) 67 | ![2-Mockup](https://user-images.githubusercontent.com/27970288/83982007-c524f980-a91a-11ea-818f-a6cb6470a69b.png) 68 | ![3-Mockup](https://user-images.githubusercontent.com/27970288/86540817-8aa18300-beff-11ea-91ee-774b7ff841f6.png) 69 | ![4-Mockup](https://user-images.githubusercontent.com/27970288/83982011-c9511700-a91a-11ea-965f-42c89bd05f6a.png) 70 | ![5-Mockup](https://user-images.githubusercontent.com/27970288/86541082-e967fc00-bf01-11ea-9766-0f519d0c008e.png) 71 | ![6-Mockup](https://user-images.githubusercontent.com/27970288/83982015-cce49e00-a91a-11ea-9ba6-8a535a937e92.png) 72 | ![7-Mockup](https://user-images.githubusercontent.com/27970288/83982016-ce15cb00-a91a-11ea-9762-d6f4e4ecb389.png) 73 | ![8-Mockup](https://user-images.githubusercontent.com/27970288/86540822-8d03dd00-beff-11ea-91ef-f490cd309dde.png) 74 | ![9-Mockup](https://user-images.githubusercontent.com/27970288/86540837-942aeb00-beff-11ea-882b-b34cc670b123.png) 75 | ![10-Mockup](https://user-images.githubusercontent.com/27970288/87050640-6e9b2b80-c1f6-11ea-801a-8649091b10a2.png) -------------------------------------------------------------------------------- /layout/DEBIAN/control: -------------------------------------------------------------------------------- 1 | Package: com.jacobcxdev.iris 2 | Name: Iris 3 | Depends: mobilesubstrate, preferenceloader, firmware (>= 13.0), com.jacobcxdev.libjcx (>= 1.1.0), ws.hbang.alderis (>= 1.0) 4 | Conflicts: com.jacobcxdev.idunnou, com.ryant453.groups, com.creaturecoding.covertck 5 | Architecture: iphoneos-arm 6 | Description: Put the sparkle back in 'i'Message! 7 | Maintainer: JacobCXDev 8 | Author: JacobCXDev 9 | Section: Tweaks 10 | Version: 1.1.5 11 | Tag: cydia::commercial, compatible::ios13 12 | Icon: https://chariz.com/cdn/icon/iris/icon@3x.png 13 | Depiction: https://repo.chariz.com/package/com.jacobcxdev.iris/ 14 | -------------------------------------------------------------------------------- /layout/DEBIAN/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Killing imagent" 4 | killall -9 imagent 5 | 6 | echo "Killing tccd" 7 | killall -9 tccd 8 | 9 | echo "Restarting imagent" 10 | launchctl start com.apple.imagent 11 | 12 | echo "Restarting tccd" 13 | launchctl start com.apple.tccd 14 | 15 | exit 0 -------------------------------------------------------------------------------- /layout/DEBIAN/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Killing imagent" 4 | killall -9 imagent 5 | 6 | echo "Killing tccd" 7 | killall -9 tccd 8 | 9 | exit 0 -------------------------------------------------------------------------------- /src/Objective-C/Categories/NSString+Compatibility.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSString (Compatibility) 4 | - (NSString *)compatibilityString; 5 | - (NSString *)stringByReplacingCurlyWithStraight; 6 | @end -------------------------------------------------------------------------------- /src/Objective-C/Categories/NSString+Compatibility.m: -------------------------------------------------------------------------------- 1 | #import "NSString+Compatibility.h" 2 | 3 | @implementation NSString (Compatibility) 4 | - (NSString *)compatibilityString { 5 | NSString *string = [self copy]; 6 | string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 7 | string = [string stringByReplacingCurlyWithStraight]; 8 | return string; 9 | } 10 | - (NSString *)stringByReplacingCurlyWithStraight { 11 | NSString *string = [self copy]; 12 | string = [string stringByReplacingOccurrencesOfString:@"“" withString:@"\""]; 13 | string = [string stringByReplacingOccurrencesOfString:@"”" withString:@"\""]; 14 | string = [string stringByReplacingOccurrencesOfString:@"‘" withString:@"'"]; 15 | string = [string stringByReplacingOccurrencesOfString:@"’" withString:@"'"]; 16 | return string; 17 | } 18 | @end -------------------------------------------------------------------------------- /src/Objective-C/Categories/UIKit+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIKit+Private.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 19/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface _UIAlertControllerTextFieldViewController : UICollectionViewController 12 | @property (readonly) NSArray *textFields; 13 | - (NSInteger)numberOfTextFields; 14 | @end 15 | 16 | @interface UIAlertController () { 17 | _UIAlertControllerTextFieldViewController *_textFieldViewController; 18 | } 19 | @property (nonatomic, strong, readwrite) UIViewController *contentViewController; 20 | @end 21 | 22 | @interface UICollectionViewLayout () 23 | @property (nonatomic, readwrite) CGFloat minimumLineSpacing; 24 | @property (nonatomic, readwrite) CGSize estimatedItemSize; 25 | @end -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagCreationAlertCollectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IrisTagCreationAlertCollectionViewController.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 21/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "../Categories/UIKit+Private.h" 12 | #import "Iris-Swift.h" 13 | 14 | @interface IrisTagCreationAlertCollectionViewController : _UIAlertControllerTextFieldViewController 15 | @property (nonatomic, retain) IrisFlagTagButtonCollectionControlModel * _Nonnull flagTagButtonCollectionControlModel; 16 | @property (nonatomic, retain) IrisConversationTag * _Nullable originalTag; 17 | @property (nonatomic, retain) IrisButtonModel * _Nullable selectedButtonModel; 18 | @property (nonatomic, retain) NSArray * _Nullable tags; 19 | + (instancetype _Nonnull)controllerWithTags:(NSArray * _Nonnull)tags; 20 | - (instancetype _Nonnull)initWithTags:(NSArray * _Nonnull)tags; 21 | - (void)didSelectButton:(IrisButtonModel * _Nonnull)buttonModel; 22 | - (IrisConversationTag * _Nullable)selectedTag; 23 | - (void)setupControlModel; 24 | @end 25 | -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagCreationAlertCollectionViewController.x: -------------------------------------------------------------------------------- 1 | // 2 | // IrisTagCreationAlertCollectionViewController.x 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 21/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import "IrisTagCreationAlertCollectionViewController.h" 10 | #import "../Categories/NSString+Compatibility.h" 11 | 12 | @interface IrisTagCreationAlertCollectionViewController () 13 | @property (nonatomic, retain) UIWindow * _Nullable colourPickerWindow; 14 | @end 15 | 16 | %subclass IrisTagCreationAlertCollectionViewController : _UIAlertControllerTextFieldViewController 17 | %property (nonatomic, retain) UIWindow *colourPickerWindow; 18 | %property (nonatomic, retain) IrisFlagTagButtonCollectionControlModel *flagTagButtonCollectionControlModel; 19 | %property (nonatomic, retain) IrisConversationTag *originalTag; 20 | %property (nonatomic, retain) IrisButtonModel *selectedButtonModel; 21 | %property (nonatomic, retain) NSArray *tags; 22 | %new 23 | + (instancetype)controllerWithTags:(NSArray * _Nonnull)tags { 24 | return [[self alloc] initWithTags:tags]; 25 | } 26 | %new 27 | - (instancetype)initWithTags:(NSArray * _Nonnull)tags { 28 | if ((self = [self init])) { 29 | self.tags = tags; 30 | [self setupControlModel]; 31 | } 32 | return self; 33 | } 34 | - (instancetype)initWithCoder:(NSCoder *)coder { 35 | self = %orig; 36 | return self; 37 | } 38 | - (void)viewDidLoad { 39 | %orig; 40 | [self.collectionView registerClass:[IrisFlagTagButtonCollectionControlCell class] forCellWithReuseIdentifier:@"IrisFlagTagButtonCollectionControlCell"]; 41 | self.collectionView.scrollEnabled = false; 42 | self.collectionView.backgroundColor = nil; 43 | self.collectionViewLayout.minimumLineSpacing = 7; 44 | } 45 | - (NSInteger)numberOfTextFields { 46 | return %orig + 1; 47 | } 48 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 49 | if (indexPath.section == 0 && indexPath.row == 0) { 50 | IrisFlagTagButtonCollectionControlCell *cell = (IrisFlagTagButtonCollectionControlCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"IrisFlagTagButtonCollectionControlCell" forIndexPath:indexPath]; 51 | [cell initPostDequeueWithControlModel:self.flagTagButtonCollectionControlModel]; 52 | return cell; 53 | } 54 | return indexPath.section == 0 ? %orig(collectionView, [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section]) : %orig; 55 | } 56 | %new 57 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 58 | return indexPath.section == 0 && indexPath.row == 0 ? CGSizeMake(self.collectionViewLayout.estimatedItemSize.width, 30) : self.collectionViewLayout.estimatedItemSize; 59 | } 60 | %new 61 | - (void)setupControlModel { 62 | SEL action = @selector(didSelectButton:); 63 | NSMutableArray *buttonModels = [NSMutableArray new]; 64 | for (IrisConversationTag *tag in self.tags) { 65 | IrisFlagTagButtonModel *buttonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Tagged conversationTag:tag]; 66 | [buttonModels addObject:buttonModel]; 67 | } 68 | IrisButtonModel *customButtonModel = [[IrisButtonModel alloc] initWithImage:[UIImage systemImageNamed:@"plus.circle.fill"] tintColour:self.originalTag ? self.originalTag.colour : [UIColor systemBlueColor] isHighlighted:false isSelected:self.originalTag selectable:true badgeCount:0 badgeHidden:true alpha:1 tag:1 target:self action:action]; 69 | [buttonModels addObject:customButtonModel]; 70 | for (IrisButtonModel *buttonModel in buttonModels) { 71 | buttonModel.target = self; 72 | buttonModel.action = action; 73 | } 74 | self.flagTagButtonCollectionControlModel = [[IrisFlagTagButtonCollectionControlModel alloc] initWithButtonModels:buttonModels]; 75 | [self.collectionView performBatchUpdates:^{ 76 | [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; 77 | } completion:nil]; 78 | } 79 | %new 80 | - (IrisConversationTag * _Nullable)selectedTag { 81 | NSUInteger idx = [self.flagTagButtonCollectionControlModel.buttonModels indexOfObjectPassingTest:^BOOL(IrisButtonModel *obj, NSUInteger idx, BOOL *stop) { 82 | return obj.isSelected == true; 83 | }]; 84 | IrisConversationTag *tag = [IrisConversationTag tagWithUUID:[NSUUID UUID] name:self.originalTag ? self.originalTag.name : @"Other" colour:[UIColor systemBlueColor]]; 85 | if (idx != NSNotFound) { 86 | IrisButtonModel *buttonModel = self.flagTagButtonCollectionControlModel.buttonModels[idx]; 87 | if ([buttonModel isKindOfClass:[IrisFlagTagButtonModel class]] && ((IrisFlagTagButtonModel *)buttonModel).conversationTag) { 88 | tag.name = ((IrisFlagTagButtonModel *)buttonModel).conversationTag.name; 89 | tag.colour = ((IrisFlagTagButtonModel *)buttonModel).conversationTag.colour; 90 | } else { 91 | tag.colour = buttonModel.tintColour; 92 | } 93 | } 94 | NSString *name = [((UITextField *)[self.textFields firstObject]).text compatibilityString]; 95 | if (![name isEqualToString:@""]) { 96 | tag.name = name; 97 | } 98 | return tag; 99 | } 100 | %new 101 | - (void)didSelectButton:(IrisButtonModel * _Nonnull)buttonModel { 102 | self.selectedButtonModel = buttonModel; 103 | if (self.textFields.count > 0) { 104 | ((UITextField *)self.textFields[0]).placeholder = self.originalTag.name ?: [buttonModel isKindOfClass:[IrisFlagTagButtonModel class]] && ((IrisFlagTagButtonModel *)buttonModel).conversationTag ? ((IrisFlagTagButtonModel *)buttonModel).conversationTag.name : @"Other"; 105 | } 106 | if (buttonModel.tag == 1 && UIApplication.sharedApplication.connectedScenes.count > 0) { 107 | UIWindowScene *windowScene = nil; 108 | for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) { 109 | if ([scene isKindOfClass:[UIWindowScene class]]) { 110 | windowScene = (UIWindowScene *)scene; 111 | } 112 | } 113 | if (windowScene) { 114 | UIViewController *viewController = [UIViewController new]; 115 | self.colourPickerWindow = [[UIWindow alloc] initWithWindowScene:windowScene]; 116 | self.colourPickerWindow.rootViewController = viewController; 117 | self.colourPickerWindow.windowLevel = UIWindowLevelAlert + 1000; 118 | [self.colourPickerWindow makeKeyAndVisible]; 119 | 120 | HBColorPickerConfiguration *configuration = [[HBColorPickerConfiguration alloc] initWithColor:buttonModel.tintColour]; 121 | HBColorPickerViewController *colourPicker = [HBColorPickerViewController new]; 122 | colourPicker.configuration = configuration; 123 | colourPicker.delegate = self; 124 | [viewController presentViewController:colourPicker animated:true completion:nil]; 125 | } 126 | } 127 | } 128 | %new 129 | - (void)colorPicker:(HBColorPickerViewController * _Nonnull)colorPicker didSelectColor:(UIColor * _Nonnull)color { 130 | [colorPicker dismissViewControllerAnimated:true completion:^{ 131 | self.colourPickerWindow.hidden = true; 132 | self.colourPickerWindow = nil; 133 | }]; 134 | self.selectedButtonModel.tintColour = color; 135 | for (IrisFlagTagButtonCollectionControlCell *cell in self.collectionView.visibleCells) { 136 | if ([cell isKindOfClass:[IrisFlagTagButtonCollectionControlCell class]]) { 137 | [(IrisFlagTagButtonCollectionControlCell *)cell updateControlWithAnimated:true]; 138 | } 139 | } 140 | } 141 | %new 142 | - (void)colorPickerDidCancel:(HBColorPickerViewController * _Nonnull)colorPicker { 143 | [colorPicker dismissViewControllerAnimated:true completion:^{ 144 | self.colourPickerWindow.hidden = true; 145 | self.colourPickerWindow = nil; 146 | }]; 147 | } 148 | %end -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagCreationAlertController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IrisTagCreationAlertController.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 19/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IrisTagCreationAlertCollectionViewController.h" 11 | #import "Iris-Swift.h" 12 | 13 | @interface IrisTagCreationAlertController : UIAlertController 14 | @property (nonatomic, retain) IrisConversationTag * _Nullable originalTag; 15 | @property (nonatomic, readonly) IrisConversationTag * _Nullable selectedTag; 16 | @end -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagCreationAlertController.x: -------------------------------------------------------------------------------- 1 | // 2 | // IrisTagCreationAlertController.x 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 19/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import "IrisTagCreationAlertController.h" 10 | 11 | @implementation IrisTagCreationAlertController 12 | - (instancetype _Nonnull)init { 13 | if (self = [super init]) { 14 | NSArray *tags = @[ 15 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Red" colour:[UIColor systemRedColor]], 16 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Orange" colour:[UIColor systemOrangeColor]], 17 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Yellow" colour:[UIColor systemYellowColor]], 18 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Green" colour:[UIColor systemGreenColor]], 19 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Blue" colour:[UIColor systemBlueColor]], 20 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Purple" colour:[UIColor systemPurpleColor]], 21 | // [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Indigo" colour:[UIColor systemIndigoColor]], 22 | // [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Pink" colour:[UIColor systemPinkColor]], 23 | // [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Teal" colour:[UIColor systemTealColor]], 24 | [IrisConversationTag tagWithUUID:[NSUUID UUID] name:@"Grey" colour:[UIColor systemGrayColor]] 25 | ]; 26 | [self setValue:[%c(IrisTagCreationAlertCollectionViewController) controllerWithTags:tags] forKey:@"_textFieldViewController"]; 27 | } 28 | return self; 29 | } 30 | - (IrisConversationTag * _Nullable)originalTag { 31 | return ((IrisTagCreationAlertCollectionViewController *)[self valueForKey:@"_textFieldViewController"]).originalTag; 32 | } 33 | - (void)setOriginalTag:(IrisConversationTag * _Nullable)originalTag { 34 | ((IrisTagCreationAlertCollectionViewController *)[self valueForKey:@"_textFieldViewController"]).originalTag = originalTag; 35 | [((IrisTagCreationAlertCollectionViewController *)[self valueForKey:@"_textFieldViewController"]) setupControlModel]; 36 | } 37 | - (IrisConversationTag * _Nullable)selectedTag { 38 | return ((IrisTagCreationAlertCollectionViewController *)[self valueForKey:@"_textFieldViewController"]).selectedTag; 39 | } 40 | @end -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagListTableViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "../Model/IrisConversationTag.h" 3 | 4 | @interface IrisTagListTableViewController : UITableViewController 5 | @property (nonatomic, retain) NSMutableArray * _Nonnull list; 6 | @property (nonatomic, retain) NSArray * _Nullable defaultList; 7 | @property (nonatomic, retain) NSString * _Nullable navBarTitle; 8 | @property (nonatomic, copy) void (^ _Nonnull saveHandler)(NSMutableArray * _Nonnull, bool isBeingDismissed); 9 | + (instancetype _Nonnull)controllerWithTitle:(NSString * _Nullable)title list:(NSMutableArray * _Nonnull)list defaultList:(NSArray * _Nullable)defaultList saveHandler:(void (^ _Nonnull)(NSMutableArray * _Nonnull, bool isBeingDismissed))saveHandler; 10 | - (instancetype _Nonnull)initWithTitle:(NSString * _Nullable)title list:(NSMutableArray * _Nonnull)list defaultList:(NSArray * _Nullable)defaultList saveHandler:(void (^ _Nonnull)(NSMutableArray * _Nonnull, bool isBeingDismissed))saveHandler; 11 | - (void)addListEntry; 12 | - (void)done; 13 | - (void)edit; 14 | - (void)editListEntryAtIndexPath:(NSIndexPath * _Nonnull)indexPath; 15 | - (void)removeListEntryAtIndexPath:(NSIndexPath * _Nonnull)indexPath; 16 | - (void)saveList:(bool)isBeingDismissed; 17 | @end -------------------------------------------------------------------------------- /src/Objective-C/Controller/IrisTagListTableViewController.m: -------------------------------------------------------------------------------- 1 | #import "IrisTagListTableViewController.h" 2 | #import 3 | #import "IrisTagCreationAlertController.h" 4 | 5 | @implementation IrisTagListTableViewController 6 | + (instancetype _Nonnull)controllerWithTitle:(NSString * _Nullable)title list:(NSMutableArray * _Nonnull)list defaultList:(NSArray * _Nullable)defaultList saveHandler:(void (^ _Nonnull)(NSMutableArray * _Nonnull, bool isBeingDismissed))saveHandler { 7 | return [[self alloc] initWithTitle:title list:list defaultList:defaultList saveHandler:saveHandler]; 8 | } 9 | - (instancetype _Nonnull)initWithTitle:(NSString * _Nullable)title list:(NSMutableArray * _Nonnull)list defaultList:(NSArray * _Nullable)defaultList saveHandler:(void (^ _Nonnull)(NSMutableArray * _Nonnull, bool isBeingDismissed))saveHandler { 10 | self = [super initWithStyle:UITableViewStyleGrouped]; 11 | _navBarTitle = title; 12 | _list = list; 13 | _defaultList = defaultList; 14 | _saveHandler = saveHandler; 15 | return self; 16 | } 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.navigationItem.title = _navBarTitle; 20 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(edit)]; 21 | if (!_defaultList || _defaultList.count == 0) { 22 | self.navigationItem.rightBarButtonItems = @[ 23 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(resetEntries)], 24 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addListEntry)] 25 | ]; 26 | } else { 27 | self.navigationItem.rightBarButtonItems = @[ 28 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(resetEntries)], 29 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(resetDefaultEntries)], 30 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addListEntry)] 31 | ]; 32 | } 33 | } 34 | - (void)viewDidDisappear:(BOOL)animated { 35 | [super viewDidDisappear:animated]; 36 | [self saveList:true]; 37 | } 38 | - (void)addListEntry { 39 | IrisTagCreationAlertController *alert = [IrisTagCreationAlertController alertControllerWithTitle:@"Create Tag" message:@"\nPlease choose the colour and name of the tag you would like to create." preferredStyle:UIAlertControllerStyleAlert]; 40 | __weak IrisTagCreationAlertController *_alert = alert; 41 | [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { 42 | textField.placeholder = _alert.selectedTag.name; 43 | textField.autocapitalizationType = UITextAutocapitalizationTypeWords; 44 | }]; 45 | UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Create" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 46 | [self->_list addObject:alert.selectedTag]; 47 | [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:self->_list.count - 1 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic]; 48 | [self saveList:false]; 49 | }]; 50 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}]; 51 | [alert addAction:confirmAction]; 52 | [alert addAction:cancelAction]; 53 | alert.preferredAction = confirmAction; 54 | [self presentViewController:alert animated:true completion:nil]; 55 | } 56 | - (void)done { 57 | [self setEditing:false animated:true]; 58 | [self saveList:false]; 59 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(edit)]; 60 | } 61 | - (void)edit { 62 | [self setEditing:true animated:true]; 63 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done)]; 64 | } 65 | - (void)editListEntryAtIndexPath:(NSIndexPath * _Nonnull)indexPath { 66 | IrisTagCreationAlertController *alert = [IrisTagCreationAlertController alertControllerWithTitle:@"Edit Tag" message:@"\nPlease choose the colour and name of the tag you would like to edit." preferredStyle:UIAlertControllerStyleAlert]; 67 | alert.originalTag = _list[indexPath.row]; 68 | [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { 69 | textField.placeholder = _list[indexPath.row].name; 70 | textField.autocapitalizationType = UITextAutocapitalizationTypeWords; 71 | }]; 72 | UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Edit" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 73 | self->_list[indexPath.row].name = alert.selectedTag.name; 74 | self->_list[indexPath.row].colour = alert.selectedTag.colour; 75 | [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 76 | [self saveList:false]; 77 | }]; 78 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}]; 79 | [alert addAction:confirmAction]; 80 | [alert addAction:cancelAction]; 81 | alert.preferredAction = confirmAction; 82 | [self presentViewController:alert animated:true completion:nil]; 83 | } 84 | - (void)removeListEntryAtIndexPath:(NSIndexPath * _Nonnull)indexPath { 85 | [_list removeObjectAtIndex:indexPath.row]; 86 | [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 87 | [self saveList:false]; 88 | } 89 | - (void)resetDefaultEntries { 90 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Reset list to defaults?" message:@"\nNB: This will RESET ALL tags.\n" preferredStyle:UIAlertControllerStyleAlert]; 91 | UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { 92 | [self.tableView beginUpdates]; 93 | for (int idx = 0; idx < self->_list.count; idx++) { 94 | [self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:idx inSection:0]] withRowAnimation:UITableViewRowAnimationRight]; 95 | } 96 | self->_list = [NSMutableArray arrayWithArray:_defaultList]; 97 | for (int idx = 0; idx < self->_list.count; idx++) { 98 | [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:idx inSection:0]] withRowAnimation:UITableViewRowAnimationLeft]; 99 | } 100 | [self.tableView endUpdates]; 101 | [self saveList:false]; 102 | }]; 103 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}]; 104 | [alert addAction:confirmAction]; 105 | [alert addAction:cancelAction]; 106 | alert.preferredAction = confirmAction; 107 | [self presentViewController:alert animated:true completion:nil]; 108 | } 109 | - (void)resetEntries { 110 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Reset list completely?" message:@"\nNB: This will REMOVE ALL tags.\n" preferredStyle:UIAlertControllerStyleAlert]; 111 | UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { 112 | [self.tableView beginUpdates]; 113 | for (int idx = 0; idx < self->_list.count; idx++) { 114 | [self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:idx inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic]; 115 | } 116 | [self->_list removeAllObjects]; 117 | [self.tableView endUpdates]; 118 | [self saveList:false]; 119 | }]; 120 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}]; 121 | [alert addAction:confirmAction]; 122 | [alert addAction:cancelAction]; 123 | alert.preferredAction = confirmAction; 124 | [self presentViewController:alert animated:true completion:nil]; 125 | } 126 | - (void)saveList:(bool)isBeingDismissed { 127 | _saveHandler(_list, isBeingDismissed); 128 | } 129 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 130 | return _list.count; 131 | } 132 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 133 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"entryCell"]; 134 | cell.textLabel.text = _list[indexPath.row].name; 135 | cell.imageView.image = [UIImage systemImageNamed:@"circle.fill"]; 136 | cell.imageView.tintColor = _list[indexPath.row].colour; 137 | return cell; 138 | } 139 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 140 | [tableView deselectRowAtIndexPath:indexPath animated:true]; 141 | [self editListEntryAtIndexPath:indexPath]; 142 | } 143 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 144 | return true; 145 | } 146 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 147 | if (editingStyle == UITableViewCellEditingStyleDelete) { 148 | [self removeListEntryAtIndexPath:indexPath]; 149 | } 150 | } 151 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 152 | return true; 153 | } 154 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { 155 | IrisConversationTag *mobileTag = _list[sourceIndexPath.row]; 156 | [tableView beginUpdates]; 157 | [_list removeObjectAtIndex:sourceIndexPath.row]; 158 | [_list insertObject:mobileTag atIndex:destinationIndexPath.row]; 159 | [tableView moveRowAtIndexPath:sourceIndexPath toIndexPath:destinationIndexPath]; 160 | [tableView endUpdates]; 161 | [self saveList:false]; 162 | } 163 | @end -------------------------------------------------------------------------------- /src/Objective-C/Globals.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | // Static Variables 4 | 5 | static NSString *defaultFlagKey = @"com.jacobcxdev.iris.defaultFlag"; 6 | static NSString *defaultTagUUIDKey = @"com.jacobcxdev.iris.defaultTagUUID"; 7 | static NSString *tagsArrayKey = @"com.jacobcxdev.iris.tagsArray"; 8 | static NSString *userDefaultsDidUpdateNotificationName = @"com.jacobcxdev.iris.userDefaults.didUpdate"; 9 | 10 | // Static Functions 11 | 12 | NSMutableArray *generateButtonModelsWithTags(NSMutableArray *tagsArray, bool includeHiddenButtonModel, bool includeEditButtonModel); -------------------------------------------------------------------------------- /src/Objective-C/Globals.m: -------------------------------------------------------------------------------- 1 | #import "Globals.h" 2 | 3 | // Conditional Imports 4 | 5 | #ifdef IS_PREFS 6 | #import "IrisPreferences-Swift.h" 7 | #else 8 | #import "Iris-Swift.h" 9 | #endif 10 | 11 | // Static Functions 12 | 13 | NSMutableArray *generateButtonModelsWithTags(NSMutableArray *tagsArray, bool includeHiddenButtonModel, bool includeEditButtonModel) { 14 | NSMutableArray *buttonModels = [NSMutableArray new]; 15 | IrisFlagTagButtonModel *shownButtonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Shown conversationTag:nil]; 16 | [buttonModels addObject:shownButtonModel]; 17 | if (includeHiddenButtonModel) { 18 | IrisFlagTagButtonModel *hiddenButtonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Hidden conversationTag:nil]; 19 | [buttonModels addObject:hiddenButtonModel]; 20 | } 21 | IrisFlagTagButtonModel *unreadButtonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Unread conversationTag:nil]; 22 | [buttonModels addObject:unreadButtonModel]; 23 | for (IrisConversationTag *tag in tagsArray) { 24 | IrisFlagTagButtonModel *buttonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Tagged conversationTag:tag]; 25 | [buttonModels addObject:buttonModel]; 26 | } 27 | IrisFlagTagButtonModel *untaggedButtonModel = [[IrisFlagTagButtonModel alloc] initWithConversationFlag:Tagged conversationTag:nil]; 28 | [buttonModels addObject:untaggedButtonModel]; 29 | if (includeEditButtonModel) { 30 | IrisButtonModel *editButtonModel = [[IrisButtonModel alloc] initWithImage:[UIImage systemImageNamed:@"ellipsis.circle"] tintColour:[UIColor systemBlueColor] isHighlighted:false isSelected:false selectable:false badgeCount:0 badgeHidden:true alpha:1 tag:1 target:nil action:nil]; 31 | [buttonModels addObject:editButtonModel]; 32 | } 33 | return buttonModels; 34 | } -------------------------------------------------------------------------------- /src/Objective-C/Iris-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Iris-Bridging-Header.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 02/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import "Model/IrisConversationFlag.h" 10 | #import "Model/IrisConversationTag.h" 11 | #import "Categories/UIKit+Private.h" 12 | -------------------------------------------------------------------------------- /src/Objective-C/Model/IrisConversationFlag.h: -------------------------------------------------------------------------------- 1 | // 2 | // IrisConversationFlag.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 02/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_OPTIONS(NSUInteger, IrisConversationFlag) { 12 | Shown = 1 << 0, 13 | Hidden = 1 << 1, 14 | Tagged = 1 << 2, 15 | Muted = 1 << 3, 16 | Unread = 1 << 4 17 | }; 18 | -------------------------------------------------------------------------------- /src/Objective-C/Model/IrisConversationTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // IrisConversationTag.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 05/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface IrisConversationTag : NSObject 12 | @property (nonatomic, readonly, copy) NSUUID * _Nonnull uuid; 13 | @property (nonatomic, retain) NSString * _Nonnull name; 14 | @property (nonatomic, strong) UIColor * _Nonnull colour; 15 | @property (nonatomic) NSUInteger unreadCount; 16 | + (instancetype _Nonnull)tagWithUUID:(NSUUID * _Nonnull)uuid name:(NSString * _Nonnull)name colour:(UIColor * _Nonnull)colour; 17 | - (instancetype _Nonnull)initWithUUID:(NSUUID * _Nonnull)uuid name:(NSString * _Nonnull)name colour:(UIColor * _Nonnull)colour; 18 | @end -------------------------------------------------------------------------------- /src/Objective-C/Model/IrisConversationTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // IrisConversationTag.m 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 05/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import "IrisConversationTag.h" 10 | 11 | @interface IrisConversationTag () 12 | @property (nonatomic, readwrite, copy) NSUUID * _Nonnull uuid; 13 | @end 14 | 15 | @implementation IrisConversationTag 16 | + (BOOL)supportsSecureCoding { 17 | return true; 18 | } 19 | + (instancetype _Nonnull)tagWithUUID:(NSUUID * _Nonnull)uuid name:(NSString * _Nonnull)name colour:(UIColor * _Nonnull)colour { 20 | return [[self alloc] initWithUUID:uuid name:name colour:colour]; 21 | } 22 | - (instancetype _Nonnull)initWithUUID:(NSUUID * _Nonnull)uuid name:(NSString * _Nonnull)name colour:(UIColor * _Nonnull)colour { 23 | self = [super init]; 24 | self.uuid = uuid; 25 | self.name = name; 26 | self.colour = colour; 27 | _unreadCount = 0; 28 | return self; 29 | } 30 | - (instancetype)initWithCoder:(NSCoder *)coder { 31 | NSUUID *uuid = [coder decodeObjectForKey:@"uuid"]; 32 | NSString *name = [coder decodeObjectForKey:@"name"]; 33 | UIColor *colour = [coder decodeObjectForKey:@"colour"]; 34 | return [self initWithUUID:uuid name:name colour:colour]; 35 | } 36 | - (void)encodeWithCoder:(NSCoder *)coder { 37 | [coder encodeObject:_uuid forKey:@"uuid"]; 38 | [coder encodeObject:_name forKey:@"name"]; 39 | [coder encodeObject:_colour forKey:@"colour"]; 40 | } 41 | @end -------------------------------------------------------------------------------- /src/Objective-C/Tweak/Tweak.h: -------------------------------------------------------------------------------- 1 | // 2 | // Tweak.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 05/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Iris-Swift.h" 11 | 12 | // Messages Interfaces 13 | 14 | @interface _UIAction : NSObject 15 | + (instancetype)actionWithTitle:(NSString *)title image:(UIImage *)image style:(long long)style handler:(UIActionHandler)handler; 16 | @end 17 | 18 | @interface IMChat : NSObject 19 | @property (nonatomic, strong, readwrite) NSString *displayName; 20 | - (BOOL)hasKnownParticipants; 21 | @end 22 | 23 | @interface IMChatRegistry : NSObject 24 | - (IMChat *)existingChatWithGUID:(id)guid; 25 | @end 26 | 27 | @interface CNContact : NSObject 28 | @property (readonly) NSArray *handles; 29 | @end 30 | 31 | @interface CNUIPRLikenessLookup : NSObject 32 | - (id)photoFutureForContactFuture:(id)contactFuture scheduler:(id)scheduler; 33 | - (id)photoFutureForContactFuture:(id)contactFuture photoFuture:(id)photoFuture allowingFallbackForMeCard:(bool)allowingFallbackForMeCard; 34 | - (id)blessedPhotoObservableWithFuture:(id)photoFuture contact:(CNContact *)contact workScheduler:(id)workScheduler; 35 | @end 36 | 37 | @interface CKEntity : NSObject 38 | @property (nonatomic, strong, readwrite) CNContact *cnContact; 39 | @end 40 | 41 | @interface CKConversation : NSObject 42 | @property (nonatomic, strong, readwrite) IMChat *chat; 43 | @property (nonatomic, readonly) NSString *name; 44 | @property (nonatomic, readwrite) NSString *displayName; 45 | @property (nonatomic, copy, readwrite) NSString *previewText; 46 | @property (nonatomic, strong, readwrite) NSNumber *businessConversation; 47 | @property (nonatomic, readonly) NSString *groupID; 48 | @property (nonatomic, readonly) BOOL hasDisplayName; 49 | @property (nonatomic, readonly) BOOL hasUnreadMessages; 50 | @property (nonatomic, readonly) NSUInteger unreadCount; 51 | @property (nonatomic, readonly) CKEntity *recipient; 52 | @property (nonatomic, readonly) NSUInteger recipientCount; 53 | @property (nonatomic, readwrite, getter=isShown) BOOL shown; 54 | @property (nonatomic, readwrite, getter=isHidden) BOOL hidden; 55 | @property (nonatomic, readwrite, getter=isTagged) BOOL tagged; 56 | @property (nonatomic, readwrite, getter=isPinned) BOOL pinned; 57 | @property (nonatomic, readonly, getter=isMuted) BOOL muted; 58 | @property (nonatomic, readonly) BOOL shouldHide; 59 | @property (nonatomic, readwrite) IrisConversationTag *tag; 60 | + (BOOL)pinnedConversationsEnabled; 61 | - (NSInteger)compareBySequenceNumberAndDateDescending:(CKConversation *)conversation; 62 | - (NSArray *)orderedContactsWithMaxCount:(NSUInteger)maxCount keysToFetch:(NSArray *)keysToFetch; 63 | - (NSInteger)pinnedIndex; 64 | - (void)setMutedUntilDate:(NSDate *)date; 65 | - (BOOL)tagMatchesTag:(IrisConversationTag *)tag; 66 | - (void)unmute; 67 | @end 68 | 69 | @interface CKConversationList : NSObject 70 | @property (nonatomic, retain) NSMutableArray *filteredConversations; 71 | @property (nonatomic) bool updating; 72 | + (instancetype)sharedConversationList; 73 | - (CKConversation *)_conversationForChat:(IMChat *)chat; 74 | - (void)_setConversations:(NSArray *)conversations forFilterMode:(NSUInteger)filterMode; 75 | - (NSMutableArray *)conversations; 76 | - (NSMutableArray *)conversationsForFlag:(IrisConversationFlag)flag tag:(IrisConversationTag *)tag updateUnreadCount:(BOOL)updateUnreadCount; 77 | - (NSMutableArray *)pinnedConversationsForFlag:(IrisConversationFlag)flag tag:(IrisConversationTag *)tag; 78 | - (void)updateConversationListsAndSortIfEnabled; 79 | @end 80 | 81 | @interface CKConversationListStandardCell : UITableViewCell { 82 | UIImageView *_unreadIndicatorImageView; 83 | } 84 | @property (nonatomic, strong, readwrite) CKConversation *conversation; 85 | @end 86 | 87 | @interface CKTranscriptPreviewController : NSObject 88 | @property (nonatomic, strong, readwrite) CKConversation *conversation; 89 | @end 90 | 91 | @interface CKUIBehavior : NSObject 92 | @property (nonatomic, readonly) UIFont *browserCellFont; 93 | @property (nonatomic, readonly) UIImage *unreadImage; 94 | @property (nonatomic, readonly) UIImage *readDNDImage; 95 | @property (nonatomic, readonly) UIImage *unreadDNDImage; 96 | @property (nonatomic, readonly) UIImage *readPinnedImage; 97 | @property (nonatomic, readonly) UIImage *unreadPinnedImage; 98 | + (instancetype)sharedBehaviors; 99 | @end 100 | 101 | @interface CKMessagesController : UIViewController 102 | - (NSMutableArray *)actionsForTranscriptPreviewController:(CKTranscriptPreviewController *)previewController; 103 | - (BOOL)resumeToConversation:(CKConversation *)conversation; 104 | - (void)showConversation:(CKConversation *)conversation animate:(BOOL)animate userInitiated:(BOOL)userInitiated; 105 | - (void)showConversationList:(BOOL)clearChatControllers; 106 | @end 107 | 108 | @interface CKConversationListController : UITableViewController 109 | @property (nonatomic, copy, readwrite) NSArray *frozenConversations; 110 | @property (nonatomic, weak, readwrite) CKMessagesController *messagesController; 111 | - (void)_chatUnreadCountDidChange:(NSNotification *)notification; 112 | - (void)_conversationListDidChange:(NSNotification *)notification; 113 | - (void)_updateConversationListsAndSortIfEnabled; 114 | - (void)_updateFilteredConversationLists; 115 | - (void)_updateNonPlaceholderConverationLists; 116 | - (void)_switchFlag:(IrisConversationFlag)flag tag:(IrisConversationTag *)tag; 117 | - (NSArray *)activeConversations; 118 | - (CKConversationList *)conversationList; 119 | - (void)didTapMenuButton:(IrisButtonModel *)buttonModel; 120 | - (void)setButtonHidden:(bool)hidden; 121 | - (void)switchFlag:(IrisConversationFlag)flag tag:(IrisConversationTag *)tag fromMenuButton:(BOOL)fromMenuButton; 122 | - (void)updateConversationList; 123 | @end 124 | 125 | @interface CNContactToggleBlockCallerAction : NSObject 126 | @property (nonatomic, readonly) BOOL isBlocked; 127 | - (void)block; 128 | - (void)unblock; 129 | - (instancetype)initWithContact:(CNContact *)contact; 130 | @end 131 | 132 | @interface CKAvatarNavigationBar : UINavigationBar 133 | @end 134 | 135 | @interface CKBrowserSwitcherFooterView : UIView 136 | - (instancetype)initWithFrame:(CGRect)frame toggleBordersOnInterfaceStyle:(BOOL)toggleBordersOnInterfaceStyle; 137 | - (UICollectionView *)collectionView; 138 | - (void)reloadData; 139 | - (void)selectPluginAtIndexPath:(NSIndexPath *)indexPath; 140 | @end 141 | 142 | @interface CKBrowserSwitcherFooterAccessoryCell : UICollectionViewCell 143 | + (NSString *)reuseIdentifier; 144 | + (id)supplementryViewKind; 145 | @end 146 | 147 | @interface CKAppStripLayoutAttributes : UICollectionViewLayoutAttributes 148 | @property (nonatomic, readwrite) NSInteger appStripSize; 149 | @property (nonatomic, readwrite) BOOL showsBorder; 150 | @end 151 | 152 | @interface CKAppStripLayout : UICollectionViewLayout 153 | @property (nonatomic, readwrite) NSUInteger layoutMode; 154 | - (NSMutableArray *)_attributesForLayoutMode:(NSUInteger)layoutMode; 155 | - (NSMutableArray *)_currentAttributes; 156 | - (NSInteger)_itemCount; 157 | - (NSInteger)_favoritesCount; 158 | - (NSMutableArray *)_generateAttributesForSpec:(void *)spec; 159 | - (NSMutableArray *)_generateSupplementryAttributesForSpec:(void *)spec minified:(BOOL)minified; 160 | - (NSInteger)_recentsCount; 161 | - (CKAppStripLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath; 162 | - (CKAppStripLayoutAttributes *)layoutAttributesForInteractivelyMovingItemAtIndexPath:(NSIndexPath *)indexPath withTargetPosition:(CGPoint)position; 163 | - (CKAppStripLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:(NSIndexPath *)indexPath; 164 | - (CKAppStripLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)indexPath; 165 | @end 166 | 167 | @interface CKBrowserSwitcherFooterViewDataSource 168 | - (id)switcherView:(CKBrowserSwitcherFooterView *)switcherView modelAtIndexPath:(NSIndexPath *)indexPath type:(NSInteger *)type; 169 | - (NSIndexPath *)switcherView:(CKBrowserSwitcherFooterView *)switcherView indexPathOfModelWithIdentifier:(NSString *)identifier; 170 | @end 171 | 172 | @interface CKAppManagerViewController : UIViewController 173 | @end 174 | 175 | @interface CKBalloonPluginManager : NSObject 176 | @property (nonatomic, readonly) BOOL isAppStoreEnabled; 177 | + (CKBalloonPluginManager *)sharedInstance; 178 | - (NSMutableDictionary *)_decodeIndexPathMap:(NSMutableDictionary *)indexPathMap; 179 | @end 180 | 181 | @interface CNAvatarView : UIView 182 | @property (nonatomic, readwrite) BOOL asynchronousRendering; 183 | @property (nonatomic, readwrite) BOOL bypassActionValidation; 184 | @property (nonatomic, readwrite) BOOL showsContactOnTap; 185 | @property (nonatomic, weak, readwrite) UIViewController *presentingViewController; 186 | @property (nonatomic, copy, readwrite) NSArray *actionCategories; 187 | @property (nonatomic, strong, readwrite) CNContact *contact; 188 | @property (nonatomic, strong, readwrite) NSArray *contacts; 189 | @property (nonatomic, copy, readwrite) NSString *name; 190 | @property (nonatomic, readwrite) NSUInteger style; 191 | @property (nonatomic, copy, readwrite) UIImageView *imageView; 192 | @end 193 | 194 | @protocol CNAvatarViewDelegate 195 | - (UIViewController *)presentingViewControllerForAvatarView:(CNAvatarView *)avatarView; 196 | @end 197 | 198 | @interface CKAvatarView : CNAvatarView 199 | @property (nonatomic, weak, readwrite) NSObject *delegate; 200 | @end 201 | 202 | @interface CKSpringBoardActionManager : NSObject 203 | - (void)updateShortcutItems; 204 | @end 205 | 206 | @interface SMSApplication : UIApplication 207 | - (void)applicationWillTerminate; 208 | @end 209 | 210 | // IMAgent Interfaces 211 | 212 | @interface IMDBadgeUtilities : NSObject 213 | - (void)updateBadgeForUnreadCountChangeIfNeeded:(NSInteger)count; 214 | @end 215 | 216 | // TCCd Interfaces 217 | 218 | @interface TCCDService : NSObject 219 | @property (retain, nonatomic) NSString *name; 220 | - (void)setDefaultAllowedIdentifiersList:(NSArray *)list; 221 | @end 222 | 223 | // SpringBoard Interfaces 224 | 225 | @interface SpringBoard : NSObject 226 | - (BOOL)_handlePhysicalButtonEvent:(UIPressesEvent *)event; 227 | - (void)_ringerChanged:(void *)event; 228 | @end -------------------------------------------------------------------------------- /src/Objective-C/View/IrisAvatarCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "../Tweak/Tweak.h" 3 | 4 | @interface IrisAvatarCollectionViewCell : UICollectionViewCell 5 | @property (nonatomic, readonly) CKAvatarView * _Nullable avatarView; 6 | @property (nonatomic, readonly) CKConversation * _Nullable conversation; 7 | @property (nonatomic, readonly) UIStackView * _Nullable stackView; 8 | @property (nonatomic, copy) void (^ _Nullable tapHandler)(CKConversation * _Nullable); 9 | - (void)initPostDequeueWithConversation:(CKConversation * _Nullable)conversation tapHandler:(void (^ _Nullable)(CKConversation * _Nullable))tapHandler; 10 | - (void)setupAvatarView; 11 | - (void)setupStackView; 12 | - (UIImageView * _Nullable)browserImage; 13 | @end -------------------------------------------------------------------------------- /src/Objective-C/View/IrisAvatarCollectionViewCell.x: -------------------------------------------------------------------------------- 1 | #import "IrisAvatarCollectionViewCell.h" 2 | 3 | @implementation IrisAvatarCollectionViewCell 4 | - (void)initPostDequeueWithConversation:(CKConversation * _Nullable)conversation tapHandler:(void (^ _Nullable)(CKConversation * _Nullable))tapHandler { 5 | _conversation = conversation; 6 | _tapHandler = tapHandler; 7 | if (conversation) { 8 | if (!_stackView) { 9 | [self setupStackView]; 10 | } 11 | if (!_avatarView) { 12 | [self setupAvatarView]; 13 | } 14 | if (conversation.recipientCount == 1) { 15 | if (conversation.recipient.cnContact) { 16 | _avatarView.contact = conversation.recipient.cnContact; 17 | } 18 | _avatarView.actionCategories = @[@"audio-call", @"video-call", @"instant-message", @"mail", @"add-to-contacts"]; 19 | } else { 20 | _avatarView.contacts = [conversation orderedContactsWithMaxCount:conversation.recipientCount keysToFetch:@[]]; 21 | _avatarView.actionCategories = @[@"instant-message"]; 22 | } 23 | _avatarView.name = conversation.hasDisplayName ? conversation.displayName : conversation.name; 24 | _avatarView.style = [conversation.businessConversation unsignedIntegerValue]; 25 | [self setNeedsLayout]; 26 | } else { 27 | [_avatarView removeFromSuperview]; 28 | _avatarView = nil; 29 | } 30 | } 31 | - (void)setupAvatarView { 32 | _avatarView = [[%c(CKAvatarView) alloc] initWithFrame:CGRectMake(0, 0, 38, 38)]; 33 | _avatarView.asynchronousRendering = true; 34 | _avatarView.bypassActionValidation = true; 35 | _avatarView.showsContactOnTap = false; 36 | _avatarView.delegate = self; 37 | _avatarView.translatesAutoresizingMaskIntoConstraints = false; 38 | [_avatarView.widthAnchor constraintEqualToAnchor:_avatarView.heightAnchor].active = true; 39 | [_stackView addArrangedSubview:_avatarView]; 40 | [_avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapOnAvatarView:)]]; 41 | } 42 | - (void)setupStackView { 43 | _stackView = [[UIStackView alloc] initWithFrame:CGRectMake(0, 0, 52, 38)]; 44 | _stackView.alignment = UIStackViewAlignmentCenter; 45 | _stackView.axis = UILayoutConstraintAxisVertical; 46 | _stackView.distribution = UIStackViewDistributionFill; 47 | [self.contentView addSubview:_stackView]; 48 | _stackView.translatesAutoresizingMaskIntoConstraints = false; 49 | [_stackView.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:5].active = true; 50 | [_stackView.bottomAnchor constraintEqualToAnchor:self.contentView.bottomAnchor constant:-5].active = true; 51 | [_stackView.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor].active = true; 52 | [_stackView.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor].active = true; 53 | } 54 | - (void)prepareForReuse { 55 | [super prepareForReuse]; 56 | _conversation = nil; 57 | _tapHandler = nil; 58 | _avatarView.contact = nil; 59 | _avatarView.contacts = nil; 60 | _avatarView.name = nil; 61 | _avatarView.actionCategories = nil; 62 | _avatarView.style = 0; 63 | } 64 | - (void)didTapOnAvatarView:(id)sender { 65 | _tapHandler(_conversation); 66 | } 67 | - (UIImageView * _Nullable)browserImage { 68 | return _avatarView.imageView; 69 | } 70 | - (UIViewController *)presentingViewControllerForAvatarView:(CNAvatarView *)avatarView { 71 | return [avatarView isKindOfClass:%c(CKAvatarView)] ? ((CKAvatarView *)avatarView).presentingViewController : nil; 72 | } 73 | @end -------------------------------------------------------------------------------- /src/Objective-C/View/IrisRoundedBorderLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // IrisRoundedBorderLayer.h 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 06/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface IrisRoundedBorderLayer : CALayer 12 | + (instancetype _Nonnull)roundedBorderLayerForView:(UIView * _Nonnull)view colour:(CGColorRef _Nonnull)colour; 13 | @end -------------------------------------------------------------------------------- /src/Objective-C/View/IrisRoundedBorderLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // IrisRoundedBorderLayer.m 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 06/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | #import "IrisRoundedBorderLayer.h" 10 | 11 | @implementation IrisRoundedBorderLayer 12 | + (instancetype _Nonnull)roundedBorderLayerForView:(UIView * _Nonnull)view colour:(CGColorRef _Nonnull)colour { 13 | IrisRoundedBorderLayer *layer = [super layer]; 14 | layer.frame = CGRectMake(-3, -3, view.frame.size.width + 6, view.frame.size.height + 6); 15 | layer.borderColor = colour; 16 | layer.borderWidth = 2; 17 | layer.cornerRadius = layer.frame.size.height / 2; 18 | return layer; 19 | } 20 | @end -------------------------------------------------------------------------------- /src/Swift/Extensions/UIView+allSubviews.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+allSubviews.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 26/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension UIView { 12 | 13 | // MARK: - Computed Properties 14 | @objc var allSubviews: [UIView] { 15 | allSubviews_() 16 | } 17 | 18 | // MARK: - Private Funcs 19 | private func allSubviews_() -> [UIView] { 20 | var allSubviews = [UIView]() 21 | for subview in subviews { 22 | allSubviews.append(subview) 23 | allSubviews += subview.allSubviews_() 24 | } 25 | return allSubviews 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Swift/Model/IrisButtonModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisButtonModel.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 23/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisButtonModel: NSObject { 12 | 13 | // MARK: - Properties 14 | @objc public var image: UIImage? 15 | @objc public var tintColour: UIColor 16 | @objc public var isHighlighted: Bool 17 | @objc public var isSelected: Bool 18 | @objc public var selectable: Bool 19 | @objc public var badgeCount: UInt 20 | @objc public var badgeHidden: Bool 21 | @objc public var alpha: CGFloat 22 | @objc public var tag: Int 23 | @objc public var target: AnyObject? 24 | @objc public var action: Selector? 25 | 26 | // MARK: - Init Methods 27 | @objc public init(image: UIImage? = nil, tintColour: UIColor = .systemBlue, isHighlighted: Bool = false, isSelected: Bool = false, selectable: Bool = true, badgeCount: UInt = 0, badgeHidden: Bool = true, alpha: CGFloat = 1, tag: Int = 0, target: AnyObject? = nil, action: Selector? = nil) { 28 | self.image = image 29 | self.tintColour = tintColour 30 | self.isHighlighted = isHighlighted 31 | self.isSelected = isSelected 32 | self.selectable = selectable 33 | self.badgeCount = badgeCount 34 | self.badgeHidden = badgeHidden 35 | self.alpha = alpha 36 | self.tag = tag 37 | self.target = target 38 | self.action = action 39 | super.init() 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/Swift/Model/IrisFlagTagButtonCollectionControlModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonCollectionControlModel.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 24/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | @objc public class IrisFlagTagButtonCollectionControlModel: NSObject { 12 | 13 | // MARK: - Properties 14 | @objc public var buttonModels: [IrisButtonModel] 15 | 16 | // MARK: - Init Methods 17 | @objc public init(buttonModels: [IrisButtonModel] = [IrisButtonModel]()) { 18 | self.buttonModels = buttonModels 19 | super.init() 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Swift/Model/IrisFlagTagButtonModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonModel.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 23/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisFlagTagButtonModel: IrisButtonModel { 12 | 13 | // MARK: - Static Properties 14 | static let shownImage = UIImage(systemName: "person.crop.circle") 15 | static let shownTintColour: UIColor = .systemBlue 16 | static let hiddenImage = UIImage(systemName: "questionmark.circle") 17 | static let hiddenTintColour: UIColor = .systemBlue 18 | static let unreadImage = UIImage(systemName: "message.circle") 19 | static let unreadTintColour: UIColor = .systemBlue 20 | static let untaggedImage = UIImage(systemName: "minus.circle") 21 | static let untaggedTintColour: UIColor = .systemBlue 22 | static let defaultImage = UIImage(systemName: "circle.fill") 23 | static let defaultTintColour: UIColor = .systemBlue 24 | 25 | // MARK: - Properties 26 | @objc public var name = "" 27 | 28 | // MARK: - Observed Properties 29 | @objc public var conversationFlag: IrisConversationFlag { 30 | didSet { 31 | updateFlagTag() 32 | } 33 | } 34 | @objc public var conversationTag: IrisConversationTag? { 35 | didSet { 36 | updateFlagTag() 37 | } 38 | } 39 | 40 | // MARK: - Init Methods 41 | @objc public init(conversationFlag: IrisConversationFlag = .Shown, conversationTag: IrisConversationTag? = nil) { 42 | self.conversationFlag = conversationFlag 43 | self.conversationTag = conversationTag 44 | super.init() 45 | updateFlagTag() 46 | } 47 | 48 | // MARK: - Funcs 49 | @objc public func updateBadgeCount(shownUnreadCount: UInt, hiddenUnreadCount: UInt, shouldSecureHiddenList: Bool) { 50 | switch conversationFlag { 51 | case .Hidden: 52 | badgeCount = hiddenUnreadCount 53 | case .Unread: 54 | badgeCount = shouldSecureHiddenList ? shownUnreadCount : shownUnreadCount + hiddenUnreadCount 55 | case .Tagged: 56 | if let tag = conversationTag { 57 | badgeCount = tag.unreadCount 58 | } 59 | default: 60 | badgeCount = shownUnreadCount 61 | } 62 | } 63 | 64 | public func updateFlagTag() { 65 | switch conversationFlag { 66 | case .Shown: 67 | name = "Shown" 68 | image = IrisFlagTagButtonModel.shownImage 69 | tintColour = conversationTag?.colour ?? IrisFlagTagButtonModel.shownTintColour 70 | case .Hidden: 71 | name = "Hidden" 72 | image = IrisFlagTagButtonModel.hiddenImage 73 | tintColour = conversationTag?.colour ?? IrisFlagTagButtonModel.hiddenTintColour 74 | case .Unread: 75 | name = "Unread" 76 | image = IrisFlagTagButtonModel.unreadImage 77 | tintColour = conversationTag?.colour ?? IrisFlagTagButtonModel.unreadTintColour 78 | case .Tagged: 79 | name = conversationTag == nil ? "Untagged" : conversationTag?.name ?? "" 80 | image = conversationTag == nil ? IrisFlagTagButtonModel.untaggedImage : IrisFlagTagButtonModel.defaultImage 81 | tintColour = conversationTag?.colour ?? IrisFlagTagButtonModel.untaggedTintColour 82 | default: 83 | name = "" 84 | image = IrisFlagTagButtonModel.defaultImage 85 | tintColour = conversationTag?.colour ?? IrisFlagTagButtonModel.defaultTintColour 86 | } 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/Swift/Protocols/BadgeView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeView.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 25/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol BadgeView where Self: UIView { 12 | 13 | // MARK: - Properties 14 | var badgeLabel: UILabel { get } 15 | var badgeCount: UInt { get set } 16 | var badgeHidden: Bool { get set } 17 | 18 | // MARK: - Funcs 19 | func badgeFrameForRect(rect: CGRect) -> CGRect 20 | func layoutBadge() 21 | func setBadgeHidden(hidden: Bool, animated: Bool) 22 | func setupBadge() 23 | func updateBadge(animated: Bool) 24 | 25 | } 26 | 27 | // MARK: - Default Implementations 28 | extension BadgeView { 29 | 30 | public func badgeFrameForRect(rect: CGRect) -> CGRect { 31 | let height = max(18, badgeLabel.frame.height + 5.0) 32 | let width = max(height, badgeLabel.frame.width + 10.0) 33 | return CGRect(x: rect.width - 5, y: -badgeLabel.frame.height / 2, width: width, height: height); 34 | } 35 | 36 | public func layoutBadge() { 37 | badgeLabel.sizeToFit() 38 | badgeLabel.frame = badgeFrameForRect(rect: frame) 39 | badgeLabel.layer.cornerRadius = badgeLabel.frame.height / 2; 40 | badgeLabel.layer.masksToBounds = true; 41 | } 42 | 43 | public func setBadgeHidden(hidden: Bool, animated: Bool) { 44 | if badgeHidden == hidden { 45 | return 46 | } 47 | badgeHidden = hidden 48 | guard badgeCount != 0 else { 49 | return 50 | } 51 | if !hidden { 52 | badgeLabel.isHidden = hidden 53 | } 54 | badgeLabel.layer.removeAllAnimations() 55 | UIView.animate(withDuration: animated ? 0.25 : 0, animations: { 56 | self.badgeLabel.alpha = hidden ? 0 : 1 57 | }) { _ in 58 | self.badgeLabel.isHidden = hidden 59 | } 60 | } 61 | 62 | public func setupBadge() { 63 | badgeLabel.textColor = .white 64 | badgeLabel.backgroundColor = .systemRed 65 | badgeLabel.textAlignment = .center 66 | badgeLabel.font = .preferredFont(forTextStyle: .caption1) 67 | badgeLabel.alpha = 0 68 | badgeLabel.isHidden = badgeHidden 69 | updateBadge(animated: false) 70 | addSubview(badgeLabel) 71 | } 72 | 73 | public func updateBadge(animated: Bool) { 74 | if badgeCount != 0 { 75 | let formatter = NumberFormatter() 76 | formatter.numberStyle = .decimal 77 | badgeLabel.text = formatter.string(from: NSNumber(value: badgeCount)) 78 | } 79 | UIView.animate(withDuration: animated ? 0.25 : 0) { 80 | self.badgeLabel.alpha = self.badgeHidden || self.badgeCount == 0 ? 0 : 1 81 | } 82 | layoutSubviews() 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/Swift/Protocols/IrisMenuButtonDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisMenuButtonDelegate.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 26/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public protocol IrisMenuButtonDelegate: class { 12 | 13 | // MARK: - Funcs 14 | func menuButton(_ menuButton: IrisMenuButton, isExpandedDidUpdate isExpanded: Bool) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/Swift/View/IrisButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisButton.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 24/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisButton: UIButton, BadgeView { 12 | 13 | // MARK: - Enums 14 | enum SizeState: CGFloat { 15 | case normal = 22 16 | case expanded = 30 17 | } 18 | 19 | // MARK: - Properties 20 | var widthConstraint: NSLayoutConstraint! 21 | var heightConstraint: NSLayoutConstraint! 22 | var model: IrisButtonModel? 23 | 24 | // MARK: - BadgeView Properties 25 | public var badgeLabel = UILabel() 26 | public var badgeCount: UInt = 0 27 | public var badgeHidden = true 28 | 29 | // MARK: - Observed Properties 30 | var sizeState: SizeState = .normal { 31 | didSet { 32 | if sizeState != oldValue { 33 | switch sizeState { 34 | case .normal: 35 | widthConstraint.constant = SizeState.normal.rawValue 36 | heightConstraint.constant = SizeState.normal.rawValue 37 | break 38 | case .expanded: 39 | widthConstraint.constant = SizeState.expanded.rawValue 40 | heightConstraint.constant = SizeState.expanded.rawValue 41 | } 42 | layoutIfNeeded() 43 | } 44 | } 45 | } 46 | 47 | // MARK: - Computed Properties 48 | var maxRect: CGRect { 49 | let rect = CGRect(x: 0, y: 0, width: SizeState.expanded.rawValue, height: SizeState.expanded.rawValue) 50 | return rect.union(badgeFrameForRect(rect: rect)) 51 | } 52 | 53 | // MARK: - Init Methods 54 | @objc public init(image: UIImage? = nil, tintColour: UIColor = .systemBlue) { 55 | super.init(frame: CGRect(x: 0, y: 0, width: SizeState.normal.rawValue, height: SizeState.normal.rawValue)) 56 | if let image = image { 57 | setImage(image, for: .normal) 58 | } 59 | tintColor = tintColour 60 | setup() 61 | } 62 | 63 | required init?(coder: NSCoder) { 64 | super.init(coder: coder) 65 | setup() 66 | } 67 | 68 | // MARK: - Private Funcs 69 | private func setup() { 70 | backgroundColor = .secondarySystemFill 71 | translatesAutoresizingMaskIntoConstraints = false 72 | widthConstraint = widthAnchor.constraint(equalToConstant: SizeState.normal.rawValue) 73 | heightConstraint = heightAnchor.constraint(equalToConstant: SizeState.normal.rawValue) 74 | widthConstraint.priority = .init(rawValue: 999) 75 | heightConstraint.priority = .init(rawValue: 999) 76 | widthConstraint.isActive = true 77 | heightConstraint.isActive = true 78 | setupBadge() 79 | } 80 | 81 | // MARK: - Override Funcs 82 | public override func layoutSubviews() { 83 | super.layoutSubviews() 84 | layer.cornerRadius = frame.height / 2 85 | layoutBadge() 86 | } 87 | 88 | // MARK: - Funcs 89 | func setTintColour(tintColour: UIColor, animated: Bool) { 90 | UIView.animate(withDuration: animated ? 0.3 : 0) { 91 | self.tintColor = tintColour 92 | } 93 | } 94 | 95 | func setIsHighlighted(isHighlighted: Bool, animated: Bool) { 96 | self.isHighlighted = isHighlighted 97 | UIView.animate(withDuration: animated ? 0.3 : 0) { 98 | self.sizeState = isHighlighted ? .expanded : .normal 99 | } 100 | } 101 | 102 | func setIsSelected(isSelected: Bool, animated: Bool) { 103 | self.isSelected = isSelected 104 | UIView.animate(withDuration: animated ? 0.3 : 0) { 105 | self.sizeState = isSelected ? .expanded : .normal 106 | } 107 | } 108 | 109 | func setBadgeCount(badgeCount: UInt, animated: Bool) { 110 | self.badgeCount = badgeCount 111 | updateBadge(animated: animated) 112 | } 113 | 114 | func setAlpha(alpha: CGFloat, animated: Bool) { 115 | UIView.animate(withDuration: animated ? 0.3 : 0) { 116 | self.alpha = alpha 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/Swift/View/IrisButtonCollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisButtonCollectionViewCell.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 24/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IrisButtonCollectionViewCell: UICollectionViewCell { 12 | 13 | // MARK: - Private Properties 14 | private let button_ = IrisButton() 15 | 16 | // MARK: - Properties 17 | var button: IrisButton { 18 | button_ 19 | } 20 | 21 | // MARK: - Init Methods 22 | override init(frame: CGRect) { 23 | super.init(frame: frame) 24 | setup() 25 | } 26 | 27 | required init?(coder: NSCoder) { 28 | super.init(coder: coder) 29 | setup() 30 | } 31 | 32 | // MARK: - Private Funcs 33 | private func setup() { 34 | isUserInteractionEnabled = false 35 | addSubview(button) 36 | button.translatesAutoresizingMaskIntoConstraints = false 37 | button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true 38 | button.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true 39 | } 40 | 41 | // MARK: - Override Funcs 42 | override func prepareForReuse() { 43 | super.prepareForReuse() 44 | button.model = nil 45 | updateButton(animated: false) 46 | } 47 | 48 | // MARK: - Funcs 49 | func initPostDequeue(buttonModel: IrisButtonModel) { 50 | button.model = buttonModel 51 | updateButton(animated: false) 52 | } 53 | 54 | func updateButton(animated: Bool) { 55 | if button.image(for: .normal) != button.model?.image ?? nil { 56 | button.setImage(button.model?.image, for: .normal) 57 | } 58 | if button.tintColor != button.model?.tintColour ?? .systemBlue { 59 | button.setTintColour(tintColour: button.model?.tintColour ?? .systemBlue, animated: animated) 60 | } 61 | if button.isHighlighted != button.model?.isHighlighted ?? false { 62 | button.setIsHighlighted(isHighlighted: button.model?.isHighlighted ?? false, animated: animated) 63 | } 64 | if button.isSelected != button.model?.isSelected ?? false { 65 | button.setIsSelected(isSelected: button.model?.isSelected ?? false, animated: animated) 66 | } 67 | if button.badgeCount != button.model?.badgeCount ?? 0 { 68 | button.setBadgeCount(badgeCount: button.model?.badgeCount ?? 0, animated: animated) 69 | } 70 | if button.badgeHidden != button.model?.badgeHidden ?? true { 71 | button.setBadgeHidden(hidden: button.model?.badgeHidden ?? true, animated: animated) 72 | } 73 | if button.alpha != button.model?.alpha ?? 1 { 74 | button.setAlpha(alpha: button.model?.alpha ?? 1, animated: animated) 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/Swift/View/IrisFlagTagButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButton.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 02/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisFlagTagButton: IrisButton { 12 | 13 | // MARK: - Properties 14 | @objc public var conversationFlag: IrisConversationFlag 15 | @objc public var conversationTag: IrisConversationTag? 16 | 17 | // MARK: - Init Methods 18 | @objc public init(flag: IrisConversationFlag = .Shown, tag: IrisConversationTag? = nil) { 19 | conversationFlag = flag 20 | conversationTag = tag 21 | super.init() 22 | } 23 | 24 | required init?(coder: NSCoder) { 25 | conversationFlag = .Shown 26 | conversationTag = nil 27 | super.init(coder: coder) 28 | } 29 | 30 | // MARK: - Funcs 31 | 32 | @objc public func updateBadgeCount(shownUnreadCount: UInt, hiddenUnreadCount: UInt, animated: Bool) { 33 | switch conversationFlag { 34 | case .Hidden: 35 | badgeCount = hiddenUnreadCount 36 | model?.badgeCount = hiddenUnreadCount 37 | case .Tagged: 38 | if let tag = conversationTag { 39 | badgeCount = tag.unreadCount 40 | model?.badgeCount = tag.unreadCount 41 | } 42 | default: 43 | badgeCount = shownUnreadCount 44 | model?.badgeCount = shownUnreadCount 45 | } 46 | updateBadge(animated: animated) 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/Swift/View/IrisFlagTagButtonCollectionControl.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonCollectionControl.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 18/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisFlagTagButtonCollectionControl: UIControl { 12 | 13 | // MARK: - Private Properties 14 | private var collectionView: UICollectionView! 15 | private var itemSize = CGSize(width: 30, height: 30) 16 | private var lastHighlightedButtonModel: IrisButtonModel? 17 | 18 | // MARK: - Properties 19 | var model: IrisFlagTagButtonCollectionControlModel? 20 | 21 | // MARK: - Observed Properties 22 | @objc public var buttonModels = [IrisButtonModel]() { 23 | didSet { 24 | buttonModels.forEach { $0.badgeHidden = true } 25 | } 26 | } 27 | 28 | // MARK: - Computed Properties 29 | @objc public var selectedButtonModel: IrisButtonModel? { 30 | buttonModels.first { $0.isSelected } 31 | } 32 | 33 | // MARK: - Init Methods 34 | @objc public init(buttonModels: [IrisButtonModel], itemSize: CGSize) { 35 | super.init(frame: .zero) 36 | self.buttonModels = buttonModels 37 | self.itemSize = itemSize 38 | buttonModels.forEach { $0.badgeHidden = true } 39 | setup() 40 | selectFirstButton(animated: false) 41 | } 42 | 43 | override init(frame: CGRect) { 44 | super.init(frame: frame) 45 | setup() 46 | } 47 | 48 | required init?(coder: NSCoder) { 49 | super.init(coder: coder) 50 | setup() 51 | } 52 | 53 | // MARK: - Private Funcs 54 | private func setup() { 55 | backgroundColor = .secondarySystemBackground 56 | layer.shadowColor = UIColor.systemFill.cgColor 57 | layer.shadowOpacity = 0 58 | layer.shadowOffset = .zero 59 | 60 | let layout = UICollectionViewFlowLayout() 61 | layout.scrollDirection = .horizontal 62 | layout.minimumLineSpacing = 0 63 | layout.itemSize = itemSize 64 | 65 | collectionView = IrisFlagTagButtonCollectionView(frame: .zero, collectionViewLayout: layout) 66 | collectionView.register(IrisButtonCollectionViewCell.self, forCellWithReuseIdentifier: "IrisButtonCollectionViewCell") 67 | collectionView.register(IrisFlagTagButtonCollectionViewCell.self, forCellWithReuseIdentifier: "IrisFlagTagButtonCollectionViewCell") 68 | collectionView.isUserInteractionEnabled = false 69 | collectionView.isScrollEnabled = false 70 | collectionView.dataSource = self 71 | collectionView.backgroundColor = nil 72 | addSubview(collectionView) 73 | 74 | collectionView.translatesAutoresizingMaskIntoConstraints = false 75 | collectionView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true 76 | collectionView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true 77 | collectionView.topAnchor.constraint(equalTo: topAnchor).isActive = true 78 | collectionView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true 79 | } 80 | 81 | // MARK: - Override Funcs 82 | public override func layoutSubviews() { 83 | super.layoutSubviews() 84 | layer.cornerRadius = frame.height / 2 85 | } 86 | 87 | public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 88 | _ = updateButtonsWithTouch(touch, shouldHighlight: true, shouldSelect: false) 89 | return true 90 | } 91 | 92 | public override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 93 | _ = updateButtonsWithTouch(touch, shouldHighlight: true, shouldSelect: false) 94 | return true 95 | } 96 | 97 | public override func endTracking(_ touch: UITouch?, with event: UIEvent?) { 98 | guard let touch = touch else { 99 | return 100 | } 101 | if !updateButtonsWithTouch(touch, shouldHighlight: false, shouldSelect: true) { 102 | selectLastHighlightedButton(animated: true) 103 | if let buttonModel = lastHighlightedButtonModel, let action = buttonModel.action { 104 | buttonModel.target?.perform(action, with: buttonModel, afterDelay: 0) 105 | } 106 | } 107 | } 108 | 109 | // MARK: - Funcs 110 | func maxButtonRect() -> CGRect { 111 | var x: CGFloat = 0 112 | var y: CGFloat = 0 113 | var width: CGFloat = 0 114 | var height: CGFloat = 0 115 | (collectionView.visibleCells as? [IrisButtonCollectionViewCell])?.map(\.button).forEach { 116 | let rect = $0.maxRect 117 | x = min(x, rect.minX) 118 | y = min(y, rect.minY) 119 | width = max(width, rect.width) 120 | height = max(height, rect.height) 121 | } 122 | return CGRect(x: x, y: y, width: width, height: height) 123 | } 124 | 125 | func selectFirstButton(animated: Bool) { 126 | buttonModels.enumerated().forEach { $1.isSelected = $0 == 0 } 127 | updateButtons(animated: animated) 128 | } 129 | 130 | func selectLastHighlightedButton(animated: Bool) { 131 | buttonModels.forEach { $0.isSelected = $0 == lastHighlightedButtonModel } 132 | updateButtons(animated: animated) 133 | } 134 | 135 | func updateButtonsWithTouch(_ touch: UITouch, shouldHighlight: Bool, shouldSelect: Bool) -> Bool { 136 | var newButtonModel: IrisButtonModel? 137 | let indexPath = collectionView.indexPathForItem(at: touch.location(in: collectionView)) 138 | if let indexPath = indexPath { 139 | newButtonModel = buttonModels[indexPath.row] 140 | } 141 | buttonModels.forEach { 142 | if $0 != newButtonModel { 143 | $0.isHighlighted = false 144 | $0.isSelected = false 145 | } 146 | } 147 | guard let buttonModel = newButtonModel else { 148 | updateButtons(animated: true) 149 | return false 150 | } 151 | if !buttonModel.isHighlighted { 152 | let haptics = UISelectionFeedbackGenerator() 153 | haptics.selectionChanged() 154 | } 155 | buttonModel.isHighlighted = shouldHighlight 156 | buttonModel.isSelected = shouldSelect && buttonModel.selectable 157 | if shouldHighlight { 158 | lastHighlightedButtonModel = buttonModel 159 | } 160 | if shouldSelect { 161 | if let action = buttonModel.action { 162 | buttonModel.target?.perform(action, with: buttonModel, afterDelay: 0) 163 | } 164 | } 165 | updateButtons(animated: true) 166 | return true 167 | } 168 | 169 | @objc public func reloadCollectionView(selectFirstButton shouldSelectFirstButton: Bool, animated: Bool) { 170 | collectionView.performBatchUpdates({ 171 | collectionView.reloadSections(IndexSet(integer: 0)) 172 | }, completion: nil) 173 | if shouldSelectFirstButton { 174 | selectFirstButton(animated: animated) 175 | } 176 | } 177 | 178 | @objc public func updateButtonModels(_ buttonModels: [IrisButtonModel], animated: Bool) { 179 | self.buttonModels = buttonModels 180 | reloadCollectionView(selectFirstButton: !buttonModels.map(\.isSelected).contains(true), animated: animated) 181 | updateButtons(animated: animated) 182 | } 183 | 184 | @objc public func updateButtons(animated: Bool) { 185 | (collectionView.visibleCells as! [IrisButtonCollectionViewCell]).forEach { $0.updateButton(animated: animated) } 186 | } 187 | 188 | @objc public func updateButtonBadges(shownUnreadCount: UInt, hiddenUnreadCount: UInt, shouldSecureHiddenList: Bool, animated: Bool) { 189 | buttonModels.forEach { ($0 as? IrisFlagTagButtonModel)?.updateBadgeCount(shownUnreadCount: shownUnreadCount, hiddenUnreadCount: hiddenUnreadCount, shouldSecureHiddenList: shouldSecureHiddenList) } 190 | updateButtons(animated: true) 191 | } 192 | 193 | } 194 | 195 | // MARK: - UICollectionViewDataSource 196 | extension IrisFlagTagButtonCollectionControl: UICollectionViewDataSource { 197 | 198 | public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 199 | buttonModels.count 200 | } 201 | 202 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 203 | if buttonModels[indexPath.row].isKind(of: IrisFlagTagButtonModel.self) { 204 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "IrisFlagTagButtonCollectionViewCell", for: indexPath) as! IrisFlagTagButtonCollectionViewCell 205 | cell.initPostDequeue(buttonModel: buttonModels[indexPath.row]) 206 | return cell 207 | } 208 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "IrisButtonCollectionViewCell", for: indexPath) as! IrisButtonCollectionViewCell 209 | cell.initPostDequeue(buttonModel: buttonModels[indexPath.row]) 210 | return cell 211 | } 212 | 213 | } 214 | 215 | // MARK: - UICollectionViewDelegateFlowLayout 216 | extension IrisFlagTagButtonCollectionControl: UICollectionViewDelegateFlowLayout { 217 | 218 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { 219 | let width = itemSize.width * CGFloat(collectionView.numberOfItems(inSection: section)) 220 | let inset = (collectionView.contentSize.width - width) / 2 221 | return UIEdgeInsets(top: 0, left: inset, bottom: 0, right: inset) 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /src/Swift/View/IrisFlagTagButtonCollectionControlCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonCollectionControlCell.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 18/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisFlagTagButtonCollectionControlCell: UICollectionViewCell { 12 | 13 | // MARK: - Private Properties 14 | private let control_ = IrisFlagTagButtonCollectionControl() 15 | 16 | // MARK: - Properties 17 | @objc public var control: IrisFlagTagButtonCollectionControl { 18 | control_ 19 | } 20 | 21 | // MARK: - Init Methods 22 | override init(frame: CGRect) { 23 | super.init(frame: frame) 24 | setup() 25 | } 26 | 27 | required init?(coder: NSCoder) { 28 | super.init(coder: coder) 29 | setup() 30 | } 31 | 32 | // MARK: - Private Funcs 33 | private func setup() { 34 | control.backgroundColor = nil 35 | addSubview(control) 36 | control.translatesAutoresizingMaskIntoConstraints = false 37 | control.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true 38 | control.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true 39 | control.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15).isActive = true 40 | control.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: 15).isActive = true 41 | } 42 | 43 | // MARK: - Override Funcs 44 | public override func prepareForReuse() { 45 | super.prepareForReuse() 46 | control.model = nil 47 | updateControl(animated: false) 48 | } 49 | 50 | // MARK: - Funcs 51 | @objc public func initPostDequeue(controlModel: IrisFlagTagButtonCollectionControlModel) { 52 | control.model = controlModel 53 | updateControl(animated: false) 54 | } 55 | 56 | @objc public func updateControl(animated: Bool) { 57 | control.updateButtonModels(control.model?.buttonModels ?? [IrisButtonModel](), animated: animated) 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/Swift/View/IrisFlagTagButtonCollectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonCollectionView.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 18/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IrisFlagTagButtonCollectionView: UICollectionView { 12 | 13 | // MARK: - Override Properties 14 | override var intrinsicContentSize: CGSize { 15 | return contentSize 16 | } 17 | 18 | // MARK: - Init Methods 19 | required override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { 20 | super.init(frame: frame, collectionViewLayout: layout) 21 | setup() 22 | } 23 | 24 | required init?(coder: NSCoder) { 25 | super.init(coder: coder) 26 | setup() 27 | } 28 | 29 | // MARK: - Override Funcs 30 | override func layoutSubviews() { 31 | super.layoutSubviews() 32 | if !__CGSizeEqualToSize(bounds.size, intrinsicContentSize) { 33 | invalidateIntrinsicContentSize() 34 | } 35 | allSubviews.forEach { $0.isUserInteractionEnabled = false } 36 | } 37 | 38 | // MARK: - Funcs 39 | func setup() { 40 | clipsToBounds = false 41 | isUserInteractionEnabled = false 42 | isScrollEnabled = false 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/Swift/View/IrisFlagTagButtonCollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisFlagTagButtonCollectionViewCell.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 23/05/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IrisFlagTagButtonCollectionViewCell: IrisButtonCollectionViewCell { 12 | 13 | // MARK: - Private Properties 14 | private let button_ = IrisFlagTagButton() 15 | 16 | // MARK: - Properties 17 | override var button: IrisFlagTagButton { 18 | button_ 19 | } 20 | 21 | // MARK: - Init Methods 22 | override init(frame: CGRect) { 23 | super.init(frame: frame) 24 | setup() 25 | } 26 | 27 | required init?(coder: NSCoder) { 28 | super.init(coder: coder) 29 | setup() 30 | } 31 | 32 | // MARK: - Private Funcs 33 | private func setup() { 34 | isUserInteractionEnabled = false 35 | addSubview(button) 36 | button.translatesAutoresizingMaskIntoConstraints = false 37 | button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true 38 | button.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true 39 | } 40 | 41 | // MARK: - Override Funcs 42 | override func prepareForReuse() { 43 | super.prepareForReuse() 44 | button.conversationFlag = .Shown 45 | button.conversationTag = nil 46 | button.setImage(nil, for: .normal) 47 | button.tintColor = .systemBlue 48 | } 49 | 50 | override func initPostDequeue(buttonModel: IrisButtonModel) { 51 | button.conversationFlag = (buttonModel as? IrisFlagTagButtonModel)?.conversationFlag ?? .Shown 52 | button.conversationTag = (buttonModel as? IrisFlagTagButtonModel)?.conversationTag 53 | super.initPostDequeue(buttonModel: buttonModel) 54 | } 55 | 56 | override func updateButton(animated: Bool) { 57 | if button.conversationFlag != (button.model as? IrisFlagTagButtonModel)?.conversationFlag || button.conversationTag != (button.model as? IrisFlagTagButtonModel)?.conversationTag { 58 | (button.model as? IrisFlagTagButtonModel)?.updateFlagTag() 59 | } 60 | super.updateButton(animated: animated) 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/Swift/View/IrisMenuButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisMenuButton.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 24/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisMenuButton: UIControl, BadgeView { 12 | 13 | // MARK: - Private Properties 14 | private var collectionView: UICollectionView! 15 | private var itemSize = CGSize(width: 30, height: 30) 16 | private var shadowRadius: CGFloat = 5 17 | private var heightConstraint: NSLayoutConstraint! 18 | private var previousTopButtonModel: IrisButtonModel? 19 | private var unorderedButtonModels = [IrisButtonModel]() 20 | private var pressTimer: Timer? 21 | private var scrollTimer: Timer? 22 | 23 | // MARK: - Weak Properties 24 | @objc public weak var delegate: IrisMenuButtonDelegate? 25 | 26 | // MARK: - Computed Properties 27 | @objc public var selectedButtonModel: IrisButtonModel? { 28 | buttonModels.first { $0.isSelected } 29 | } 30 | 31 | // MARK: - Observed Properties 32 | private var scrollDirection: ScrollDirection = .null { 33 | didSet { 34 | if scrollDirection == oldValue { 35 | return 36 | } 37 | scrollTimer?.invalidate() 38 | if scrollDirection != .null { 39 | scrollTimer = Timer(timeInterval: 0.25, target: self, selector: #selector(scroll), userInfo: nil, repeats: true) 40 | if !animatingHeight { 41 | RunLoop.current.add(scrollTimer!, forMode: .default) 42 | } 43 | } 44 | } 45 | } 46 | private var animatingHeight = false { 47 | didSet { 48 | if isExpanded && scrollTimer != nil { 49 | RunLoop.current.add(scrollTimer!, forMode: .default) 50 | } 51 | } 52 | } 53 | @objc public var buttonModels = [IrisButtonModel]() { 54 | didSet { 55 | buttonModels.forEach { $0.badgeHidden = true } 56 | } 57 | } 58 | @objc public var isExpanded = false { 59 | didSet { 60 | if isExpanded != oldValue { 61 | if isExpanded { 62 | becomeFirstResponder() 63 | let haptics = UIImpactFeedbackGenerator(style: .rigid) 64 | haptics.impactOccurred() 65 | } 66 | guard let sv = self.superview else { 67 | return 68 | } 69 | UIView.animate(withDuration: 0.3, animations: { 70 | self.animatingHeight = true 71 | self.heightConstraint.isActive = !self.isExpanded 72 | sv.layoutIfNeeded() 73 | self.layer.shadowOpacity = self.isExpanded ? 1 : 0 74 | self.collectionView.setContentOffset(.zero, animated: true) 75 | self.setBadgeHidden(hidden: self.isExpanded, animated: true) 76 | self.updateButtons(animated: true) 77 | }) { _ in 78 | self.animatingHeight = false 79 | } 80 | delegate?.menuButton(self, isExpandedDidUpdate: isExpanded) 81 | } 82 | } 83 | } 84 | 85 | // MARK: - BadgeView Properties 86 | public var badgeLabel = UILabel() 87 | public var badgeCount: UInt = 0 88 | public var badgeHidden = false 89 | 90 | // MARK: - Init Methods 91 | @objc public init(buttonModels: [IrisButtonModel], topButtonModel: IrisButtonModel? = nil, itemSize: CGSize) { 92 | super.init(frame: .zero) 93 | self.buttonModels = buttonModels 94 | self.itemSize = itemSize 95 | unorderedButtonModels = buttonModels 96 | if let buttonModel = topButtonModel { 97 | unorderedButtonModels.removeAll { $0 == buttonModel } 98 | unorderedButtonModels.insert(buttonModel, at: 0) 99 | } 100 | unorderedButtonModels.enumerated().forEach { 101 | $1.badgeHidden = true 102 | $1.alpha = $0 == 0 ? 1 : 0 103 | } 104 | setup() 105 | selectFirstButton(animated: false) 106 | } 107 | 108 | public override init(frame: CGRect) { 109 | super.init(frame: frame) 110 | setup() 111 | } 112 | 113 | required init?(coder: NSCoder) { 114 | super.init(coder: coder) 115 | setup() 116 | } 117 | 118 | // MARK: - Private Funcs 119 | private func setup() { 120 | backgroundColor = .secondarySystemBackground 121 | layer.shadowColor = UIColor.systemFill.cgColor 122 | layer.shadowOpacity = 0 123 | layer.shadowOffset = .zero 124 | layer.shadowRadius = shadowRadius 125 | mask = UIView() 126 | mask?.backgroundColor = .black 127 | 128 | translatesAutoresizingMaskIntoConstraints = false 129 | heightConstraint = heightAnchor.constraint(equalToConstant: itemSize.height) 130 | heightConstraint.isActive = true 131 | 132 | let layout = UICollectionViewFlowLayout() 133 | layout.scrollDirection = .vertical 134 | layout.minimumLineSpacing = 0 135 | layout.itemSize = itemSize 136 | 137 | collectionView = IrisMenuCollectionView(frame: .zero, collectionViewLayout: layout) 138 | collectionView.register(IrisButtonCollectionViewCell.self, forCellWithReuseIdentifier: "IrisButtonCollectionViewCell") 139 | collectionView.register(IrisFlagTagButtonCollectionViewCell.self, forCellWithReuseIdentifier: "IrisFlagTagButtonCollectionViewCell") 140 | collectionView.isUserInteractionEnabled = false 141 | collectionView.isScrollEnabled = false 142 | collectionView.dataSource = self 143 | collectionView.backgroundColor = nil 144 | addSubview(collectionView) 145 | 146 | collectionView.translatesAutoresizingMaskIntoConstraints = false 147 | collectionView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true 148 | collectionView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true 149 | collectionView.topAnchor.constraint(equalTo: topAnchor).isActive = true 150 | collectionView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true 151 | 152 | setupBadge() 153 | } 154 | 155 | // MARK: - Override Funcs 156 | public override func didMoveToWindow() { 157 | super.didMoveToWindow() 158 | if let view = window?.rootViewController?.view { 159 | topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor).isActive = true 160 | bottomAnchor.constraint(lessThanOrEqualTo: view.bottomAnchor).isActive = true 161 | } 162 | } 163 | 164 | public override func layoutSubviews() { 165 | super.layoutSubviews() 166 | layer.cornerRadius = frame.width / 2 167 | layoutBadge() 168 | 169 | let rect = maxButtonRect() 170 | mask?.frame.origin.x = rect.minX - shadowRadius * 2 171 | mask?.frame.origin.y = rect.minY - shadowRadius * 2 172 | mask?.frame.size.width = max(frame.width, rect.width) + shadowRadius * 4 173 | mask?.frame.size.height = frame.height - rect.minY + shadowRadius * 4 174 | } 175 | 176 | public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 177 | if isExpanded { 178 | _ = updateButtonsWithTouch(touch, shouldHighlight: true, shouldSelect: false) 179 | } else { 180 | pressTimer?.invalidate() 181 | pressTimer = Timer.scheduledTimer(withTimeInterval: UILongPressGestureRecognizer().minimumPressDuration, repeats: false, block: { _ in 182 | self.isExpanded = true 183 | }) 184 | } 185 | return true 186 | } 187 | 188 | public override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { 189 | if isExpanded { 190 | _ = updateButtonsWithTouch(touch, shouldHighlight: true, shouldSelect: false) 191 | let y = touch.location(in: self).y 192 | if y < frame.minY + itemSize.height { 193 | scrollDirection = .up 194 | } else if y > frame.maxY - itemSize.height { 195 | scrollDirection = .down 196 | } else { 197 | scrollDirection = .null 198 | } 199 | } else { 200 | scrollDirection = .null 201 | } 202 | return true 203 | } 204 | 205 | public override func endTracking(_ touch: UITouch?, with event: UIEvent?) { 206 | guard let touch = touch else { 207 | return 208 | } 209 | if isExpanded { 210 | if !updateButtonsWithTouch(touch, shouldHighlight: false, shouldSelect: true) { 211 | selectFirstButton(animated: true) 212 | } 213 | isExpanded = false 214 | } else { 215 | selectFirstButton(animated: true) 216 | pressTimer?.fire() 217 | pressTimer?.invalidate() 218 | } 219 | scrollDirection = .null 220 | } 221 | 222 | public override func resignFirstResponder() -> Bool { 223 | super.resignFirstResponder() 224 | reloadCollectionView(animated: true) 225 | isExpanded = false 226 | return true 227 | } 228 | 229 | // MARK: - Funcs 230 | func maxButtonRect() -> CGRect { 231 | var x: CGFloat = 0 232 | var y: CGFloat = 0 233 | var width: CGFloat = 0 234 | var height: CGFloat = 0 235 | (collectionView.visibleCells as? [IrisButtonCollectionViewCell])?.map(\.button).forEach { 236 | let rect = $0.maxRect 237 | x = min(x, rect.minX) 238 | y = min(y, rect.minY) 239 | width = max(width, rect.width) 240 | height = max(height, rect.height) 241 | } 242 | return CGRect(x: x, y: y, width: width, height: height) 243 | } 244 | 245 | func selectFirstButton(animated: Bool) { 246 | unorderedButtonModels.enumerated().forEach { $1.isSelected = $0 == 0 } 247 | updateButtons(animated: animated) 248 | } 249 | 250 | func updateButtonsWithTouch(_ touch: UITouch, shouldHighlight: Bool, shouldSelect: Bool) -> Bool { 251 | var newButtonModel: IrisButtonModel? 252 | let indexPath = collectionView.indexPathForItem(at: touch.location(in: collectionView)) 253 | if let indexPath = indexPath { 254 | newButtonModel = unorderedButtonModels[indexPath.row] 255 | } 256 | buttonModels.forEach { 257 | if $0 != newButtonModel { 258 | $0.isHighlighted = false 259 | $0.isSelected = false 260 | } 261 | } 262 | guard let buttonModel = newButtonModel else { 263 | updateButtons(animated: true) 264 | return false 265 | } 266 | if !buttonModel.isHighlighted { 267 | let haptics = UISelectionFeedbackGenerator() 268 | haptics.selectionChanged() 269 | } 270 | buttonModel.isHighlighted = shouldHighlight 271 | buttonModel.isSelected = shouldSelect && buttonModel.selectable 272 | if shouldSelect { 273 | reloadCollectionView(topButtonModel: buttonModel.isSelected ? buttonModel : unorderedButtonModels.first, animated: true) 274 | if let action = buttonModel.action { 275 | buttonModel.target?.perform(action, with: buttonModel, afterDelay: 0) 276 | } 277 | } else { 278 | updateButtons(animated: true) 279 | } 280 | return true 281 | } 282 | 283 | @objc public func reloadCollectionView(topButtonModel buttonModel: IrisButtonModel? = nil, animated: Bool) { 284 | collectionView.performBatchUpdates({ 285 | previousTopButtonModel = unorderedButtonModels.first 286 | unorderedButtonModels = buttonModels 287 | if let buttonModel = buttonModel { 288 | unorderedButtonModels.removeAll { $0 == buttonModel } 289 | unorderedButtonModels.insert(buttonModel, at: 0) 290 | } 291 | collectionView.reloadSections(IndexSet(integer: 0)) 292 | }, completion: nil) 293 | selectFirstButton(animated: animated) 294 | } 295 | 296 | @objc public func revertToPreviousButton() { 297 | reloadCollectionView(topButtonModel: previousTopButtonModel, animated: true) 298 | } 299 | 300 | @objc public func updateButtonModels(_ buttonModels: [IrisButtonModel], topButtonModel: IrisButtonModel? = nil, animated: Bool) { 301 | self.buttonModels = buttonModels 302 | reloadCollectionView(topButtonModel: topButtonModel, animated: animated) 303 | updateButtons(animated: animated) 304 | } 305 | 306 | func updateButtons(animated: Bool) { 307 | unorderedButtonModels.enumerated().forEach { 308 | $1.badgeHidden = !isExpanded 309 | $1.alpha = isExpanded || $0 == 0 ? 1 : 0 310 | } 311 | (collectionView.visibleCells as! [IrisButtonCollectionViewCell]).forEach { $0.updateButton(animated: animated) } 312 | } 313 | 314 | @objc public func updateButtonBadges(shownUnreadCount: UInt, hiddenUnreadCount: UInt, shouldSecureHiddenList: Bool, animated: Bool) { 315 | buttonModels.forEach { ($0 as? IrisFlagTagButtonModel)?.updateBadgeCount(shownUnreadCount: shownUnreadCount, hiddenUnreadCount: hiddenUnreadCount, shouldSecureHiddenList: shouldSecureHiddenList) } 316 | updateButtons(animated: animated) 317 | } 318 | 319 | @objc public func scroll() { 320 | switch scrollDirection { 321 | case .up: 322 | if collectionView.contentOffset.y >= itemSize.height / 2 { 323 | collectionView.setContentOffset(CGPoint(x: collectionView.contentOffset.x, y: collectionView.contentOffset.y - itemSize.height), animated: true) 324 | } 325 | case .down: 326 | if collectionView.contentOffset.y < collectionView.contentSize.height - frame.maxY { 327 | collectionView.setContentOffset(CGPoint(x: collectionView.contentOffset.x, y: collectionView.contentOffset.y + itemSize.height), animated: true) 328 | } 329 | default: 330 | break; 331 | } 332 | } 333 | 334 | @objc public func setBadgeCount(_ badgeCount: UInt, animated: Bool) { 335 | self.badgeCount = badgeCount 336 | updateBadge(animated: animated) 337 | } 338 | 339 | // MARK: - Enums 340 | enum ScrollDirection { 341 | case null, up, down 342 | } 343 | 344 | } 345 | 346 | // MARK: - UICollectionViewDataSource 347 | extension IrisMenuButton: UICollectionViewDataSource { 348 | 349 | public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 350 | unorderedButtonModels.count 351 | } 352 | 353 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 354 | if unorderedButtonModels[indexPath.row].isKind(of: IrisFlagTagButtonModel.self) { 355 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "IrisFlagTagButtonCollectionViewCell", for: indexPath) as! IrisFlagTagButtonCollectionViewCell 356 | cell.initPostDequeue(buttonModel: unorderedButtonModels[indexPath.row]) 357 | return cell 358 | } 359 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "IrisButtonCollectionViewCell", for: indexPath) as! IrisButtonCollectionViewCell 360 | cell.initPostDequeue(buttonModel: unorderedButtonModels[indexPath.row]) 361 | return cell 362 | } 363 | 364 | } 365 | -------------------------------------------------------------------------------- /src/Swift/View/IrisMenuButtonDimmingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisMenuButtonDimmingView.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 26/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public class IrisMenuButtonDimmingView: UIView { 12 | 13 | // MARK: - Weak Properties 14 | @objc public weak var menuButton: IrisMenuButton? 15 | 16 | // MARK: - Init Methods 17 | override init(frame: CGRect) { 18 | super.init(frame: frame) 19 | setup() 20 | } 21 | 22 | required init?(coder: NSCoder) { 23 | super.init(coder: coder) 24 | setup() 25 | } 26 | 27 | // MARK: - Private Funcs 28 | private func setup() { 29 | backgroundColor = .black 30 | alpha = 0 31 | isUserInteractionEnabled = false 32 | translatesAutoresizingMaskIntoConstraints = false 33 | } 34 | 35 | // MARK: - Override Funcs 36 | public override func didMoveToWindow() { 37 | super.didMoveToWindow() 38 | if let view = window?.rootViewController?.view { 39 | topAnchor.constraint(equalTo: view.topAnchor).isActive = true 40 | bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true 41 | leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true 42 | trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true 43 | } 44 | } 45 | 46 | public override func touchesBegan(_ touches: Set, with event: UIEvent?) { 47 | menuButton?.isExpanded = false 48 | } 49 | 50 | } 51 | 52 | // MARK: - IrisMenuButtonDelegate 53 | extension IrisMenuButtonDimmingView: IrisMenuButtonDelegate { 54 | 55 | public func menuButton(_ menuButton: IrisMenuButton, isExpandedDidUpdate isExpanded: Bool) { 56 | isUserInteractionEnabled = isExpanded 57 | UIView.animate(withDuration: 0.3) { 58 | self.alpha = isExpanded ? 0.2 : 0 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/Swift/View/IrisMenuCollectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IrisMenuCollectionView.swift 3 | // Iris 4 | // 5 | // Created by Jacob Clayden on 24/04/2020. 6 | // Copyright © 2020 JacobCXDev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IrisMenuCollectionView: IrisFlagTagButtonCollectionView { 12 | 13 | // MARK: - Private Properties 14 | private var heightConstraint: NSLayoutConstraint! 15 | 16 | // MARK: - Override Funcs 17 | override func setup() { 18 | super.setup() 19 | heightConstraint = heightAnchor.constraint(equalToConstant: 100) 20 | heightConstraint.priority = .init(rawValue: 999) 21 | } 22 | 23 | override func reloadData() { 24 | super.reloadData() 25 | heightConstraint.constant = collectionViewLayout.collectionViewContentSize.height 26 | layoutIfNeeded() 27 | } 28 | 29 | override func reloadSections(_ sections: IndexSet) { 30 | super.reloadSections(sections) 31 | heightConstraint.constant = collectionViewLayout.collectionViewContentSize.height 32 | layoutIfNeeded() 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------