diff --git a/.github/workflows/dart_lint.yml b/.github/workflows/dart_lint.yml index eb5703cd72..3ff87dc680 100644 --- a/.github/workflows/dart_lint.yml +++ b/.github/workflows/dart_lint.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v2 - uses: subosito/flutter-action@v1 with: - flutter-version: '3.0.0' + flutter-version: '3.0.5' channel: "stable" - uses: actions-rs/toolchain@v1 with: diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart index ab58176e50..30e8d2743c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart @@ -28,7 +28,7 @@ class BoardPluginBuilder implements PluginBuilder { class BoardPluginConfig implements PluginConfig { @override - bool get creatable => false; + bool get creatable => true; } class BoardPlugin extends Plugin { diff --git a/frontend/app_flowy/packages/appflowy_board/.gitignore b/frontend/app_flowy/packages/appflowy_board/.gitignore new file mode 100644 index 0000000000..96486fd930 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/frontend/app_flowy/packages/appflowy_board/.metadata b/frontend/app_flowy/packages/appflowy_board/.metadata new file mode 100644 index 0000000000..e7011f64f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: package diff --git a/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md new file mode 100644 index 0000000000..7cf059202f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md @@ -0,0 +1,14 @@ +# 0.0.3 +* Support customize UI +* Update example +* Add AppFlowy style widget + +## 0.0.2 + +* Update documentation + +## 0.0.1 + +* Support drag and drop column +* Support drag and drop column items from one to another + diff --git a/frontend/app_flowy/packages/appflowy_board/LICENSE b/frontend/app_flowy/packages/appflowy_board/LICENSE new file mode 100644 index 0000000000..0ad25db4bd --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/frontend/app_flowy/packages/appflowy_board/README.md b/frontend/app_flowy/packages/appflowy_board/README.md new file mode 100644 index 0000000000..893bc3ed64 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/README.md @@ -0,0 +1,86 @@ +# appflowy_board + +The **appflowy_board** is a package that is used in [AppFlowy](https://github.com/AppFlowy-IO/AppFlowy). For the moment, this package is iterated very fast. + + +**appflowy_board** will be a standard git repository when it becomes stable. +## Getting Started + +

+ +

+ +```dart +@override + void initState() { + final column1 = BoardColumnData(id: "To Do", items: [ + TextItem("Card 1"), + TextItem("Card 2"), + TextItem("Card 3"), + TextItem("Card 4"), + ]); + final column2 = BoardColumnData(id: "In Progress", items: [ + TextItem("Card 5"), + TextItem("Card 6"), + ]); + + final column3 = BoardColumnData(id: "Done", items: []); + + boardDataController.addColumn(column1); + boardDataController.addColumn(column2); + boardDataController.addColumn(column3); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + final config = BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ); + return Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), + child: Board( + dataController: boardDataController, + footBuilder: (context, columnData) { + return AppFlowyColumnFooter( + icon: const Icon(Icons.add, size: 20), + title: const Text('New'), + height: 50, + margin: config.columnItemPadding, + ); + }, + headerBuilder: (context, columnData) { + return AppFlowyColumnHeader( + icon: const Icon(Icons.lightbulb_circle), + title: Text(columnData.id), + addIcon: const Icon(Icons.add, size: 20), + moreIcon: const Icon(Icons.more_horiz, size: 20), + height: 50, + margin: config.columnItemPadding, + ); + }, + cardBuilder: (context, item) { + final textItem = item as TextItem; + return AppFlowyColumnItemCard( + key: ObjectKey(item), + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Text(textItem.s), + ), + ), + ); + }, + columnConstraints: const BoxConstraints.tightFor(width: 240), + config: BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ), + ), + ), + ); + } +``` \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml new file mode 100644 index 0000000000..a5744c1cfb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_board/example/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/.gitignore new file mode 100644 index 0000000000..34802023f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/.gitignore @@ -0,0 +1,49 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +.metadata \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/example/README.md b/frontend/app_flowy/packages/appflowy_board/example/README.md new file mode 100644 index 0000000000..2b3fce4c86 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml new file mode 100644 index 0000000000..61b6c4de17 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore new file mode 100644 index 0000000000..6f568019d3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle new file mode 100644 index 0000000000..4466eba652 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.appflowy.board.example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000000..95bcce0ae3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..07ba21884a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt new file mode 100644 index 0000000000..4cd6f28560 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.appflowy.board.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000000..f74085f3f6 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000..304732f884 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..db77bb4b7b Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..17987b79bb Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..09d4391482 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d5f1c8d34e Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d6372eebd Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000000..06952be745 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000..cb1ef88056 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000000..95bcce0ae3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle new file mode 100644 index 0000000000..83ae220041 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties b/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties new file mode 100644 index 0000000000..94adc3a3f9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties b/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..cc5527d781 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle new file mode 100644 index 0000000000..44e62bcf06 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif b/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif new file mode 100644 index 0000000000..bf1345608e Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore new file mode 100644 index 0000000000..7a7f9873ad --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000000..8d4492f977 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..74374c8530 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,481 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..c87d15a335 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000000..70693e4a8c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..d36b1fab2d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000..dc9ada4725 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000..28c6bf0301 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000..f091b6b0bc Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000..4cde12118d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000..d0ef06e7ed Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000000..dcdc2306c2 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000..c8f9ed8f5c Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000..75b2d164a5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000..c4df70d39d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000000..6a84f41e14 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000..d0e1f58536 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000000..0bedcf2fd4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000000..89c2725b70 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..f2e259c7c9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..f3c28516fb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist new file mode 100644 index 0000000000..907f329fe0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000000..308a2a560b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart new file mode 100644 index 0000000000..c881370e03 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'single_board_list_example.dart'; +import 'multi_board_list_example.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + int _currentIndex = 0; + final _bottomNavigationColor = Colors.blue; + + final List _examples = [ + const MultiBoardListExample(), + const SingleBoardListExample(), + ]; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('AppFlowy Board'), + ), + body: _examples[_currentIndex], + bottomNavigationBar: BottomNavigationBar( + fixedColor: _bottomNavigationColor, + showSelectedLabels: true, + showUnselectedLabels: false, + currentIndex: _currentIndex, + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.grid_on, color: _bottomNavigationColor), + label: "MultiColumn"), + BottomNavigationBarItem( + icon: Icon(Icons.grid_on, color: _bottomNavigationColor), + label: "SingleColumn"), + ], + onTap: (int index) { + setState(() { + _currentIndex = index; + }); + }, + )), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart new file mode 100644 index 0000000000..3edb32c3bf --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart @@ -0,0 +1,152 @@ +import 'package:appflowy_board/appflowy_board.dart'; +import 'package:flutter/material.dart'; + +class MultiBoardListExample extends StatefulWidget { + const MultiBoardListExample({Key? key}) : super(key: key); + + @override + State createState() => _MultiBoardListExampleState(); +} + +class _MultiBoardListExampleState extends State { + final BoardDataController boardDataController = BoardDataController( + onMoveColumn: (fromIndex, toIndex) { + debugPrint('Move column from $fromIndex to $toIndex'); + }, + onMoveColumnItem: (columnId, fromIndex, toIndex) { + debugPrint('Move $columnId:$fromIndex to $columnId:$toIndex'); + }, + onMoveColumnItemToColumn: (fromColumnId, fromIndex, toColumnId, toIndex) { + debugPrint('Move $fromColumnId:$fromIndex to $toColumnId:$toIndex'); + }, + ); + + @override + void initState() { + final column1 = BoardColumnData(id: "To Do", items: [ + TextItem("Card 1"), + TextItem("Card 2"), + RichTextItem(title: "Card 3", subtitle: 'Aug 1, 2020 4:05 PM'), + TextItem("Card 4"), + ]); + final column2 = BoardColumnData(id: "In Progress", items: [ + RichTextItem(title: "Card 5", subtitle: 'Aug 1, 2020 4:05 PM'), + TextItem("Card 6"), + ]); + + final column3 = BoardColumnData(id: "Done", items: []); + + boardDataController.addColumn(column1); + boardDataController.addColumn(column2); + boardDataController.addColumn(column3); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + final config = BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ); + return Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), + child: Board( + dataController: boardDataController, + footBuilder: (context, columnData) { + return AppFlowyColumnFooter( + icon: const Icon(Icons.add, size: 20), + title: const Text('New'), + height: 50, + margin: config.columnItemPadding, + ); + }, + headerBuilder: (context, columnData) { + return AppFlowyColumnHeader( + icon: const Icon(Icons.lightbulb_circle), + title: Text(columnData.id), + addIcon: const Icon(Icons.add, size: 20), + moreIcon: const Icon(Icons.more_horiz, size: 20), + height: 50, + margin: config.columnItemPadding, + ); + }, + cardBuilder: (context, item) { + return AppFlowyColumnItemCard( + key: ObjectKey(item), + child: _buildCard(item), + ); + }, + columnConstraints: const BoxConstraints.tightFor(width: 240), + config: BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ), + ), + ), + ); + } + + Widget _buildCard(ColumnItem item) { + if (item is TextItem) { + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Text(item.s), + ), + ); + } + + if (item is RichTextItem) { + return Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.title, + style: const TextStyle(fontSize: 14), + textAlign: TextAlign.left, + ), + const SizedBox(height: 10), + Text( + item.subtitle, + style: const TextStyle(fontSize: 12, color: Colors.grey), + ) + ], + ), + ); + } + + throw UnimplementedError(); + } +} + +class TextItem extends ColumnItem { + final String s; + + TextItem(this.s); + + @override + String get id => s; +} + +class RichTextItem extends ColumnItem { + final String title; + final String subtitle; + + RichTextItem({required this.title, required this.subtitle}); + + @override + String get id => title; +} + +extension HexColor on Color { + static Color fromHex(String hexString) { + final buffer = StringBuffer(); + if (hexString.length == 6 || hexString.length == 7) buffer.write('ff'); + buffer.write(hexString.replaceFirst('#', '')); + return Color(int.parse(buffer.toString(), radix: 16)); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart new file mode 100644 index 0000000000..655f1439c1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:appflowy_board/appflowy_board.dart'; + +class SingleBoardListExample extends StatefulWidget { + const SingleBoardListExample({Key? key}) : super(key: key); + + @override + State createState() => _SingleBoardListExampleState(); +} + +class _SingleBoardListExampleState extends State { + final BoardDataController boardData = BoardDataController(); + + @override + void initState() { + final column = BoardColumnData(id: "1", items: [ + TextItem("a"), + TextItem("b"), + TextItem("c"), + TextItem("d"), + ]); + + boardData.addColumn(column); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Board( + dataController: boardData, + cardBuilder: (context, item) { + return _RowWidget(item: item as TextItem, key: ObjectKey(item)); + }, + ); + } +} + +class _RowWidget extends StatelessWidget { + final TextItem item; + const _RowWidget({Key? key, required this.item}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + key: ObjectKey(item), + height: 60, + color: Colors.green, + child: Center(child: Text(item.s)), + ); + } +} + +class TextItem extends ColumnItem { + final String s; + + TextItem(this.s); + + @override + String get id => s; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore new file mode 100644 index 0000000000..d3896c9844 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt new file mode 100644 index 0000000000..697a9f905a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.appflowy.board.example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000000..d5bd01648a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..e71a16d23d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..e0f0a47bc0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..2e1de87a7e --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc new file mode 100644 index 0000000000..e7c5c54370 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc new file mode 100644 index 0000000000..0ba8f43096 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h new file mode 100644 index 0000000000..72271d5e41 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore new file mode 100644 index 0000000000..746adbb6b9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000000..cccf817a52 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..c84862c675 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* example.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..fb7259e177 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000..d53ef64377 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..a2ec33f19f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000..3c4935a7ca Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000..ed4cc16421 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000..483be61389 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000..bcbf36df2f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000..9c0a652864 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000..e71a726136 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000..8a31fe2dd3 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000..80e867a4e0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000..e379d4a333 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2022 com.appflowy.board. All rights reserved. diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000..36b0fd9464 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000..dff4f49561 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000..42bcbf4780 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000..dddb8a30c8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist new file mode 100644 index 0000000000..4789daa6a4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000..2722837ec9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements new file mode 100644 index 0000000000..852fa1a472 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml b/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml new file mode 100644 index 0000000000..1a90f3b84a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml @@ -0,0 +1,91 @@ +name: example +description: A new Flutter project. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.17.6 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + appflowy_board: + path: ../ + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart b/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart new file mode 100644 index 0000000000..29cad86982 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart @@ -0,0 +1,7 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. +void main() {} diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png b/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png new file mode 100644 index 0000000000..8aaa46ac1a Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png new file mode 100644 index 0000000000..b749bfef07 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png new file mode 100644 index 0000000000..88cfd48dff Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000000..eb9b4d76e5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000000..d69c56691f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/index.html b/frontend/app_flowy/packages/appflowy_board/example/web/index.html new file mode 100644 index 0000000000..41b3bc336f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/web/index.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + example + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json b/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json new file mode 100644 index 0000000000..096edf8fe4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore new file mode 100644 index 0000000000..d492d0d98c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt new file mode 100644 index 0000000000..c0270746b1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000000..930d2071a3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..8b6d4680af --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..dc139d85a9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..b93c4c30c1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt new file mode 100644 index 0000000000..b9e550fba8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc new file mode 100644 index 0000000000..8949260514 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.appflowy.board" "\0" + VALUE "FileDescription", "example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2022 com.appflowy.board. All rights reserved." "\0" + VALUE "OriginalFilename", "example.exe" "\0" + VALUE "ProductName", "example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp new file mode 100644 index 0000000000..b43b9095ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h new file mode 100644 index 0000000000..6da0652f05 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp new file mode 100644 index 0000000000..bcb57b0e2a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h new file mode 100644 index 0000000000..66a65d1e4a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000..c04e20caf6 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest new file mode 100644 index 0000000000..c977c4a425 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp new file mode 100644 index 0000000000..f5bf9fa0f5 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h new file mode 100644 index 0000000000..3879d54755 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp new file mode 100644 index 0000000000..c10f08dc7d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h new file mode 100644 index 0000000000..17ba431125 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart b/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart new file mode 100644 index 0000000000..fc8f3c662f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart @@ -0,0 +1,6 @@ +library appflowy_board; + +export 'src/widgets/board_column/board_column_data.dart'; +export 'src/widgets/board_data.dart'; +export 'src/widgets/styled_widgets/appflowy_styled_widgets.dart'; +export 'src/widgets/board.dart'; diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart new file mode 100644 index 0000000000..f2c99e057b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart @@ -0,0 +1,409 @@ +import 'dart:collection'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/scheduler.dart'; + +class BoardOverlayEntry { + /// This entry will include the widget built by this builder in the overlay at + /// the entry's position. + /// The builder will be called again after calling [markNeedsBuild] on this entry. + final WidgetBuilder builder; + + /// Whether this entry occludes the entire overlay. + /// + /// If an entry claims to be opaque, then, for efficiency, the overlay will + /// skip building entries below that entry. + bool get opaque => _opaque; + bool _opaque; + + BoardOverlayState? _overlay; + final GlobalKey<_OverlayEntryWidgetState> _key = + GlobalKey<_OverlayEntryWidgetState>(); + + set opaque(bool value) { + if (_opaque == value) return; + + _opaque = value; + assert(_overlay != null); + _overlay!._didChangeEntryOpacity(); + } + + BoardOverlayEntry({ + required this.builder, + bool opaque = false, + }) : _opaque = opaque; + + /// If this method is called while the [SchedulerBinding.schedulerPhase] is + /// [SchedulerPhase.persistentCallbacks], i.e. during the build, layout, or + /// paint phases (see [WidgetsBinding.drawFrame]), then the removal is + /// delayed until the post-frame callbacks phase. Otherwise the removal is done synchronously. + void remove() { + assert(_overlay != null, 'Should only call once'); + final BoardOverlayState overlay = _overlay!; + _overlay = null; + if (SchedulerBinding.instance.schedulerPhase == + SchedulerPhase.persistentCallbacks) { + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + overlay._remove(this); + }); + } else { + overlay._remove(this); + } + } + + /// Cause this entry to rebuild during the next pipeline flush. + /// You need to call this function if the output of [builder] has changed. + void markNeedsBuild() { + _key.currentState?._markNeedsBuild(); + } +} + +/// A [Stack] of entries that can be managed independently. +/// +/// Overlays let independent child widgets "float" visual elements on top of +/// other widgets by inserting them into the overlay's [Stack]. The overlay lets +/// each of these widgets manage their participation in the overlay using +/// [OverlayEntry] objects. +class BoardOverlay extends StatefulWidget { + final List initialEntries; + + const BoardOverlay({ + this.initialEntries = const [], + Key? key, + }) : super(key: key); + + static BoardOverlayState of(BuildContext context, + {Widget? debugRequiredFor}) { + final BoardOverlayState? result = + context.findAncestorStateOfType(); + assert(() { + if (debugRequiredFor != null && result == null) { + final String additional = context.widget != debugRequiredFor + ? '\nThe context from which that widget was searching for an overlay was:\n $context' + : ''; + throw FlutterError('No Overlay widget found.\n' + '${debugRequiredFor.runtimeType} widgets require an Overlay widget ancestor for correct operation.\n' + 'The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n' + 'The specific widget that failed to find an overlay was:\n' + ' $debugRequiredFor' + '$additional'); + } + return true; + }()); + return result!; + } + + @override + BoardOverlayState createState() => BoardOverlayState(); +} + +class BoardOverlayState extends State + with TickerProviderStateMixin { + final List _entries = []; + + @override + void initState() { + super.initState(); + insertAll(widget.initialEntries); + } + + /// Insert the given entry into the overlay. + /// + /// If [above] is non-null, the entry is inserted just above [above]. + /// Otherwise, the entry is inserted on top. + void insert(BoardOverlayEntry entry, {BoardOverlayEntry? above}) { + assert(entry._overlay == null); + assert( + above == null || (above._overlay == this && _entries.contains(above))); + entry._overlay = this; + setState(() { + final int index = + above == null ? _entries.length : _entries.indexOf(above) + 1; + _entries.insert(index, entry); + }); + } + + /// Insert all the entries in the given iterable. + /// + /// If [above] is non-null, the entries are inserted just above [above]. + /// Otherwise, the entries are inserted on top. + void insertAll(Iterable entries, + {BoardOverlayEntry? above}) { + assert( + above == null || (above._overlay == this && _entries.contains(above))); + if (entries.isEmpty) return; + for (BoardOverlayEntry entry in entries) { + assert(entry._overlay == null); + entry._overlay = this; + } + setState(() { + final int index = + above == null ? _entries.length : _entries.indexOf(above) + 1; + _entries.insertAll(index, entries); + }); + } + + void _remove(BoardOverlayEntry entry) { + if (mounted) { + _entries.remove(entry); + setState(() { + /* entry was removed */ + }); + } + } + + void _didChangeEntryOpacity() { + setState(() { + // We use the opacity of the entry in our build function, which means we + // our state has changed. + }); + } + + @override + Widget build(BuildContext context) { + // These lists are filled backwards. For the offstage children that + // does not matter since they aren't rendered, but for the onstage + // children we reverse the list below before adding it to the tree. + final List onstageChildren = []; + final List offstageChildren = []; + bool onstage = true; + for (int i = _entries.length - 1; i >= 0; i -= 1) { + final BoardOverlayEntry entry = _entries[i]; + if (onstage) { + onstageChildren.add(_OverlayEntryWidget(entry)); + if (entry.opaque) onstage = false; + } + } + return _BoardStack( + onstage: Stack( + fit: StackFit.passthrough, + //HanSheng changed it to passthrough so that this widget doesn't change layout constraints + children: onstageChildren.reversed.toList(growable: false), + ), + offstage: offstageChildren, + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty>('entries', _entries)); + } +} + +class _OverlayEntryWidget extends StatefulWidget { + _OverlayEntryWidget(this.entry) : super(key: entry._key); + + final BoardOverlayEntry entry; + + @override + _OverlayEntryWidgetState createState() => _OverlayEntryWidgetState(); +} + +class _OverlayEntryWidgetState extends State<_OverlayEntryWidget> { + @override + Widget build(BuildContext context) { + return widget.entry.builder(context); + } + + void _markNeedsBuild() { + setState(() {}); + } +} + +/// A widget that has one [onstage] child which is visible, and one or more +/// [offstage] widgets which are kept alive, and are built, but are not laid out +/// or painted. +/// +/// The onstage widget must be a Stack. +/// +/// For convenience, it is legal to use [Positioned] widgets around the offstage +/// widgets. +class _BoardStack extends RenderObjectWidget { + final Stack? onstage; + final List offstage; + + const _BoardStack({ + required this.offstage, + this.onstage, + }); + + @override + _BoardStackElement createElement() => _BoardStackElement(this); + + @override + _RenderBoardObject createRenderObject(BuildContext context) => + _RenderBoardObject(); +} + +class _BoardStackElement extends RenderObjectElement { + Element? _onstage; + static final Object _onstageSlot = Object(); + late List _offstage; + final Set _forgottenOffstageChildren = HashSet(); + + _BoardStackElement(_BoardStack widget) + : assert(!debugChildrenHaveDuplicateKeys(widget, widget.offstage)), + super(widget); + + @override + _BoardStack get widget => super.widget as _BoardStack; + + @override + _RenderBoardObject get renderObject => + super.renderObject as _RenderBoardObject; + + @override + void insertRenderObjectChild(RenderBox child, dynamic slot) { + assert(renderObject.debugValidateChild(child)); + if (slot == _onstageSlot) { + assert(child is RenderStack); + renderObject.child = child as RenderStack?; + } else { + assert(slot == null || slot is Element); + renderObject.insert(child, after: slot?.renderObject); + } + } + + @override + void moveRenderObjectChild(RenderBox child, dynamic oldSlot, dynamic slot) { + if (slot == _onstageSlot) { + renderObject.remove(child); + assert(child is RenderStack); + renderObject.child = child as RenderStack?; + } else { + assert(slot == null || slot is Element); + if (renderObject.child == child) { + renderObject.child = null; + renderObject.insert(child, after: slot?.renderObject); + } else { + renderObject.move(child, after: slot?.renderObject); + } + } + } + + @override + void removeRenderObjectChild(RenderBox child, dynamic slot) { + if (renderObject.child == child) { + renderObject.child = null; + } else { + renderObject.remove(child); + } + } + + @override + void visitChildren(ElementVisitor visitor) { + if (_onstage != null) visitor(_onstage!); + for (Element child in _offstage) { + if (!_forgottenOffstageChildren.contains(child)) visitor(child); + } + } + + @override + void debugVisitOnstageChildren(ElementVisitor visitor) { + if (_onstage != null) visitor(_onstage!); + } + + @override + void forgetChild(Element child) { + if (child == _onstage) { + _onstage = null; + } else { + assert(_offstage.contains(child)); + assert(!_forgottenOffstageChildren.contains(child)); + _forgottenOffstageChildren.add(child); + } + super.forgetChild(child); + } + + @override + void mount(Element? parent, dynamic newSlot) { + super.mount(parent, newSlot); + _onstage = updateChild(_onstage, widget.onstage, _onstageSlot); + _offstage = []; + } + + @override + void update(_BoardStack newWidget) { + super.update(newWidget); + assert(widget == newWidget); + _onstage = updateChild(_onstage, widget.onstage, _onstageSlot); + _offstage = updateChildren(_offstage, widget.offstage, + forgottenChildren: _forgottenOffstageChildren); + _forgottenOffstageChildren.clear(); + } +} + +// A render object which lays out and paints one subtree while keeping a list +// of other subtrees alive but not laid out or painted. +// +// The subtree that is laid out and painted must be a [RenderStack]. +// +// This class uses [StackParentData] objects for its parent data so that the +// children of its primary subtree's stack can be moved to this object's list +// of zombie children without changing their parent data objects. +class _RenderBoardObject extends RenderBox + with + RenderObjectWithChildMixin, + RenderProxyBoxMixin, + ContainerRenderObjectMixin { + @override + void setupParentData(RenderObject child) { + if (child.parentData is! StackParentData) { + child.parentData = StackParentData(); + } + } + + @override + void redepthChildren() { + if (child != null) redepthChild(child!); + super.redepthChildren(); + } + + @override + void visitChildren(RenderObjectVisitor visitor) { + if (child != null) visitor(child!); + super.visitChildren(visitor); + } + + @override + List debugDescribeChildren() { + final List children = []; + + if (child != null) children.add(child!.toDiagnosticsNode(name: 'onstage')); + + if (firstChild != null) { + RenderBox child = firstChild!; + + int count = 1; + while (true) { + children.add( + child.toDiagnosticsNode( + name: 'offstage $count', + style: DiagnosticsTreeStyle.offstage, + ), + ); + if (child == lastChild) break; + final StackParentData childParentData = + child.parentData! as StackParentData; + child = childParentData.nextSibling!; + count += 1; + } + } else { + children.add( + DiagnosticsNode.message( + 'no offstage children', + style: DiagnosticsTreeStyle.offstage, + ), + ); + } + return children; + } + + @override + void visitChildrenForSemantics(RenderObjectVisitor visitor) { + if (child != null) visitor(child!); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart new file mode 100644 index 0000000000..b9f766f961 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +// ignore: constant_identifier_names +const DART_LOG = "Dart_LOG"; + +class Log { + // static const enableLog = bool.hasEnvironment(DART_LOG); + // static final shared = Log(); + static const enableLog = true; + + static void info(String? message) { + if (enableLog) { + debugPrint('ℹ️[Info]=> $message'); + } + } + + static void debug(String? message) { + if (enableLog) { + debugPrint('🐛[Debug]=> $message'); + } + } + + static void trace(String? message) { + if (enableLog) { + // debugPrint('❗️[Trace]=> $message'); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart new file mode 100644 index 0000000000..3cd2a331f1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart @@ -0,0 +1,264 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'board_column/board_column.dart'; +import 'board_column/board_column_data.dart'; +import 'board_data.dart'; +import 'reorder_flex/drag_target_inteceptor.dart'; +import 'reorder_flex/reorder_flex.dart'; +import 'reorder_phantom/phantom_controller.dart'; +import '../rendering/board_overlay.dart'; + +class BoardConfig { + final double cornerRadius; + final EdgeInsets columnPadding; + final EdgeInsets columnItemPadding; + final Color columnBackgroundColor; + + const BoardConfig({ + this.cornerRadius = 6.0, + this.columnPadding = const EdgeInsets.symmetric(horizontal: 8), + this.columnItemPadding = const EdgeInsets.symmetric(horizontal: 10), + this.columnBackgroundColor = Colors.transparent, + }); +} + +class Board extends StatelessWidget { + /// The direction to use as the main axis. + final Axis direction = Axis.vertical; + + /// + final Widget? background; + + /// + final BoardColumnCardBuilder cardBuilder; + + /// + final BoardColumnHeaderBuilder? headerBuilder; + + /// + final BoardColumnFooterBuilder? footBuilder; + + /// + final BoardDataController dataController; + + final BoxConstraints columnConstraints; + + /// + final BoardPhantomController phantomController; + + final BoardConfig config; + + Board({ + required this.dataController, + required this.cardBuilder, + this.background, + this.footBuilder, + this.headerBuilder, + this.columnConstraints = const BoxConstraints(maxWidth: 200), + this.config = const BoardConfig(), + Key? key, + }) : phantomController = BoardPhantomController(delegate: dataController), + super(key: key); + + @override + Widget build(BuildContext context) { + return ChangeNotifierProvider.value( + value: dataController, + child: Consumer( + builder: (context, notifier, child) { + return BoardContent( + config: config, + dataController: dataController, + background: background, + delegate: phantomController, + columnConstraints: columnConstraints, + cardBuilder: cardBuilder, + footBuilder: footBuilder, + headerBuilder: headerBuilder, + phantomController: phantomController, + onReorder: dataController.moveColumn, + ); + }, + ), + ); + } +} + +class BoardContent extends StatefulWidget { + final ScrollController? scrollController; + final OnDragStarted? onDragStarted; + final OnReorder onReorder; + final OnDragEnded? onDragEnded; + final BoardDataController dataController; + final Widget? background; + final BoardConfig config; + final ReorderFlexConfig reorderFlexConfig; + final BoxConstraints columnConstraints; + + /// + final BoardColumnCardBuilder cardBuilder; + + /// + final BoardColumnHeaderBuilder? headerBuilder; + + /// + final BoardColumnFooterBuilder? footBuilder; + + final OverlapDragTargetDelegate delegate; + + final BoardPhantomController phantomController; + + const BoardContent({ + required this.config, + required this.onReorder, + required this.delegate, + required this.dataController, + this.onDragStarted, + this.onDragEnded, + this.scrollController, + this.background, + required this.columnConstraints, + required this.cardBuilder, + this.footBuilder, + this.headerBuilder, + required this.phantomController, + Key? key, + }) : reorderFlexConfig = const ReorderFlexConfig(), + super(key: key); + + @override + State createState() => _BoardContentState(); +} + +class _BoardContentState extends State { + final GlobalKey _columnContainerOverlayKey = + GlobalKey(debugLabel: '$BoardContent overlay key'); + late BoardOverlayEntry _overlayEntry; + + @override + void initState() { + _overlayEntry = BoardOverlayEntry( + builder: (BuildContext context) { + final interceptor = OverlappingDragTargetInteceptor( + reorderFlexId: widget.dataController.identifier, + acceptedReorderFlexId: widget.dataController.columnIds, + delegate: widget.delegate, + ); + + final reorderFlex = ReorderFlex( + key: widget.key, + config: widget.reorderFlexConfig, + scrollController: widget.scrollController, + onDragStarted: widget.onDragStarted, + onReorder: widget.onReorder, + onDragEnded: widget.onDragEnded, + dataSource: widget.dataController, + direction: Axis.horizontal, + interceptor: interceptor, + children: _buildColumns(), + ); + + return Stack( + alignment: AlignmentDirectional.topStart, + children: [ + if (widget.background != null) + Container( + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(widget.config.cornerRadius), + ), + child: widget.background, + ), + reorderFlex, + ], + ); + }, + opaque: false, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BoardOverlay( + key: _columnContainerOverlayKey, + initialEntries: [_overlayEntry], + ); + } + + List _buildColumns() { + final List children = + widget.dataController.columnDatas.asMap().entries.map( + (item) { + final columnData = item.value; + final columnIndex = item.key; + + final dataSource = _BoardColumnDataSourceImpl( + columnId: columnData.id, + dataController: widget.dataController, + ); + + return ChangeNotifierProvider.value( + key: ValueKey(columnData.id), + value: widget.dataController.columnController(columnData.id), + child: Consumer( + builder: (context, value, child) { + return ConstrainedBox( + constraints: widget.columnConstraints, + child: BoardColumnWidget( + margin: _marginFromIndex(columnIndex), + itemMargin: widget.config.columnItemPadding, + headerBuilder: widget.headerBuilder, + footBuilder: widget.footBuilder, + cardBuilder: widget.cardBuilder, + dataSource: dataSource, + scrollController: ScrollController(), + phantomController: widget.phantomController, + onReorder: widget.dataController.moveColumnItem, + cornerRadius: widget.config.cornerRadius, + backgroundColor: widget.config.columnBackgroundColor, + ), + ); + }, + ), + ); + }, + ).toList(); + + return children; + } + + EdgeInsets _marginFromIndex(int index) { + if (widget.dataController.columnDatas.isEmpty) { + return widget.config.columnPadding; + } + + if (index == 0) { + return EdgeInsets.only(right: widget.config.columnPadding.right); + } + + if (index == widget.dataController.columnDatas.length - 1) { + return EdgeInsets.only(left: widget.config.columnPadding.left); + } + + return widget.config.columnPadding; + } +} + +class _BoardColumnDataSourceImpl extends BoardColumnDataDataSource { + String columnId; + final BoardDataController dataController; + + _BoardColumnDataSourceImpl({ + required this.columnId, + required this.dataController, + }); + + @override + BoardColumnData get columnData => + dataController.columnController(columnId).columnData; + + @override + List get acceptedColumnIds => dataController.columnIds; +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart new file mode 100644 index 0000000000..d8981096e3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart @@ -0,0 +1,208 @@ +import 'dart:collection'; + +import 'package:flutter/material.dart'; +import '../../rendering/board_overlay.dart'; +import '../../utils/log.dart'; +import '../reorder_phantom/phantom_controller.dart'; +import '../reorder_flex/reorder_flex.dart'; +import '../reorder_flex/drag_target_inteceptor.dart'; +import 'board_column_data.dart'; + +typedef OnColumnDragStarted = void Function(int index); + +typedef OnColumnDragEnded = void Function(String listId); + +typedef OnColumnReorder = void Function( + String listId, + int fromIndex, + int toIndex, +); + +typedef OnColumnDeleted = void Function(String listId, int deletedIndex); + +typedef OnColumnInserted = void Function(String listId, int insertedIndex); + +typedef BoardColumnCardBuilder = Widget Function( + BuildContext context, + ColumnItem item, +); + +typedef BoardColumnHeaderBuilder = Widget Function( + BuildContext context, + BoardColumnData columnData, +); + +typedef BoardColumnFooterBuilder = Widget Function( + BuildContext context, + BoardColumnData columnData, +); + +abstract class BoardColumnDataDataSource extends ReoderFlextDataSource { + BoardColumnData get columnData; + + List get acceptedColumnIds; + + @override + String get identifier => columnData.id; + + @override + UnmodifiableListView get items => columnData.items; + + void debugPrint() { + String msg = '[$BoardColumnDataDataSource] $columnData data: '; + for (var element in items) { + msg = '$msg$element,'; + } + + Log.debug(msg); + } +} + +/// [BoardColumnWidget] represents the column of the Board. +/// +class BoardColumnWidget extends StatefulWidget { + final BoardColumnDataDataSource dataSource; + final ScrollController? scrollController; + final ReorderFlexConfig config; + + final OnColumnDragStarted? onDragStarted; + final OnColumnReorder onReorder; + final OnColumnDragEnded? onDragEnded; + + final BoardPhantomController phantomController; + + String get columnId => dataSource.columnData.id; + + final BoardColumnCardBuilder cardBuilder; + + final BoardColumnHeaderBuilder? headerBuilder; + + final BoardColumnFooterBuilder? footBuilder; + + final EdgeInsets margin; + + final EdgeInsets itemMargin; + + final double cornerRadius; + + final Color backgroundColor; + + const BoardColumnWidget({ + Key? key, + this.headerBuilder, + this.footBuilder, + required this.cardBuilder, + required this.onReorder, + required this.dataSource, + required this.phantomController, + this.onDragStarted, + this.scrollController, + this.onDragEnded, + this.margin = EdgeInsets.zero, + this.itemMargin = EdgeInsets.zero, + this.cornerRadius = 0.0, + this.backgroundColor = Colors.transparent, + }) : config = const ReorderFlexConfig(), + super(key: key); + + @override + State createState() => _BoardColumnWidgetState(); +} + +class _BoardColumnWidgetState extends State { + final GlobalKey _columnOverlayKey = + GlobalKey(debugLabel: '$BoardColumnWidget overlay key'); + + late BoardOverlayEntry _overlayEntry; + + @override + void initState() { + _overlayEntry = BoardOverlayEntry( + builder: (BuildContext context) { + final children = widget.dataSource.columnData.items + .map((item) => _buildWidget(context, item)) + .toList(); + + final header = + widget.headerBuilder?.call(context, widget.dataSource.columnData); + + final footer = + widget.footBuilder?.call(context, widget.dataSource.columnData); + + final interceptor = CrossReorderFlexDragTargetInterceptor( + reorderFlexId: widget.columnId, + delegate: widget.phantomController, + acceptedReorderFlexIds: widget.dataSource.acceptedColumnIds, + draggableTargetBuilder: PhantomDraggableBuilder(), + ); + + final reorderFlex = ReorderFlex( + key: widget.key, + scrollController: widget.scrollController, + config: widget.config, + onDragStarted: (index) { + widget.phantomController.columnStartDragging(widget.columnId); + widget.onDragStarted?.call(index); + }, + onReorder: ((fromIndex, toIndex) { + if (widget.phantomController.isFromColumn(widget.columnId)) { + widget.onReorder(widget.columnId, fromIndex, toIndex); + widget.phantomController.transformIndex(fromIndex, toIndex); + } + }), + onDragEnded: () { + widget.phantomController.columnEndDragging(widget.columnId); + widget.onDragEnded?.call(widget.columnId); + widget.dataSource.debugPrint(); + }, + dataSource: widget.dataSource, + interceptor: interceptor, + children: children, + ); + + return Container( + margin: widget.margin, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + color: widget.backgroundColor, + borderRadius: BorderRadius.circular(widget.cornerRadius), + ), + child: Column( + children: [ + if (header != null) header, + Expanded( + child: Padding( + padding: widget.itemMargin, + child: reorderFlex, + ), + ), + if (footer != null) footer, + ], + ), + ); + }, + opaque: false, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BoardOverlay( + key: _columnOverlayKey, + initialEntries: [_overlayEntry], + ); + } + + Widget _buildWidget(BuildContext context, ColumnItem item) { + if (item is PhantomColumnItem) { + return PassthroughPhantomWidget( + key: UniqueKey(), + opacity: widget.config.draggingWidgetOpacity, + passthroughPhantomContext: item.phantomContext, + ); + } else { + return widget.cardBuilder(context, item); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart new file mode 100644 index 0000000000..2ce739220e --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart @@ -0,0 +1,130 @@ +import 'dart:collection'; + +import 'package:equatable/equatable.dart'; +import 'package:flutter/material.dart'; +import '../../utils/log.dart'; +import '../reorder_flex/reorder_flex.dart'; + +abstract class ColumnItem extends ReoderFlexItem { + bool get isPhantom => false; + + @override + String toString() => id; +} + +/// [BoardColumnDataController] is used to handle the [BoardColumnData]. +/// * Remove an item by calling [removeAt] method. +/// * Move item to another position by calling [move] method. +/// * Insert item to index by calling [insert] method +/// * Replace item at index by calling [replace] method. +/// +/// All there operations will notify listeners by default. +/// +class BoardColumnDataController extends ChangeNotifier with EquatableMixin { + final BoardColumnData columnData; + + BoardColumnDataController({ + required this.columnData, + }); + + @override + List get props => columnData.props; + + /// Returns the readonly List + UnmodifiableListView get items => + UnmodifiableListView(columnData.items); + + /// Remove the item at [index]. + /// * [index] the index of the item you want to remove + /// * [notify] the default value of [notify] is true, it will notify the + /// listener. Set to [false] if you do not want to notify the listeners. + /// + ColumnItem removeAt(int index, {bool notify = true}) { + assert(index >= 0); + + Log.debug('[$BoardColumnDataController] $columnData remove item at $index'); + final item = columnData._items.removeAt(index); + if (notify) { + notifyListeners(); + } + return item; + } + + int removeWhere(bool Function(ColumnItem) condition) { + return items.indexWhere(condition); + } + + /// Move the item from [fromIndex] to [toIndex]. It will do nothing if the + /// [fromIndex] equal to the [toIndex]. + void move(int fromIndex, int toIndex) { + assert(fromIndex >= 0); + assert(toIndex >= 0); + + if (fromIndex == toIndex) { + return; + } + Log.debug( + '[$BoardColumnDataController] $columnData move item from $fromIndex to $toIndex'); + final item = columnData._items.removeAt(fromIndex); + columnData._items.insert(toIndex, item); + notifyListeners(); + } + + /// Insert an item to [index] and notify the listen if the value of [notify] + /// is true. + /// + /// The default value of [notify] is true. + void insert(int index, ColumnItem item, {bool notify = true}) { + assert(index >= 0); + Log.debug( + '[$BoardColumnDataController] $columnData insert $item at $index'); + + if (columnData._items.length > index) { + columnData._items.insert(index, item); + } else { + columnData._items.add(item); + } + + if (notify) { + notifyListeners(); + } + } + + /// Replace the item at index with the [newItem]. + void replace(int index, ColumnItem newItem) { + if (columnData._items.isEmpty) { + columnData._items.add(newItem); + Log.debug('[$BoardColumnDataController] $columnData add $newItem'); + } else { + final removedItem = columnData._items.removeAt(index); + columnData._items.insert(index, newItem); + Log.debug( + '[$BoardColumnDataController] $columnData replace $removedItem with $newItem at $index'); + } + + notifyListeners(); + } +} + +/// [BoardColumnData] represents the data of each Column of the Board. +class BoardColumnData extends ReoderFlexItem with EquatableMixin { + @override + final String id; + final List _items; + + BoardColumnData({ + required this.id, + required List items, + }) : _items = items; + + /// Returns the readonly List + UnmodifiableListView get items => UnmodifiableListView(_items); + + @override + List get props => [id, ..._items]; + + @override + String toString() { + return 'Column:[$id]'; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart new file mode 100644 index 0000000000..06e8ff1a57 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart @@ -0,0 +1,153 @@ +import 'dart:collection'; + +import 'package:equatable/equatable.dart'; + +import '../utils/log.dart'; +import 'board_column/board_column_data.dart'; +import 'reorder_flex/reorder_flex.dart'; +import 'package:flutter/material.dart'; +import 'reorder_phantom/phantom_controller.dart'; + +typedef OnMoveColumn = void Function(int fromIndex, int toIndex); + +typedef OnMoveColumnItem = void Function( + String columnId, + int fromIndex, + int toIndex, +); + +typedef OnMoveColumnItemToColumn = void Function( + String fromColumnId, + int fromIndex, + String toColumnId, + int toIndex, +); + +class BoardDataController extends ChangeNotifier + with EquatableMixin, BoardPhantomControllerDelegate, ReoderFlextDataSource { + final List _columnDatas = []; + final OnMoveColumn? onMoveColumn; + final OnMoveColumnItem? onMoveColumnItem; + final OnMoveColumnItemToColumn? onMoveColumnItemToColumn; + + List get columnDatas => _columnDatas; + + List get columnIds => + _columnDatas.map((columnData) => columnData.id).toList(); + + final LinkedHashMap _columnControllers = + LinkedHashMap(); + + BoardDataController({ + this.onMoveColumn, + this.onMoveColumnItem, + this.onMoveColumnItemToColumn, + }); + + void addColumn(BoardColumnData columnData) { + final controller = BoardColumnDataController(columnData: columnData); + _columnDatas.add(columnData); + _columnControllers[columnData.id] = controller; + } + + BoardColumnDataController columnController(String columnId) { + return _columnControllers[columnId]!; + } + + void moveColumn(int fromIndex, int toIndex) { + final columnData = _columnDatas.removeAt(fromIndex); + _columnDatas.insert(toIndex, columnData); + onMoveColumn?.call(fromIndex, toIndex); + notifyListeners(); + } + + void moveColumnItem(String columnId, int fromIndex, int toIndex) { + final columnController = _columnControllers[columnId]; + assert(columnController != null); + if (columnController != null) { + columnController.move(fromIndex, toIndex); + onMoveColumnItem?.call(columnId, fromIndex, toIndex); + } + } + + @override + @protected + void swapColumnItem( + String fromColumnId, + int fromColumnIndex, + String toColumnId, + int toColumnIndex, + ) { + final item = columnController(fromColumnId).removeAt(fromColumnIndex); + + if (columnController(toColumnId).items.length > toColumnIndex) { + assert(columnController(toColumnId).items[toColumnIndex] + is PhantomColumnItem); + } + + columnController(toColumnId).replace(toColumnIndex, item); + + onMoveColumnItemToColumn?.call( + fromColumnId, + fromColumnIndex, + toColumnId, + toColumnIndex, + ); + } + + @override + List get props { + return [_columnDatas]; + } + + @override + BoardColumnDataController? controller(String columnId) { + return _columnControllers[columnId]; + } + + @override + String get identifier => '$BoardDataController'; + + @override + UnmodifiableListView get items => + UnmodifiableListView(_columnDatas); + + @override + @protected + bool removePhantom(String columnId) { + final columnController = this.columnController(columnId); + final index = columnController.items.indexWhere((item) => item.isPhantom); + + final isExist = index != -1; + if (isExist) { + columnController.removeAt(index); + + Log.debug( + '[$BoardDataController] Column:[$columnId] remove phantom, current count: ${columnController.items.length}'); + } + return isExist; + } + + @override + @protected + void updatePhantom(String columnId, int newIndex) { + final columnDataController = columnController(columnId); + final index = + columnDataController.items.indexWhere((item) => item.isPhantom); + + assert(index != -1); + if (index != -1) { + if (index != newIndex) { + // Log.debug('[$BoardPhantomController] update $toColumnId:$index to $toColumnId:$phantomIndex'); + final item = columnDataController.removeAt(index, notify: false); + columnDataController.insert(newIndex, item, notify: false); + } + } + } + + @override + @protected + void insertPhantom(String columnId, int index, PhantomColumnItem item) { + columnController(columnId).insert(index, item); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart new file mode 100644 index 0000000000..f5f7250834 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart @@ -0,0 +1,172 @@ +import 'package:flutter/material.dart'; + +import '../../utils/log.dart'; +import 'drag_target.dart'; +import 'reorder_flex.dart'; + +/// [FlexDragTargetData] is used to store the custom dragging data. +/// +/// * [draggingIndex] the index of the dragTarget that is being dragged. +/// * [draggingWidget] the widget of the dragTarget that is being dragged. +/// * [reorderFlexId] the id of the [ReorderFlex] +/// * [reorderFlexItem] the item of the [ReorderFlex] +/// +class FlexDragTargetData extends DragTargetData { + /// The index of the dragging target in the boardList. + @override + final int draggingIndex; + + final DraggingState _state; + + Widget? get draggingWidget => _state.draggingWidget; + + Size? get feedbackSize => _state.feedbackSize; + + final String dragTargetId; + + final String reorderFlexId; + + final ReoderFlexItem reorderFlexItem; + + FlexDragTargetData({ + required this.dragTargetId, + required this.draggingIndex, + required this.reorderFlexId, + required this.reorderFlexItem, + required DraggingState state, + }) : _state = state; + + @override + String toString() { + return 'ReorderFlexId: $reorderFlexId, dragTargetId: $dragTargetId'; + } +} + +class DraggingState { + final String id; + + /// The member of widget.children currently being dragged. + Widget? _draggingWidget; + + Widget? get draggingWidget => _draggingWidget; + + /// The last computed size of the feedback widget being dragged. + Size? feedbackSize = Size.zero; + + /// The location that the dragging widget occupied before it started to drag. + int dragStartIndex = -1; + + /// The index that the dragging widget most recently left. + /// This is used to show an animation of the widget's position. + int phantomIndex = -1; + + /// The index that the dragging widget currently occupies. + int currentIndex = -1; + + /// The widget to move the dragging widget too after the current index. + int nextIndex = 0; + + /// Whether or not we are currently scrolling this view to show a widget. + bool scrolling = false; + + /// The additional margin to place around a computed drop area. + static const double _dropAreaMargin = 0.0; + + DraggingState(this.id); + + Size get dropAreaSize { + if (feedbackSize == null) { + return Size.zero; + } + return feedbackSize! + const Offset(_dropAreaMargin, _dropAreaMargin); + } + + void startDragging( + Widget draggingWidget, + int draggingWidgetIndex, + Size? draggingWidgetSize, + ) { + /// + assert(draggingWidgetIndex >= 0); + + _draggingWidget = draggingWidget; + phantomIndex = draggingWidgetIndex; + dragStartIndex = draggingWidgetIndex; + currentIndex = draggingWidgetIndex; + feedbackSize = draggingWidgetSize; + } + + void endDragging() { + dragStartIndex = -1; + phantomIndex = -1; + currentIndex = -1; + _draggingWidget = null; + } + + /// When the phantomIndex and currentIndex are the same, it means the dragging + /// widget did move to the destination location. + void removePhantom() { + phantomIndex = currentIndex; + } + + /// The dragging widget overlaps with the phantom widget. + bool isOverlapWithPhantom() { + return currentIndex != phantomIndex; + } + + bool isPhantomAboveDragTarget() { + return currentIndex > phantomIndex; + } + + bool isPhantomBelowDragTarget() { + return currentIndex < phantomIndex; + } + + bool didDragTargetMoveToNext() { + return currentIndex == nextIndex; + } + + /// Set the currentIndex to nextIndex + void moveDragTargetToNext() { + currentIndex = nextIndex; + } + + void updateNextIndex(int index) { + Log.trace('updateNextIndex: $index'); + nextIndex = index; + } + + bool isNotDragging() { + return dragStartIndex == -1; + } + + bool isDragging() { + return !isNotDragging(); + } + + /// When the _dragStartIndex less than the _currentIndex, it means the + /// dragTarget is going down to the end of the list. + bool isDragTargetMovingDown() { + return dragStartIndex < currentIndex; + } + + /// The index represents the widget original index of the list. + int calculateShiftedIndex(int index) { + int shiftedIndex = index; + if (index == dragStartIndex) { + shiftedIndex = phantomIndex; + } else if (index > dragStartIndex && index <= phantomIndex) { + /// phantom move up + shiftedIndex--; + } else if (index < dragStartIndex && index >= phantomIndex) { + /// phantom move down + shiftedIndex++; + } + return shiftedIndex; + } + + @override + String toString() { + return 'DragStartIndex: $dragStartIndex, PhantomIndex: $phantomIndex, CurrentIndex: $currentIndex, NextIndex: $nextIndex'; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart new file mode 100644 index 0000000000..ea8cc91fab --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart @@ -0,0 +1,471 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:provider/provider.dart'; +import '../transitions.dart'; + +abstract class DragTargetData { + int get draggingIndex; +} + +abstract class ReorderFlexDraggableTargetBuilder { + Widget? build( + BuildContext context, + Widget child, + DragTargetOnStarted onDragStarted, + DragTargetOnEnded onDragEnded, + DragTargetWillAccpet onWillAccept, + AnimationController insertAnimationController, + AnimationController deleteAnimationController, + ); +} + +/// +typedef DragTargetWillAccpet = bool Function( + T dragTargetData); + +/// +typedef DragTargetOnStarted = void Function(Widget, int, Size?); + +/// +typedef DragTargetOnEnded = void Function( + T dragTargetData); + +/// [ReorderDragTarget] is a [DragTarget] that carries the index information of +/// the child. You could check out this link for more information. +/// +/// The size of the [ReorderDragTarget] will become zero when it start dragging. +/// +class ReorderDragTarget extends StatefulWidget { + final Widget child; + final T dragTargetData; + + final GlobalObjectKey _indexGlobalKey; + + /// Called when dragTarget is being dragging. + final DragTargetOnStarted onDragStarted; + + final DragTargetOnEnded onDragEnded; + + /// Called to determine whether this widget is interested in receiving a given + /// piece of data being dragged over this drag target. + /// + /// [toAccept] represents the dragTarget index, which is the value passed in + /// when creating the [ReorderDragTarget]. + final DragTargetWillAccpet onWillAccept; + + /// Called when an acceptable piece of data was dropped over this drag target. + /// + /// Equivalent to [onAcceptWithDetails], but only includes the data. + final void Function(T dragTargetData)? onAccept; + + /// Called when a given piece of data being dragged over this target leaves + /// the target. + final void Function(T dragTargetData)? onLeave; + + final ReorderFlexDraggableTargetBuilder? draggableTargetBuilder; + + final AnimationController insertAnimationController; + final AnimationController deleteAnimationController; + + final bool useMoveAnimation; + + ReorderDragTarget({ + Key? key, + required this.child, + required this.dragTargetData, + required this.onDragStarted, + required this.onDragEnded, + required this.onWillAccept, + required this.insertAnimationController, + required this.deleteAnimationController, + required this.useMoveAnimation, + this.onAccept, + this.onLeave, + this.draggableTargetBuilder, + }) : _indexGlobalKey = GlobalObjectKey(child.key!), + super(key: key); + + @override + State> createState() => _ReorderDragTargetState(); +} + +class _ReorderDragTargetState + extends State> { + /// Returns the dragTarget's size + Size? _draggingFeedbackSize = Size.zero; + + @override + Widget build(BuildContext context) { + Widget dragTarget = DragTarget( + builder: _buildDraggableWidget, + onWillAccept: (dragTargetData) { + assert(dragTargetData != null); + if (dragTargetData == null) return false; + return widget.onWillAccept(dragTargetData); + }, + onAccept: widget.onAccept, + onLeave: (dragTargetData) { + assert(dragTargetData != null); + if (dragTargetData != null) { + widget.onLeave?.call(dragTargetData); + } + }, + ); + + dragTarget = KeyedSubtree(key: widget._indexGlobalKey, child: dragTarget); + return dragTarget; + } + + Widget _buildDraggableWidget( + BuildContext context, + List acceptedCandidates, + List rejectedCandidates, + ) { + Widget feedbackBuilder = Builder(builder: (BuildContext context) { + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(_draggingFeedbackSize!); + return _buildDraggableFeedback( + context, + contentSizeConstraints, + widget.child, + ); + }); + + final draggableWidget = widget.draggableTargetBuilder?.build( + context, + widget.child, + widget.onDragStarted, + widget.onDragEnded, + widget.onWillAccept, + widget.insertAnimationController, + widget.deleteAnimationController, + ) ?? + LongPressDraggable( + maxSimultaneousDrags: 1, + data: widget.dragTargetData, + ignoringFeedbackSemantics: false, + feedback: feedbackBuilder, + childWhenDragging: IgnorePointerWidget( + useIntrinsicSize: !widget.useMoveAnimation, + child: widget.child, + ), + onDragStarted: () { + _draggingFeedbackSize = widget._indexGlobalKey.currentContext?.size; + widget.onDragStarted( + widget.child, + widget.dragTargetData.draggingIndex, + _draggingFeedbackSize, + ); + }, + dragAnchorStrategy: childDragAnchorStrategy, + + /// When the drag ends inside a DragTarget widget, the drag + /// succeeds, and we reorder the widget into position appropriately. + onDragCompleted: () { + widget.onDragEnded(widget.dragTargetData); + }, + + /// When the drag does not end inside a DragTarget widget, the + /// drag fails, but we still reorder the widget to the last position it + /// had been dragged to. + onDraggableCanceled: (Velocity velocity, Offset offset) => + widget.onDragEnded(widget.dragTargetData), + child: widget.child, + ); + + return draggableWidget; + } + + Widget _buildDraggableFeedback( + BuildContext context, BoxConstraints constraints, Widget child) { + return Transform( + transform: Matrix4.rotationZ(0), + alignment: FractionalOffset.topLeft, + child: Material( + color: Colors.transparent, + borderRadius: BorderRadius.zero, + clipBehavior: Clip.hardEdge, + child: ConstrainedBox( + constraints: constraints, + child: Opacity(opacity: 0.6, child: child), + ), + ), + ); + } +} + +class DragTargetAnimation { + // How long an animation to reorder an element in the list takes. + final Duration reorderAnimationDuration; + + // This controls the entrance of the dragging widget into a new place. + late AnimationController entranceController; + + // This controls the 'phantom' of the dragging widget, which is left behind + // where the widget used to be. + late AnimationController phantomController; + + late AnimationController insertController; + + late AnimationController deleteController; + + DragTargetAnimation({ + required this.reorderAnimationDuration, + required TickerProvider vsync, + required void Function(AnimationStatus) entranceAnimateStatusChanged, + }) { + entranceController = AnimationController( + value: 1.0, vsync: vsync, duration: reorderAnimationDuration); + entranceController.addStatusListener(entranceAnimateStatusChanged); + + phantomController = AnimationController( + value: 0, vsync: vsync, duration: reorderAnimationDuration); + + insertController = AnimationController( + value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 100)); + + deleteController = AnimationController( + value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 10)); + } + + void startDargging() { + entranceController.value = 1.0; + } + + void animateToNext() { + phantomController.reverse(from: 1.0); + entranceController.forward(from: 0.0); + } + + void reverseAnimation() { + phantomController.reverse(from: 0.1); + entranceController.reverse(from: 0.0); + } + + void dispose() { + entranceController.dispose(); + phantomController.dispose(); + insertController.dispose(); + deleteController.dispose(); + } +} + +class IgnorePointerWidget extends StatelessWidget { + final Widget? child; + final bool useIntrinsicSize; + const IgnorePointerWidget({ + required this.child, + this.useIntrinsicSize = false, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final sizedChild = useIntrinsicSize + ? child + : SizedBox(width: 0.0, height: 0.0, child: child); + + final opacity = useIntrinsicSize ? 0.3 : 0.0; + return IgnorePointer( + ignoring: true, + child: Opacity( + opacity: opacity, + child: sizedChild, + ), + ); + } +} + +class PhantomWidget extends StatelessWidget { + final Widget? child; + final double opacity; + const PhantomWidget({ + this.child, + this.opacity = 1.0, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Opacity( + opacity: opacity, + child: child, + ); + } +} + +abstract class DragTargetMovePlaceholderDelegate { + void registerPlaceholder( + int dragTargetIndex, + void Function(int currentDragTargetIndex) callback, + ); + + void unregisterPlaceholder(int dragTargetIndex); +} + +class DragTargeMovePlaceholder extends StatefulWidget { + final double height; + final Color color; + final Color highlightColor; + final int dragTargetIndex; + final DragTargetMovePlaceholderDelegate delegate; + + const DragTargeMovePlaceholder({ + required this.delegate, + required this.dragTargetIndex, + this.height = 4, + this.color = Colors.transparent, + this.highlightColor = Colors.lightBlue, + Key? key, + }) : super(key: key); + + @override + State createState() => + _DragTargeMovePlaceholderState(); +} + +class _DragTargeMovePlaceholderState extends State { + ValueNotifier isHighlight = ValueNotifier(false); + + @override + void initState() { + widget.delegate.registerPlaceholder( + widget.dragTargetIndex, + (currentDragTargetIndex) { + if (!mounted) return; + + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + if (currentDragTargetIndex == -1) { + isHighlight.value = false; + } else { + isHighlight.value = + widget.dragTargetIndex == currentDragTargetIndex; + } + }); + }, + ); + super.initState(); + } + + @override + void dispose() { + isHighlight.dispose(); + widget.delegate.unregisterPlaceholder(widget.dragTargetIndex); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ChangeNotifierProvider.value( + value: isHighlight, + child: Consumer>( + builder: (context, notifier, child) { + return Container( + height: widget.height, + color: notifier.value ? widget.highlightColor : widget.color, + ); + }, + ), + ); + } +} + +abstract class FakeDragTargetEventTrigger { + void fakeOnDragEnded(VoidCallback callback); +} + +abstract class FakeDragTargetEventData { + Size? get feedbackSize; + int get index; + DragTargetData get dragTargetData; +} + +class FakeDragTarget extends StatefulWidget { + final Duration animationDuration; + final FakeDragTargetEventTrigger eventTrigger; + final FakeDragTargetEventData eventData; + final DragTargetOnStarted onDragStarted; + final DragTargetOnEnded onDragEnded; + final DragTargetWillAccpet onWillAccept; + final Widget child; + final AnimationController insertAnimationController; + final AnimationController deleteAnimationController; + const FakeDragTarget({ + Key? key, + required this.eventTrigger, + required this.eventData, + required this.onDragStarted, + required this.onDragEnded, + required this.onWillAccept, + required this.insertAnimationController, + required this.deleteAnimationController, + required this.child, + this.animationDuration = const Duration(milliseconds: 250), + }) : super(key: key); + + @override + State> createState() => _FakeDragTargetState(); +} + +class _FakeDragTargetState + extends State> + with TickerProviderStateMixin> { + bool simulateDragging = false; + + @override + void initState() { + widget.insertAnimationController.addStatusListener( + _onInsertedAnimationStatusChanged, + ); + + /// Start insert animation + widget.insertAnimationController.forward(from: 0.0); + + widget.eventTrigger.fakeOnDragEnded(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + widget.onDragEnded(widget.eventData.dragTargetData as T); + }); + }); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + if (simulateDragging) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: widget.deleteAnimationController, + axis: Axis.vertical, + child: IgnorePointerWidget( + child: widget.child, + ), + ); + } else { + return SizeTransitionWithIntrinsicSize( + sizeFactor: widget.insertAnimationController, + axis: Axis.vertical, + child: IgnorePointerWidget( + useIntrinsicSize: true, + child: widget.child, + ), + ); + } + } + + void _onInsertedAnimationStatusChanged(AnimationStatus status) { + if (status != AnimationStatus.completed) return; + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + setState(() { + simulateDragging = true; + widget.deleteAnimationController.reverse(from: 1.0); + widget.onWillAccept(widget.eventData.dragTargetData as T); + widget.onDragStarted( + widget.child, + widget.eventData.index, + widget.eventData.feedbackSize, + ); + }); + }); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart new file mode 100644 index 0000000000..da529819dd --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart @@ -0,0 +1,161 @@ +import 'package:flutter/material.dart'; + +import '../../utils/log.dart'; +import 'drag_state.dart'; +import 'drag_target.dart'; +import 'reorder_flex.dart'; + +/// [DragTargetInterceptor] is used to intercept the [DragTarget]'s +/// [onWillAccept], [OnAccept], and [onLeave] event. +abstract class DragTargetInterceptor { + /// Returns [yes] to receive the [DragTarget]'s event. + bool canHandler(FlexDragTargetData dragTargetData); + + /// Handle the [DragTarget]'s [onWillAccept] event. + bool onWillAccept({ + required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex, + }); + + /// Handle the [DragTarget]'s [onAccept] event. + void onAccept(FlexDragTargetData dragTargetData) {} + + /// Handle the [DragTarget]'s [onLeave] event. + void onLeave(FlexDragTargetData dragTargetData) {} + + ReorderFlexDraggableTargetBuilder? get draggableTargetBuilder => null; +} + +abstract class OverlapDragTargetDelegate { + void cancel(); + void moveTo( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ); + + bool canMoveTo(String dragTargetId); +} + +/// [OverlappingDragTargetInteceptor] is used to receive the overlapping +/// [DragTarget] event. If a [DragTarget] child is [DragTarget], it will +/// receive the [DragTarget] event when being dragged. +/// +/// Receive the [DragTarget] event if the [acceptedReorderFlexId] contains +/// the passed in dragTarget' reorderFlexId. +class OverlappingDragTargetInteceptor extends DragTargetInterceptor { + final String reorderFlexId; + final List acceptedReorderFlexId; + final OverlapDragTargetDelegate delegate; + + OverlappingDragTargetInteceptor({ + required this.delegate, + required this.reorderFlexId, + required this.acceptedReorderFlexId, + }); + + @override + bool canHandler(FlexDragTargetData dragTargetData) { + return acceptedReorderFlexId.contains(dragTargetData.reorderFlexId); + } + + @override + bool onWillAccept( + {required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex}) { + if (dragTargetId == dragTargetData.reorderFlexId) { + delegate.cancel(); + } else { + if (delegate.canMoveTo(dragTargetId)) { + delegate.moveTo(dragTargetId, dragTargetData, 0); + } + } + + return true; + } +} + +abstract class CrossReorderFlexDragTargetDelegate { + /// * [reorderFlexId] is the id that the [ReorderFlex] passed in. + bool acceptNewDragTargetData( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ); + + void updateDragTargetData( + String reorderFlexId, + int dragTargetIndex, + ); +} + +class CrossReorderFlexDragTargetInterceptor extends DragTargetInterceptor { + final String reorderFlexId; + final List acceptedReorderFlexIds; + final CrossReorderFlexDragTargetDelegate delegate; + @override + final ReorderFlexDraggableTargetBuilder? draggableTargetBuilder; + + CrossReorderFlexDragTargetInterceptor({ + required this.reorderFlexId, + required this.delegate, + required this.acceptedReorderFlexIds, + this.draggableTargetBuilder, + }); + + @override + bool canHandler(FlexDragTargetData dragTargetData) { + if (acceptedReorderFlexIds.isEmpty) { + return false; + } + + if (acceptedReorderFlexIds.contains(dragTargetData.reorderFlexId)) { + /// If the columnId equal to the dragTargetData's columnId, + /// it means the dragTarget is dragging on the top of its own list. + /// Otherwise, it means the dargTarget was moved to another list. + return reorderFlexId != dragTargetData.reorderFlexId; + } else { + return false; + } + } + + @override + void onAccept(FlexDragTargetData dragTargetData) { + Log.trace( + '[$CrossReorderFlexDragTargetInterceptor] Column:[$reorderFlexId] on onAccept'); + } + + @override + void onLeave(FlexDragTargetData dragTargetData) { + Log.trace( + '[$CrossReorderFlexDragTargetInterceptor] Column:[$reorderFlexId] on leave'); + } + + @override + bool onWillAccept({ + required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex, + }) { + final isNewDragTarget = delegate.acceptNewDragTargetData( + reorderFlexId, + dragTargetData, + dragTargetIndex, + ); + + if (isNewDragTarget == false) { + delegate.updateDragTargetData(reorderFlexId, dragTargetIndex); + reorderFlexState.handleOnWillAccept(context, dragTargetIndex); + } + + return true; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart new file mode 100644 index 0000000000..6354b25c33 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart @@ -0,0 +1,558 @@ +import 'dart:collection'; +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import '../../utils/log.dart'; +import 'reorder_mixin.dart'; +import 'drag_target.dart'; +import 'drag_state.dart'; +import 'drag_target_inteceptor.dart'; + +typedef OnDragStarted = void Function(int index); +typedef OnDragEnded = void Function(); +typedef OnReorder = void Function(int fromIndex, int toIndex); +typedef OnDeleted = void Function(int deletedIndex); +typedef OnInserted = void Function(int insertedIndex); +typedef OnReveivePassedInPhantom = void Function( + FlexDragTargetData dragTargetData, int phantomIndex); + +abstract class ReoderFlextDataSource { + /// [identifier] represents the id the [ReorderFlex]. It must be unique. + String get identifier; + + /// The number of [ReoderFlexItem]s will be displaied in the [ReorderFlex]. + UnmodifiableListView get items; +} + +/// Each item displaied in the [ReorderFlex] required to implement the [ReoderFlexItem]. +abstract class ReoderFlexItem { + /// [id] is used to identify the item. It must be unique. + String get id; +} + +class ReorderFlexConfig { + /// The opacity of the dragging widget + final double draggingWidgetOpacity = 0.2; + + // How long an animation to reorder an element + final Duration reorderAnimationDuration = const Duration(milliseconds: 250); + + // How long an animation to scroll to an off-screen element + final Duration scrollAnimationDuration = const Duration(milliseconds: 250); + + final bool useMoveAnimation; + + final bool useMovePlaceholder; + + const ReorderFlexConfig({ + this.useMoveAnimation = true, + }) : useMovePlaceholder = !useMoveAnimation; +} + +class ReorderFlex extends StatefulWidget { + final ReorderFlexConfig config; + + final List children; + + /// [direction] How to place the children, default is Axis.vertical + final Axis direction; + final MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start; + + final ScrollController? scrollController; + + /// [onDragStarted] is called when start dragging + final OnDragStarted? onDragStarted; + + /// [onReorder] is called when dragTarget did end dragging + final OnReorder onReorder; + + /// [onDragEnded] is called when dragTarget did end dragging + final OnDragEnded? onDragEnded; + + final ReoderFlextDataSource dataSource; + + final DragTargetInterceptor? interceptor; + + const ReorderFlex({ + Key? key, + this.scrollController, + required this.dataSource, + required this.children, + required this.config, + required this.onReorder, + this.onDragStarted, + this.onDragEnded, + this.interceptor, + this.direction = Axis.vertical, + }) : super(key: key); + + @override + State createState() => ReorderFlexState(); + + String get reorderFlexId => dataSource.identifier; +} + +class ReorderFlexState extends State + with ReorderFlexMinxi, TickerProviderStateMixin { + /// Controls scrolls and measures scroll progress. + late ScrollController _scrollController; + + /// Records the position of the [Scrollable] + ScrollPosition? _attachedScrollPosition; + + /// Whether or not we are currently scrolling this view to show a widget. + bool _scrolling = false; + + /// [dragState] records the dragging state including dragStartIndex, and phantomIndex, etc. + late DraggingState dragState; + + /// [_animation] controls the dragging animations + late DragTargetAnimation _animation; + + late ReorderFlexNotifier _notifier; + + @override + void initState() { + _notifier = ReorderFlexNotifier(); + dragState = DraggingState(widget.reorderFlexId); + + _animation = DragTargetAnimation( + reorderAnimationDuration: widget.config.reorderAnimationDuration, + entranceAnimateStatusChanged: (status) { + if (status == AnimationStatus.completed) { + setState(() => _requestAnimationToNextIndex()); + } + }, + vsync: this, + ); + + super.initState(); + } + + @override + void didChangeDependencies() { + if (_attachedScrollPosition != null) { + _scrollController.detach(_attachedScrollPosition!); + _attachedScrollPosition = null; + } + + _scrollController = widget.scrollController ?? + PrimaryScrollController.of(context) ?? + ScrollController(); + + if (_scrollController.hasClients) { + _attachedScrollPosition = Scrollable.of(context)?.position; + } else { + _attachedScrollPosition = null; + } + + if (_attachedScrollPosition != null) { + _scrollController.attach(_attachedScrollPosition!); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final List children = []; + + for (int i = 0; i < widget.children.length; i += 1) { + Widget child = widget.children[i]; + children.add(_wrap(child, i)); + + // if (widget.config.useMovePlaceholder) { + // children.add(DragTargeMovePlaceholder( + // dragTargetIndex: i, + // delegate: _notifier, + // )); + // } + } + + final child = _wrapContainer(children); + return _wrapScrollView(child: child); + } + + @override + void dispose() { + if (_attachedScrollPosition != null) { + _scrollController.detach(_attachedScrollPosition!); + _attachedScrollPosition = null; + } + + _animation.dispose(); + super.dispose(); + } + + void _requestAnimationToNextIndex({bool isAcceptingNewTarget = false}) { + /// Update the dragState and animate to the next index if the current + /// dragging animation is completed. Otherwise, it will get called again + /// when the animation finishs. + + if (_animation.entranceController.isCompleted) { + dragState.removePhantom(); + + if (!isAcceptingNewTarget && dragState.didDragTargetMoveToNext()) { + return; + } + + dragState.moveDragTargetToNext(); + _animation.animateToNext(); + } + } + + /// [child]: the child will be wrapped with dartTarget + /// [childIndex]: the index of the child in a list + Widget _wrap(Widget child, int childIndex) { + return Builder(builder: (context) { + final ReorderDragTarget dragTarget = + _buildDragTarget(context, child, childIndex); + int shiftedIndex = childIndex; + + if (dragState.isOverlapWithPhantom()) { + shiftedIndex = dragState.calculateShiftedIndex(childIndex); + } + + Log.trace( + 'Rebuild: Column:[${dragState.id}] ${dragState.toString()}, childIndex: $childIndex shiftedIndex: $shiftedIndex'); + final currentIndex = dragState.currentIndex; + final dragPhantomIndex = dragState.phantomIndex; + + if (shiftedIndex == currentIndex || childIndex == dragPhantomIndex) { + Widget dragSpace; + if (dragState.draggingWidget != null) { + if (dragState.draggingWidget is PhantomWidget) { + dragSpace = dragState.draggingWidget!; + } else { + dragSpace = PhantomWidget( + opacity: widget.config.draggingWidgetOpacity, + child: dragState.draggingWidget, + ); + } + } else { + dragSpace = SizedBox.fromSize(size: dragState.dropAreaSize); + } + + /// Returns the dragTarget it is not start dragging. The size of the + /// dragTarget is the same as the the passed in child. + /// + if (dragState.isNotDragging()) { + return _buildDraggingContainer(children: [dragTarget]); + } + + /// Determine the size of the drop area to show under the dragging widget. + Size? feedbackSize = Size.zero; + if (widget.config.useMoveAnimation) { + feedbackSize = dragState.feedbackSize; + } + + Widget appearSpace = _makeAppearSpace(dragSpace, feedbackSize); + Widget disappearSpace = _makeDisappearSpace(dragSpace, feedbackSize); + + /// When start dragging, the dragTarget, [ReorderDragTarget], will + /// return a [IgnorePointerWidget] which size is zero. + if (dragState.isPhantomAboveDragTarget()) { + _notifier.updateDragTargetIndex(currentIndex); + if (shiftedIndex == currentIndex && childIndex == dragPhantomIndex) { + return _buildDraggingContainer(children: [ + disappearSpace, + dragTarget, + appearSpace, + ]); + } else if (shiftedIndex == currentIndex) { + return _buildDraggingContainer(children: [ + dragTarget, + appearSpace, + ]); + } else if (childIndex == dragPhantomIndex) { + return _buildDraggingContainer( + children: shiftedIndex <= childIndex + ? [dragTarget, disappearSpace] + : [disappearSpace, dragTarget]); + } + } + + /// + if (dragState.isPhantomBelowDragTarget()) { + _notifier.updateDragTargetIndex(currentIndex); + if (shiftedIndex == currentIndex && childIndex == dragPhantomIndex) { + return _buildDraggingContainer(children: [ + appearSpace, + dragTarget, + disappearSpace, + ]); + } else if (shiftedIndex == currentIndex) { + return _buildDraggingContainer(children: [ + appearSpace, + dragTarget, + ]); + } else if (childIndex == dragPhantomIndex) { + return _buildDraggingContainer( + children: shiftedIndex >= childIndex + ? [disappearSpace, dragTarget] + : [dragTarget, disappearSpace]); + } + } + + assert(!dragState.isOverlapWithPhantom()); + + List children = []; + if (dragState.isDragTargetMovingDown()) { + children.addAll([dragTarget, appearSpace]); + } else { + children.addAll([appearSpace, dragTarget]); + } + return _buildDraggingContainer(children: children); + } + + /// We still wrap dragTarget with a container so that widget's depths are + /// the same and it prevent's layout alignment issue + return _buildDraggingContainer(children: [dragTarget]); + }); + } + + ReorderDragTarget _buildDragTarget( + BuildContext builderContext, Widget child, int dragTargetIndex) { + final ReoderFlexItem reorderFlexItem = + widget.dataSource.items[dragTargetIndex]; + return ReorderDragTarget( + dragTargetData: FlexDragTargetData( + draggingIndex: dragTargetIndex, + reorderFlexId: widget.reorderFlexId, + reorderFlexItem: reorderFlexItem, + state: dragState, + dragTargetId: reorderFlexItem.id, + ), + onDragStarted: (draggingWidget, draggingIndex, size) { + Log.debug( + "[DragTarget] Column:[${widget.dataSource.identifier}] start dragging item at $draggingIndex"); + _startDragging(draggingWidget, draggingIndex, size); + widget.onDragStarted?.call(draggingIndex); + }, + onDragEnded: (dragTargetData) { + Log.debug( + "[DragTarget]: Column:[${widget.dataSource.identifier}] end dragging"); + _notifier.updateDragTargetIndex(-1); + setState(() { + if (dragTargetData.reorderFlexId == widget.reorderFlexId) { + _onReordered( + dragState.dragStartIndex, + dragState.currentIndex, + ); + } + + dragState.endDragging(); + widget.onDragEnded?.call(); + }); + }, + onWillAccept: (FlexDragTargetData dragTargetData) { + if (_animation.deleteController.isAnimating) { + return false; + } + + assert(widget.dataSource.items.length > dragTargetIndex); + if (_interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onWillAccept( + context: builderContext, + reorderFlexState: this, + dragTargetData: dragTargetData, + dragTargetId: reorderFlexItem.id, + dragTargetIndex: dragTargetIndex, + ), + )) { + return true; + } else { + return handleOnWillAccept(builderContext, dragTargetIndex); + } + }, + onAccept: (dragTargetData) { + _interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onAccept(dragTargetData), + ); + }, + onLeave: (dragTargetData) { + _notifier.updateDragTargetIndex(-1); + _interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onLeave(dragTargetData), + ); + }, + insertAnimationController: _animation.insertController, + deleteAnimationController: _animation.deleteController, + draggableTargetBuilder: widget.interceptor?.draggableTargetBuilder, + useMoveAnimation: widget.config.useMoveAnimation, + child: child, + ); + } + + bool _interceptDragTarget( + FlexDragTargetData dragTargetData, + void Function(DragTargetInterceptor) callback, + ) { + final interceptor = widget.interceptor; + if (interceptor != null && interceptor.canHandler(dragTargetData)) { + callback(interceptor); + return true; + } else { + return false; + } + } + + Widget _makeAppearSpace(Widget child, Size? feedbackSize) { + return makeAppearingWidget( + child, + _animation.entranceController, + feedbackSize, + widget.direction, + ); + } + + Widget _makeDisappearSpace(Widget child, Size? feedbackSize) { + return makeDisappearingWidget( + child, + _animation.phantomController, + feedbackSize, + widget.direction, + ); + } + + void _startDragging( + Widget draggingWidget, + int dragIndex, + Size? feedbackSize, + ) { + setState(() { + dragState.startDragging(draggingWidget, dragIndex, feedbackSize); + _animation.startDargging(); + }); + } + + bool handleOnWillAccept(BuildContext context, int dragTargetIndex) { + final dragIndex = dragState.dragStartIndex; + + /// The [willAccept] will be true if the dargTarget is the widget that gets + /// dragged and it is dragged on top of the other dragTargets. + /// + Log.debug( + '[$ReorderDragTarget] ${widget.dataSource.identifier} on will accept, dragIndex:$dragIndex, dragTargetIndex:$dragTargetIndex, count: ${widget.dataSource.items.length}'); + + bool willAccept = + dragState.dragStartIndex == dragIndex && dragIndex != dragTargetIndex; + setState(() { + if (willAccept) { + int shiftedIndex = dragState.calculateShiftedIndex(dragTargetIndex); + dragState.updateNextIndex(shiftedIndex); + } else { + dragState.updateNextIndex(dragTargetIndex); + } + _requestAnimationToNextIndex(isAcceptingNewTarget: true); + }); + + _scrollTo(context); + + /// If the target is not the original starting point, then we will accept the drop. + return willAccept; + } + + void _onReordered(int fromIndex, int toIndex) { + if (fromIndex != toIndex) { + widget.onReorder.call(fromIndex, toIndex); + } + + _animation.reverseAnimation(); + } + + Widget _wrapScrollView({required Widget child}) { + if (widget.scrollController != null && + PrimaryScrollController.of(context) == null) { + return child; + } else { + return SingleChildScrollView( + scrollDirection: widget.direction, + controller: _scrollController, + child: child, + ); + } + } + + Widget _wrapContainer(List children) { + switch (widget.direction) { + case Axis.horizontal: + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + case Axis.vertical: + default: + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + } + } + + Widget _buildDraggingContainer({required List children}) { + switch (widget.direction) { + case Axis.horizontal: + return Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + case Axis.vertical: + default: + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + } + } + +// Scrolls to a target context if that context is not on the screen. + void _scrollTo(BuildContext context) { + if (_scrolling) return; + final RenderObject contextObject = context.findRenderObject()!; + final RenderAbstractViewport viewport = + RenderAbstractViewport.of(contextObject)!; + // If and only if the current scroll offset falls in-between the offsets + // necessary to reveal the selected context at the top or bottom of the + // screen, then it is already on-screen. + final double margin = widget.direction == Axis.horizontal + ? dragState.dropAreaSize.width + : dragState.dropAreaSize.height; + if (_scrollController.hasClients) { + final double scrollOffset = _scrollController.offset; + final double topOffset = max( + _scrollController.position.minScrollExtent, + viewport.getOffsetToReveal(contextObject, 0.0).offset - margin, + ); + final double bottomOffset = min( + _scrollController.position.maxScrollExtent, + viewport.getOffsetToReveal(contextObject, 1.0).offset + margin, + ); + final bool onScreen = + scrollOffset <= topOffset && scrollOffset >= bottomOffset; + + // If the context is off screen, then we request a scroll to make it visible. + if (!onScreen) { + _scrolling = true; + _scrollController.position + .animateTo( + scrollOffset < bottomOffset ? bottomOffset : topOffset, + duration: widget.config.scrollAnimationDuration, + curve: Curves.easeInOut, + ) + .then((void value) { + setState(() => _scrolling = false); + }); + } + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart new file mode 100644 index 0000000000..accdaa866b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart @@ -0,0 +1,142 @@ +import 'package:flutter/widgets.dart'; + +import '../transitions.dart'; +import 'drag_target.dart'; + +mixin ReorderFlexMinxi { + @protected + Widget makeAppearingWidget( + Widget child, + AnimationController animationController, + Size? draggingFeedbackSize, + Axis direction, + ) { + final sizeFactor = animationController.withLinearCurve(); + if (null == draggingFeedbackSize) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition( + opacity: sizeFactor, + child: child, + ), + ); + } else { + var transition = SizeTransition( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition(opacity: animationController, child: child), + ); + + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(draggingFeedbackSize); + return ConstrainedBox( + constraints: contentSizeConstraints, child: transition); + } + } + + @protected + Widget makeDisappearingWidget( + Widget child, + AnimationController animationController, + Size? draggingFeedbackSize, + Axis direction, + ) { + final sizeFactor = animationController.withLinearCurve(); + if (null == draggingFeedbackSize) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition( + opacity: sizeFactor, + child: child, + ), + ); + } else { + var transition = SizeTransition( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition(opacity: animationController, child: child), + ); + + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(draggingFeedbackSize); + return ConstrainedBox( + constraints: contentSizeConstraints, child: transition); + } + } +} + +Animation withCurve( + AnimationController animationController, Cubic curve) { + return CurvedAnimation( + parent: animationController, + curve: curve, + ); +} + +extension CurveAnimationController on AnimationController { + Animation withLinearCurve() { + return withCurve(Curves.linear); + } + + Animation withCurve(Curve curve) { + return CurvedAnimation( + parent: this, + curve: curve, + ); + } +} + +class ReorderFlexNotifier extends DragTargetMovePlaceholderDelegate { + Map dragTargeEventNotifier = {}; + + void updateDragTargetIndex(int index) { + for (var notifier in dragTargeEventNotifier.values) { + notifier.setDragTargetIndex(index); + } + } + + DragTargetEventNotifier _notifierFromIndex(int dragTargetIndex) { + DragTargetEventNotifier? notifier = dragTargeEventNotifier[dragTargetIndex]; + if (notifier == null) { + final newNotifier = DragTargetEventNotifier(); + dragTargeEventNotifier[dragTargetIndex] = newNotifier; + notifier = newNotifier; + } + + return notifier; + } + + void dispose() { + for (var notifier in dragTargeEventNotifier.values) { + notifier.dispose(); + } + } + + @override + void registerPlaceholder( + int dragTargetIndex, + void Function(int dragTargetIndex) callback, + ) { + _notifierFromIndex(dragTargetIndex).addListener(() { + callback.call(_notifierFromIndex(dragTargetIndex).currentDragTargetIndex); + }); + } + + @override + void unregisterPlaceholder(int dragTargetIndex) { + dragTargeEventNotifier.remove(dragTargetIndex); + } +} + +class DragTargetEventNotifier extends ChangeNotifier { + int currentDragTargetIndex = -1; + + void setDragTargetIndex(int index) { + if (currentDragTargetIndex != index) { + currentDragTargetIndex = index; + notifyListeners(); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart new file mode 100644 index 0000000000..ccff83b502 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart @@ -0,0 +1,353 @@ +import 'package:flutter/material.dart'; +import '../../utils/log.dart'; +import '../board_column/board_column_data.dart'; +import '../reorder_flex/drag_state.dart'; +import '../reorder_flex/drag_target.dart'; +import '../reorder_flex/drag_target_inteceptor.dart'; +import 'phantom_state.dart'; + +abstract class BoardPhantomControllerDelegate { + BoardColumnDataController? controller(String columnId); + + bool removePhantom(String columnId); + + /// Insert the phantom into column + /// + /// * [toColumnId] id of the column + /// * [phantomIndex] the phantom occupies index + void insertPhantom( + String columnId, + int index, + PhantomColumnItem item, + ); + + /// Update the column's phantom index if it exists. + /// [toColumnId] the id of the column + /// [dragTargetIndex] the index of the dragTarget + void updatePhantom(String columnId, int newIndex); + + void swapColumnItem( + String fromColumnId, + int fromColumnIndex, + String toColumnId, + int toColumnIndex, + ); +} + +class BoardPhantomController extends OverlapDragTargetDelegate + with CrossReorderFlexDragTargetDelegate { + PhantomRecord? phantomRecord; + final BoardPhantomControllerDelegate delegate; + final columnsState = ColumnPhantomStateController(); + BoardPhantomController({required this.delegate}); + + bool isFromColumn(String columnId) { + if (phantomRecord != null) { + return phantomRecord!.fromColumnId == columnId; + } else { + return true; + } + } + + void transformIndex(int fromIndex, int toIndex) { + if (phantomRecord == null) { + return; + } + assert(phantomRecord!.fromColumnIndex == fromIndex); + phantomRecord?.updateFromColumnIndex(toIndex); + } + + void columnStartDragging(String columnId) { + columnsState.setColumnIsDragging(columnId, false); + } + + /// Remove the phanton in the column when the column is end dragging. + void columnEndDragging(String columnId) { + columnsState.setColumnIsDragging(columnId, true); + if (phantomRecord == null) return; + + final fromColumnId = phantomRecord!.fromColumnId; + final toColumnId = phantomRecord!.toColumnId; + if (fromColumnId == columnId) { + columnsState.notifyDidRemovePhantom(toColumnId); + } + + if (columnsState.isDragging(fromColumnId) == false) { + return; + } + + delegate.swapColumnItem( + fromColumnId, + phantomRecord!.fromColumnIndex, + toColumnId, + phantomRecord!.toColumnIndex, + ); + + Log.debug("[$BoardPhantomController] did move ${phantomRecord.toString()}"); + phantomRecord = null; + } + + /// Remove the phantom in the column if it contains phantom + void _removePhantom(String columnId) { + if (delegate.removePhantom(columnId)) { + columnsState.notifyDidRemovePhantom(columnId); + columnsState.removeColumnListener(columnId); + } + } + + void _insertPhantom( + String toColumnId, + FlexDragTargetData dragTargetData, + int phantomIndex, + ) { + final phantomContext = PassthroughPhantomContext( + index: phantomIndex, + dragTargetData: dragTargetData, + ); + columnsState.addColumnListener(toColumnId, phantomContext); + + delegate.insertPhantom( + toColumnId, + phantomIndex, + PhantomColumnItem(phantomContext), + ); + + columnsState.notifyDidInsertPhantom(toColumnId); + } + + /// Reset or initial the [PhantomRecord] + /// + /// + /// * [columnId] the id of the column + /// * [dragTargetData] + /// * [dragTargetIndex] + /// + void _resetPhantomRecord( + String columnId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + // Log.debug('[$BoardPhantomController] move Column:[${dragTargetData.reorderFlexId}]:${dragTargetData.draggingIndex} ' + // 'to Column:[$columnId]:$index'); + + phantomRecord = PhantomRecord( + toColumnId: columnId, + toColumnIndex: dragTargetIndex, + fromColumnId: dragTargetData.reorderFlexId, + fromColumnIndex: dragTargetData.draggingIndex, + ); + Log.debug('[$BoardPhantomController] will move: $phantomRecord'); + } + + @override + bool acceptNewDragTargetData( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + if (phantomRecord == null) { + _resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex); + _insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex); + return false; + } + + final isNewDragTarget = phantomRecord!.toColumnId != reorderFlexId; + if (isNewDragTarget) { + /// Remove the phantom when the dragTarget is moved from one column to another column. + _removePhantom(phantomRecord!.toColumnId); + _resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex); + _insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex); + } + + return isNewDragTarget; + } + + @override + void updateDragTargetData( + String reorderFlexId, + int dragTargetIndex, + ) { + phantomRecord?.updateInsertedIndex(dragTargetIndex); + + assert(phantomRecord != null); + if (phantomRecord!.toColumnId == reorderFlexId) { + /// Update the existing phantom index + delegate.updatePhantom(phantomRecord!.toColumnId, dragTargetIndex); + } + } + + @override + void cancel() { + if (phantomRecord == null) { + return; + } + + /// Remove the phantom when the dragTarge is go back to the original column. + _removePhantom(phantomRecord!.toColumnId); + phantomRecord = null; + } + + @override + void moveTo( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + acceptNewDragTargetData( + reorderFlexId, + dragTargetData, + dragTargetIndex, + ); + } + + @override + bool canMoveTo(String dragTargetId) { + return delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false; + } +} + +/// Use [PhantomRecord] to record where to remove the column item and where to +/// insert the column item. +/// +/// [fromColumnId] the column that phantom comes from +/// [fromColumnIndex] the index of the phantom from the original column +/// [toColumnId] the column that the phantom moves into +/// [toColumnIndex] the index of the phantom moves into the column +/// +class PhantomRecord { + final String fromColumnId; + int fromColumnIndex; + + final String toColumnId; + int toColumnIndex; + + PhantomRecord({ + required this.toColumnId, + required this.toColumnIndex, + required this.fromColumnId, + required this.fromColumnIndex, + }); + + void updateFromColumnIndex(int index) { + if (fromColumnIndex == index) { + return; + } + Log.debug( + '[$PhantomRecord] Update Column:[$fromColumnId] remove position to $index'); + fromColumnIndex = index; + } + + void updateInsertedIndex(int index) { + if (toColumnIndex == index) { + return; + } + + Log.debug( + '[$PhantomRecord] Column:[$toColumnId] update position $toColumnIndex -> $index'); + toColumnIndex = index; + } + + @override + String toString() { + return 'Column:[$fromColumnId]:$fromColumnIndex to Column:[$toColumnId]:$toColumnIndex'; + } +} + +class PhantomColumnItem extends ColumnItem { + final PassthroughPhantomContext phantomContext; + + PhantomColumnItem(PassthroughPhantomContext insertedPhantom) + : phantomContext = insertedPhantom; + + @override + bool get isPhantom => true; + + @override + String get id => phantomContext.itemData.id; + + Size? get feedbackSize => phantomContext.feedbackSize; + + Widget get draggingWidget => phantomContext.draggingWidget == null + ? const SizedBox() + : phantomContext.draggingWidget!; + + @override + String toString() { + return 'phantom:$id'; + } +} + +class PassthroughPhantomContext extends FakeDragTargetEventTrigger + with FakeDragTargetEventData, PassthroughPhantomListener { + @override + int index; + + @override + final FlexDragTargetData dragTargetData; + + @override + Size? get feedbackSize => dragTargetData.feedbackSize; + + Widget? get draggingWidget => dragTargetData.draggingWidget; + + ColumnItem get itemData => dragTargetData.reorderFlexItem as ColumnItem; + + @override + VoidCallback? onInserted; + + @override + VoidCallback? onDragEnded; + + PassthroughPhantomContext({ + required this.index, + required this.dragTargetData, + }); + + @override + void fakeOnDragEnded(VoidCallback callback) { + onDragEnded = callback; + } +} + +class PassthroughPhantomWidget extends PhantomWidget { + final PassthroughPhantomContext passthroughPhantomContext; + + PassthroughPhantomWidget({ + required double opacity, + required this.passthroughPhantomContext, + Key? key, + }) : super( + child: passthroughPhantomContext.draggingWidget, + opacity: opacity, + key: key, + ); +} + +class PhantomDraggableBuilder extends ReorderFlexDraggableTargetBuilder { + PhantomDraggableBuilder(); + @override + Widget? build( + BuildContext context, + Widget child, + DragTargetOnStarted onDragStarted, + DragTargetOnEnded onDragEnded, + DragTargetWillAccpet onWillAccept, + AnimationController insertAnimationController, + AnimationController deleteAnimationController, + ) { + if (child is PassthroughPhantomWidget) { + return FakeDragTarget( + eventTrigger: child.passthroughPhantomContext, + eventData: child.passthroughPhantomContext, + onDragStarted: onDragStarted, + onDragEnded: onDragEnded, + onWillAccept: onWillAccept, + insertAnimationController: insertAnimationController, + deleteAnimationController: deleteAnimationController, + child: child, + ); + } else { + return null; + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart new file mode 100644 index 0000000000..d33b53500d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart @@ -0,0 +1,103 @@ +import 'phantom_controller.dart'; +import 'package:flutter/material.dart'; + +class ColumnPhantomStateController { + final _states = {}; + + void setColumnIsDragging(String columnId, bool isDragging) { + _stateWithId(columnId).isDragging = isDragging; + } + + bool isDragging(String columnId) { + return _stateWithId(columnId).isDragging; + } + + void addColumnListener(String columnId, PassthroughPhantomListener listener) { + _stateWithId(columnId).notifier.addListener( + onInserted: (c) => listener.onInserted?.call(), + onDeleted: () => listener.onDragEnded?.call(), + ); + } + + void removeColumnListener(String columnId) { + _stateWithId(columnId).notifier.dispose(); + _states.remove(columnId); + } + + void notifyDidInsertPhantom(String columnId) { + _stateWithId(columnId).notifier.insert(); + } + + void notifyDidRemovePhantom(String columnId) { + _stateWithId(columnId).notifier.remove(); + } + + ColumnState _stateWithId(String columnId) { + var state = _states[columnId]; + if (state == null) { + state = ColumnState(); + _states[columnId] = state; + } + return state; + } +} + +class ColumnState { + bool isDragging = false; + final notifier = PassthroughPhantomNotifier(); +} + +abstract class PassthroughPhantomListener { + VoidCallback? get onInserted; + VoidCallback? get onDragEnded; +} + +class PassthroughPhantomNotifier { + final insertNotifier = PhantomInsertNotifier(); + + final removeNotifier = PhantomDeleteNotifier(); + + void insert() { + insertNotifier.insert(); + } + + void remove() { + removeNotifier.remove(); + } + + void addListener({ + void Function(PassthroughPhantomContext? insertedPhantom)? onInserted, + void Function()? onDeleted, + }) { + if (onInserted != null) { + insertNotifier.addListener(() { + onInserted(insertNotifier.insertedPhantom); + }); + } + + if (onDeleted != null) { + removeNotifier.addListener(() { + onDeleted(); + }); + } + } + + void dispose() { + insertNotifier.dispose(); + removeNotifier.dispose(); + } +} + +class PhantomInsertNotifier extends ChangeNotifier { + PassthroughPhantomContext? insertedPhantom; + + void insert() { + notifyListeners(); + } +} + +class PhantomDeleteNotifier extends ChangeNotifier { + void remove() { + notifyListeners(); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart new file mode 100644 index 0000000000..b802d15dae --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart @@ -0,0 +1,3 @@ +export 'card.dart'; +export 'footer.dart'; +export 'header.dart'; diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart new file mode 100644 index 0000000000..323964c75f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; + +class AppFlowyColumnItemCard extends StatefulWidget { + final Widget? child; + final Color backgroundColor; + final double cornerRadius; + final EdgeInsets margin; + final BoxConstraints boxConstraints; + + const AppFlowyColumnItemCard({ + this.child, + this.cornerRadius = 0.0, + this.margin = const EdgeInsets.all(4), + this.backgroundColor = Colors.white, + this.boxConstraints = const BoxConstraints(minHeight: 40), + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnItemCardState(); +} + +class _AppFlowyColumnItemCardState extends State { + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4), + child: Container( + clipBehavior: Clip.hardEdge, + constraints: widget.boxConstraints, + decoration: BoxDecoration( + color: widget.backgroundColor, + borderRadius: BorderRadius.circular(widget.cornerRadius), + ), + child: widget.child, + ), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart new file mode 100644 index 0000000000..7f5655fe60 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +typedef OnFooterAddButtonClick = void Function(); + +class AppFlowyColumnFooter extends StatefulWidget { + final double height; + final Widget? icon; + final Widget? title; + final EdgeInsets margin; + final OnFooterAddButtonClick? onAddButtonClick; + + const AppFlowyColumnFooter({ + this.icon, + this.title, + this.margin = EdgeInsets.zero, + required this.height, + this.onAddButtonClick, + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnFooterState(); +} + +class _AppFlowyColumnFooterState extends State { + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: widget.onAddButtonClick, + child: SizedBox( + height: widget.height, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (widget.icon != null) widget.icon!, + if (widget.title != null) widget.title!, + ], + ), + ), + ), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart new file mode 100644 index 0000000000..fdebc7ef21 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +typedef OnHeaderAddButtonClick = void Function(); +typedef OnHeaderMoreButtonClick = void Function(); + +class AppFlowyColumnHeader extends StatefulWidget { + final double height; + final Widget? icon; + final Widget? title; + final Widget? addIcon; + final Widget? moreIcon; + final EdgeInsets margin; + final OnHeaderAddButtonClick? onAddButtonClick; + final OnHeaderMoreButtonClick? onMoreButtonClick; + + const AppFlowyColumnHeader({ + required this.height, + this.icon, + this.title, + this.addIcon, + this.moreIcon, + this.margin = EdgeInsets.zero, + this.onAddButtonClick, + this.onMoreButtonClick, + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnHeaderState(); +} + +class _AppFlowyColumnHeaderState extends State { + @override + Widget build(BuildContext context) { + List children = []; + + if (widget.icon != null) { + children.add(widget.icon!); + children.add(_hSpace()); + } + + if (widget.title != null) { + children.add(widget.title!); + children.add(_hSpace()); + } + + if (widget.moreIcon != null) { + children.add(const Spacer()); + children.add( + IconButton(onPressed: widget.onMoreButtonClick, icon: widget.moreIcon!), + ); + } + + if (widget.addIcon != null) { + children.add( + IconButton(onPressed: widget.onAddButtonClick, icon: widget.addIcon!), + ); + } + + return SizedBox( + height: widget.height, + child: Padding( + padding: widget.margin, + child: Row( + children: children, + ), + ), + ); + } + + Widget _hSpace() { + return const SizedBox(width: 6); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart new file mode 100644 index 0000000000..525006af9c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart @@ -0,0 +1,113 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; + +class SizeTransitionWithIntrinsicSize extends SingleChildRenderObjectWidget { + /// Creates a size transition with its intrinsic width/height taking [sizeFactor] + /// into account. + /// + /// The [axis] argument defaults to [Axis.vertical]. + /// The [axisAlignment] defaults to 0.0, which centers the child along the + /// main axis during the transition. + SizeTransitionWithIntrinsicSize({ + this.axis = Axis.vertical, + required this.sizeFactor, + double axisAlignment = 0.0, + Widget? child, + Key? key, + }) : super( + key: key, + child: SizeTransition( + axis: axis, + sizeFactor: sizeFactor, + axisAlignment: axisAlignment, + child: child, + )); + + final Axis axis; + final Animation sizeFactor; + + @override + RenderSizeTransitionWithIntrinsicSize createRenderObject( + BuildContext context) { + return RenderSizeTransitionWithIntrinsicSize( + axis: axis, + sizeFactor: sizeFactor, + ); + } + + @override + void updateRenderObject(BuildContext context, + RenderSizeTransitionWithIntrinsicSize renderObject) { + renderObject + ..axis = axis + ..sizeFactor = sizeFactor; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('axis', axis)); + properties + .add(DiagnosticsProperty>('sizeFactor', sizeFactor)); + } +} + +class RenderSizeTransitionWithIntrinsicSize extends RenderProxyBox { + Axis axis; + Animation sizeFactor; + + RenderSizeTransitionWithIntrinsicSize({ + this.axis = Axis.vertical, + required this.sizeFactor, + RenderBox? child, + }) : super(child); + + @override + double computeMinIntrinsicWidth(double height) { + final child = this.child; + if (child != null) { + double childWidth = child.getMinIntrinsicWidth(height); + return axis == Axis.horizontal + ? childWidth * sizeFactor.value + : childWidth; + } + return 0.0; + } + + @override + double computeMaxIntrinsicWidth(double height) { + final child = this.child; + if (child != null) { + double childWidth = child.getMaxIntrinsicWidth(height); + return axis == Axis.horizontal + ? childWidth * sizeFactor.value + : childWidth; + } + return 0.0; + } + + @override + double computeMinIntrinsicHeight(double width) { + final child = this.child; + if (child != null) { + double childHeight = child.getMinIntrinsicHeight(width); + return axis == Axis.vertical + ? childHeight * sizeFactor.value + : childHeight; + } + return 0.0; + } + + @override + double computeMaxIntrinsicHeight(double width) { + final child = this.child; + if (child != null) { + double childHeight = child.getMaxIntrinsicHeight(width); + return axis == Axis.vertical + ? childHeight * sizeFactor.value + : childHeight; + } + return 0.0; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/pubspec.yaml b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml new file mode 100644 index 0000000000..92b1782ea0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml @@ -0,0 +1,57 @@ +name: appflowy_board +description: A new Flutter package project. +version: 0.0.3 +homepage: https://github.com/AppFlowy-IO/AppFlowy +repository: https://github.com/AppFlowy-IO/AppFlowy + +environment: + sdk: ">=2.17.0 <3.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + equatable: ^2.0.3 + provider: ^6.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart b/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart @@ -0,0 +1 @@ +void main() {} diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index 505280115f..1c8bdf6211 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "42.0.0" + version: "44.0.0" analyzer: dependency: "direct overridden" description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" animations: dependency: transitive description: diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 5f4ff9c9b8..56e96e96dd 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -37,6 +37,8 @@ dependencies: path: packages/flowy_infra_ui flowy_infra: path: packages/flowy_infra + appflowy_board: + path: packages/appflowy_board flutter_quill: git: url: https://github.com/appflowy/flutter-quill.git @@ -86,7 +88,7 @@ dev_dependencies: bloc_test: ^9.0.2 dependency_overrides: - analyzer: ">=4.2.0 <5.0.0" + analyzer: ">=4.4.0 <5.0.0" # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is