From 05ed1f44254a6ae578c062017894fa1e6eee32b9 Mon Sep 17 00:00:00 2001 From: Prateek Sunal <41370460+prateekmedia@users.noreply.github.com> Date: Mon, 14 Feb 2022 01:51:40 +0530 Subject: [PATCH 01/77] Fix example link --- example/example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/example.md b/example/example.md index bbaafbe..0e69b78 100644 --- a/example/example.md +++ b/example/example.md @@ -1,7 +1,7 @@ # Examples for libadwaita flutter package ## Demo App -[Here]('https://github.com/gtk-flutter/libadwaita/tree/main/example') is a demo app made with libadwaita package. +[Here](https://github.com/gtk-flutter/libadwaita/tree/main/example) is a demo app made with libadwaita package. ## Minimal [`libadwaita_bitsdojo`](https://pub.dev/packages/libadwaita_bitsdojo) usage ```yaml From 9479e2bd95b803a251f9041c3b82cb77e8c1406e Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 14 Feb 2022 01:53:27 +0530 Subject: [PATCH 02/77] Bump to 1.0.0+1 --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0857e40..d2dded9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.0+1 + +- Fix Example link + ## 1.0.0 ### **BREAKING** diff --git a/example/pubspec.lock b/example/pubspec.lock index 45ceb67..fc7e893 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,7 +176,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.0+1" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 130f9d0..3183a27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.0.0 +version: 1.0.0+1 homepage: https://github.com/gtk-flutter/libadwaita environment: From 9c460d2b6c597f602530d08892f35d18f0d313a5 Mon Sep 17 00:00:00 2001 From: Prateek Sunal <41370460+prateekmedia@users.noreply.github.com> Date: Mon, 14 Feb 2022 22:03:45 +0530 Subject: [PATCH 03/77] Fix Table --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9538c07..53b1e95 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ See the example app in the `example` folder for more info. There are 6 types of `AdwHeaderBar` constructor: If you want to use default adwaita style window icons or icons using window_decorations package then you have to use any one of the following HeaderBar's: + | Widget | Docs | | ------ | ---- | | `AdwHeaderBar` | Default HeaderBar | @@ -40,6 +41,7 @@ If you want to use default adwaita style window icons or icons using window_deco | `AdwHeaderBar.nativeshell` | HeaderBar to be used with [`nativeshell`](#nativeshell) package | If you want to have a custom icon for window button then you have to use any one of the following HeaderBar's: + | Widget | Docs | | ------ | ---- | | `AdwHeaderBar.custom` | HeaderBar with custom icon | From 0de9c1a69e23bd96c276cc96e3ff2c02acd0118d Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 14 Feb 2022 22:05:52 +0530 Subject: [PATCH 04/77] Bump version to 1.0.0+2 --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2dded9..28a4c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.0+2 + +- Fix Table view on pub.dev +- ## 1.0.0+1 - Fix Example link diff --git a/example/pubspec.lock b/example/pubspec.lock index fc7e893..2801516 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,7 +176,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0+1" + version: "1.0.0+2" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3183a27..dc2fc92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.0.0+1 +version: 1.0.0+2 homepage: https://github.com/gtk-flutter/libadwaita environment: From 702a284422b6713ebb5951444187932a7bc9b62f Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 14 Feb 2022 22:16:51 +0530 Subject: [PATCH 05/77] Fix lint --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28a4c0d..448ac72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.0.0+2 - Fix Table view on pub.dev -- + ## 1.0.0+1 - Fix Example link From ef9891f69a495025a9f22127b5209c6a2a143e6f Mon Sep 17 00:00:00 2001 From: Prateek Sunal <41370460+prateekmedia@users.noreply.github.com> Date: Tue, 15 Feb 2022 03:39:09 +0530 Subject: [PATCH 06/77] Relicense under MPL-2.0 --- LICENSE | 526 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 367 insertions(+), 159 deletions(-) diff --git a/LICENSE b/LICENSE index 153d416..14e2f77 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,373 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 +Mozilla Public License Version 2.0 +================================== - 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. +1. Definitions +-------------- +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. - 0. Additional Definitions. +1.3. "Contribution" + means Covered Software of a particular Contributor. - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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 -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. From 5f688de4c11c404c13b0bc1465840a600cb4d49d Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 15 Feb 2022 03:47:19 +0530 Subject: [PATCH 07/77] Bump version to 1.0.1 --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 448ac72..8baa53e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.1 + +- Relicense under MPL-2.0 + ## 1.0.0+2 - Fix Table view on pub.dev diff --git a/example/pubspec.lock b/example/pubspec.lock index 2801516..bb8df4a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,7 +176,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0+2" + version: "1.0.1" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index dc2fc92..7416e35 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.0.0+2 +version: 1.0.1 homepage: https://github.com/gtk-flutter/libadwaita environment: From ad9a8d3a74a29e8019c9fce01169683a149f1e3d Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 15 Feb 2022 04:03:42 +0530 Subject: [PATCH 08/77] Fix readme, bump to 1.0.2 --- CHANGELOG.md | 98 +++++++++++++++++++++++--------------------- README.md | 2 +- example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8baa53e..31d16da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,90 +1,94 @@ # Changelog +## 1.0.2 + +* Fix License in README + ## 1.0.1 -- Relicense under MPL-2.0 +* Relicense under MPL-2.0 ## 1.0.0+2 -- Fix Table view on pub.dev +* Fix Table view on pub.dev ## 1.0.0+1 -- Fix Example link +* Fix Example link ## 1.0.0 ### **BREAKING** -- `AdwHeaderBar.minimal` is now `AdwHeaderBar.custom` -- Remove `label` parameter from `AdwTextField` -- `ViewSwitcherStyle` is now `ViewSwitcherPolicy` -- `ViewSwitcherStyle.desktop` and `ViewSwitcherStyle.mobile` are also renamed to `ViewSwitcherPolicy.wide` and `ViewSwitcherPolicy.narrow` +* `AdwHeaderBar.minimal` is now `AdwHeaderBar.custom` +* Remove `label` parameter from `AdwTextField` +* `ViewSwitcherStyle` is now `ViewSwitcherPolicy` +* `ViewSwitcherStyle.desktop` and `ViewSwitcherStyle.mobile` are also renamed to `ViewSwitcherPolicy.wide` and `ViewSwitcherPolicy.narrow` ### **Changes to widgets** **ComboRow** -- Dropdown is now scrollable if too many elements are there +* Dropdown is now scrollable if too many elements are there **Flap** -- Renamed `flapController` to `controller` -- Moved most of the things into `FlapStyle` class to simplify its usage in `AdwScaffold` +* Renamed `flapController` to `controller` +* Moved most of the things into `FlapStyle` class to simplify its usage in `AdwScaffold` **HeaderBar** -- Now the `AdwHeaderBar` is not dependent on any package, `windowDecor` object is now optional -- Add `isTransparent` parameter => Makes `AdwHeaderBar`'s background and border color +* Now the `AdwHeaderBar` is not dependent on any package, `windowDecor` object is now optional +* Add `isTransparent` parameter => Makes `AdwHeaderBar`'s background and border color **Popover** -- Revisit popup menu by using `popover_gtk` package (popover package with fade transition) (#35) +* Revisit popup menu by using `popover_gtk` package (popover package with fade transition) (#35) **TextField** -- Add `autofocus` parameter -- Add `prefixIcon` parameter -- Add `onSubmitted` parameter +* Add `autofocus` parameter +* Add `prefixIcon` parameter +* Add `onSubmitted` parameter **ViewSwitcher** -- Add `badge` in `AdwViewSwitcher` +* Add `badge` in `AdwViewSwitcher` **New Widgets** -- `AdwSwitch` => port of `GtkSwitch` from gtk4 -- `AdwAboutWindow` => port of upcoming `AdwAboutWindow` from libadwaita +* `AdwSwitch` => port of `GtkSwitch` from gtk4 +* `AdwAboutWindow` => port of upcoming `AdwAboutWindow` from libadwaita ## 1.0.0-rc.2 **BREAKING** -- `AdwHeaderBarMinimal` is now `AdwHeaderBar.minimal` -- The `start` and `end` parameter of `AdwHeaderBar` are now `List` instead of `Widget` -- `AdwTextButton` is now `AdwButton.flat` -- The `height` and `expanded` properties of ViewSwitcher are now deprecated +* `AdwHeaderBarMinimal` is now `AdwHeaderBar.minimal` +* The `start` and `end` parameter of `AdwHeaderBar` are now `List` instead of `Widget` +* `AdwTextButton` is now `AdwButton.flat` +* The `height` and `expanded` properties of ViewSwitcher are now deprecated **Other Changes** -- Add `AdwComboRow`, `AdwAvatar`, `AdwButton`(`.pill`, `.circular`, `.flat`) -- Improve Header Button -- Update Sidebar Theming -- Update View Switcher theming -- Remove Scroll errors from example app by improving `AdwClamp` +* Add `AdwComboRow`, `AdwAvatar`, `AdwButton`(`.pill`, `.circular`, `.flat`) +* Improve Header Button +* Update Sidebar Theming +* Update View Switcher theming +* Remove Scroll errors from example app by improving `AdwClamp` ## 1.0.0-rc.1 -- Added the following widgets: - - `AdwScaffold` - - `AdwTextField` - - `AdwTextButton` - - `AdwViewStack` - - `WindowResizeListener` -- Fix Window buttons null error -- Update Example -- Update `AdwActionRow` & `AdwStackSidebar` -- Improve `AdwFlap` +* Added the following widgets: + * `AdwScaffold` + * `AdwTextField` + * `AdwTextButton` + * `AdwViewStack` + * `WindowResizeListener` +* Fix Window buttons null error +* Update Example +* Update `AdwActionRow` & `AdwStackSidebar` +* Improve `AdwFlap` ## 1.0.0-rc.0 -- Seperate libadwaita (Widgets) and adwaita (Colors) -- Rename Every widget from GtkSomething to AdwSomething -- Rename GtkContainer to AdwClamp and GtkTwoPane to AdwFlap -- Add `AdwPreferenceGroup` and `AdwActionRow` from libadwaita. -- Add `AdwStackSidebar` which is basically `GtkStackSidebar` -- `AdwHeaderBar` parameter's - - Replace leading with start - - Replace trailing with end - - Replace center with title +* Seperate libadwaita (Widgets) and adwaita (Colors) +* Rename Every widget from GtkSomething to AdwSomething +* Rename GtkContainer to AdwClamp and GtkTwoPane to AdwFlap +* Add `AdwPreferenceGroup` and `AdwActionRow` from libadwaita. +* Add `AdwStackSidebar` which is basically `GtkStackSidebar` +* `AdwHeaderBar` parameter's + * Replace leading with start + * Replace trailing with end + * Replace center with title Older CHANGELOG can be found [here](https://pub.dev/packages/gtk/changelog) diff --git a/README.md b/README.md index 53b1e95..9fafeb8 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ AdwHeaderBar( ## License -`LGPL v3 / GNU LESSER GENERAL PUBLIC LICENSE v3` +`Mozilla Public License 2.0` TLDR; diff --git a/example/pubspec.lock b/example/pubspec.lock index bb8df4a..169aae0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,7 +176,7 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.2" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 7416e35..c4f2097 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.0.1 +version: 1.0.2 homepage: https://github.com/gtk-flutter/libadwaita environment: From c5c17a680bf8b8f21dd624f7a19bedac8fb80ad9 Mon Sep 17 00:00:00 2001 From: sim Date: Sun, 20 Feb 2022 22:02:57 -0800 Subject: [PATCH 09/77] fix(view_switcher_tab): Remove top padding (#59) Fixes overflow on tab / mobile layout when on top --- lib/src/widgets/adw/view_switcher_tab.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/view_switcher_tab.dart b/lib/src/widgets/adw/view_switcher_tab.dart index 17d5ad8..0defee7 100644 --- a/lib/src/widgets/adw/view_switcher_tab.dart +++ b/lib/src/widgets/adw/view_switcher_tab.dart @@ -54,7 +54,10 @@ class AdwViewSwitcherTab extends StatelessWidget { padding: paddingIcon ?? (isDesktop ? const EdgeInsets.only(top: 4, bottom: 4, right: 8) - : const EdgeInsets.only(top: 3.5, right: 4, left: 4)), + : const EdgeInsets.only( + right: 4, + left: 4, + )), child: Icon(data.icon, size: 17), ), if (data.badge != null) From f9add3fc1d9522bc5d47076a4ae3b024646fcae0 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Fri, 18 Feb 2022 00:54:44 +0530 Subject: [PATCH 10/77] Unify AdwHeaderBar Add HeaderBar style Change horizontalTitleGap to 0 for all ListTile's Switch to titlebar_buttons package --- README.md | 6 +- example/example.md | 6 +- example/lib/flap/flap_home_page.dart | 4 +- example/lib/home_page.dart | 4 +- example/lib/pages/lists_page.dart | 4 +- .../view_switcher_home_page.dart | 4 +- example/pubspec.lock | 21 +- example/pubspec.yaml | 3 +- lib/src/widgets/adw/about_window.dart | 13 +- lib/src/widgets/adw/action_row.dart | 1 + lib/src/widgets/adw/combo_row.dart | 1 + lib/src/widgets/adw/header_bar.dart | 305 ++++-------------- lib/src/widgets/adw/new/window_button.dart | 40 +-- pubspec.yaml | 4 + 14 files changed, 127 insertions(+), 289 deletions(-) diff --git a/README.md b/README.md index 9fafeb8..1cec92c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ See the example app in the `example` folder for more info. ### AdwHeaderBar There are 6 types of `AdwHeaderBar` constructor: -If you want to use default adwaita style window icons or icons using window_decorations package then you have to use any one of the following HeaderBar's: +If you want to use default adwaita style window icons or icons using titlebar_buttons package then you have to use any one of the following HeaderBar's: | Widget | Docs | | ------ | ---- | @@ -110,7 +110,7 @@ AdwHeaderBar.nativeshell( ) ``` -#### [**`window_decorations`**](https://pub.dev/packages/window_decorations) +#### [**`titlebar_buttons`**](https://pub.dev/packages/titlebar_buttons) Can be used with - `AdwHeaderBar` - `AdwHeaderBar.bitsdojo` @@ -118,7 +118,7 @@ Can be used with Example: ```dart -import 'package:window_decorations/window_decorations.dart'; +import 'package:titlebar_buttons/titlebar_buttons.dart'; AdwHeaderBar( ... diff --git a/example/example.md b/example/example.md index 0e69b78..bdc5f21 100644 --- a/example/example.md +++ b/example/example.md @@ -124,13 +124,13 @@ class MainWindowState extends WindowState { } ``` -## Minimal [`window_decorations`](https://pub.dev/packages/window_decorations) usage +## Minimal [`titlebar_buttons`](https://pub.dev/packages/titlebar_buttons) usage ```yaml #pubspec.yaml dependencies: adwaita: libadwaita: - window_decorations: + titlebar_buttons: ``` ```dart @@ -139,7 +139,7 @@ dependencies: import 'package:adwaita/adwaita.dart'; import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; -import 'package:window_decorations/window_decorations.dart'; +import 'package:titlebar_buttons/titlebar_buttons.dart'; void main() => runApp(MyApp()); diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index eaf7b2a..bbd44ec 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -48,8 +48,8 @@ class _FlapHomePageState extends State { Widget build(BuildContext context) { return AdwScaffold( flapController: _flapController, - headerbar: (_) => AdwHeaderBar.bitsdojo( - appWindow: appWindow, + headerbar: (_) => AdwHeaderBar( + actions: AdwActions().bitsdojo, start: [ Builder( builder: (context) { diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 002f06a..a3f12bc 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -65,8 +65,8 @@ class _MyHomePageState extends State { return AdwScaffold( flapController: _flapController, - headerbar: (_) => AdwHeaderBar.bitsdojo( - appWindow: appWindow, + headerbar: (_) => AdwHeaderBar( + actions: AdwActions().bitsdojo, start: [ AdwHeaderButton( icon: const Icon(Icons.view_sidebar_outlined, size: 19), diff --git a/example/lib/pages/lists_page.dart b/example/lib/pages/lists_page.dart index 7b877bc..9b2d1b9 100644 --- a/example/lib/pages/lists_page.dart +++ b/example/lib/pages/lists_page.dart @@ -54,8 +54,8 @@ class ListsPage extends StatelessWidget { AdwPreferencesGroup( children: List.generate( 3, - (index) => ListTile( - title: Text('Index $index'), + (index) => AdwActionRow( + title: 'Index $index', ), ), ), diff --git a/example/lib/view_switcher/view_switcher_home_page.dart b/example/lib/view_switcher/view_switcher_home_page.dart index 817555d..862830a 100644 --- a/example/lib/view_switcher/view_switcher_home_page.dart +++ b/example/lib/view_switcher/view_switcher_home_page.dart @@ -17,8 +17,8 @@ class _ViewSwitcherHomePageState extends State { return ValueListenableBuilder( valueListenable: index, builder: (context, int value, child) => AdwScaffold( - headerbar: (viewSwitcher) => AdwHeaderBar.bitsdojo( - appWindow: appWindow, + headerbar: (viewSwitcher) => AdwHeaderBar( + actions: AdwActions().bitsdojo, title: viewSwitcher, ), viewSwitcher: AdwViewSwitcher( diff --git a/example/pubspec.lock b/example/pubspec.lock index 169aae0..684c0d3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -169,7 +169,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" libadwaita: dependency: "direct main" description: @@ -180,9 +180,16 @@ packages: libadwaita_bitsdojo: dependency: "direct main" description: - name: libadwaita_bitsdojo - url: "https://pub.dartlang.org" - source: hosted + path: "../../plugins/libadwaita_bitsdojo" + relative: true + source: path + version: "0.5.1" + libadwaita_core: + dependency: transitive + description: + path: "../../plugins/libadwaita_core" + relative: true + source: path version: "0.5.0" matcher: dependency: transitive @@ -253,7 +260,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_drawing: dependency: transitive description: @@ -349,7 +356,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -449,5 +456,5 @@ packages: source: hosted version: "5.3.1" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.16.0-100.0.dev <3.0.0" flutter: ">=2.5.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c69b1c8..dff1373 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,8 @@ dependencies: sdk: flutter libadwaita: path: ../ - libadwaita_bitsdojo: ">=0.5.0 <1.0.0" + libadwaita_bitsdojo: + path: ../../plugins/libadwaita_bitsdojo dev_dependencies: flutter_test: diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index d5a0db2..4db4302 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; +import 'package:libadwaita_core/libadwaita_core.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -101,11 +102,15 @@ class _AdwAboutWindowState extends State { children: [ widget.headerbar?.call([leading], text) ?? AdwHeaderBar( - start: [leading], - autoPositionWindowButtons: false, - onClose: Navigator.of(context).pop, - isTransparent: true, title: text, + start: [leading], + actions: AdwActions( + onClose: Navigator.of(context).pop, + ), + style: const HeaderBarStyle( + autoPositionWindowButtons: false, + isTransparent: true, + ), ), Flexible( child: SingleChildScrollView( diff --git a/lib/src/widgets/adw/action_row.dart b/lib/src/widgets/adw/action_row.dart index 906bd85..203a0dd 100644 --- a/lib/src/widgets/adw/action_row.dart +++ b/lib/src/widgets/adw/action_row.dart @@ -43,6 +43,7 @@ class AdwActionRow extends StatelessWidget { return ListTile( autofocus: autofocus, enabled: enabled, + horizontalTitleGap: 0, contentPadding: contentPadding, leading: start != null ? SizedBox(height: double.infinity, child: start) diff --git a/lib/src/widgets/adw/combo_row.dart b/lib/src/widgets/adw/combo_row.dart index b72c51b..6f1cbf7 100644 --- a/lib/src/widgets/adw/combo_row.dart +++ b/lib/src/widgets/adw/combo_row.dart @@ -81,6 +81,7 @@ class _AdwComboRowState extends State { autofocus: widget.autofocus, enabled: widget.enabled, contentPadding: widget.contentPadding, + horizontalTitleGap: 0, leading: widget.start, title: Text(widget.title), subtitle: widget.subtitle != null && widget.subtitle!.isNotEmpty diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 7b8f2ae..7cff905 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -3,226 +3,77 @@ import 'dart:io'; import 'package:dbus/dbus.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:gsettings/gsettings.dart'; import 'package:libadwaita/src/utils/colors.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; +import 'package:libadwaita_core/libadwaita_core.dart'; -/// To be used with nativeshell package as it doesn't have this method -Future _maximizeOrRestore(dynamic window) async { - final dynamic flags = await window.getWindowStateFlags(); - await window.setMaximized(!(flags.maximized as bool)); -} - -class AdwHeaderBar extends StatefulWidget { - /// If you use with window_decorations - /// If you don't want that. use AdwHeaderBar.custom - AdwHeaderBar({ - Key? key, - Widget Function( - String name, - dynamic type, - void Function()? onPressed, - )? - windowDecor, - dynamic themeType, - this.onDoubleTap, - this.onHeaderDrag, - this.start = const [], - this.title, - this.end = const [], - this.textStyle, - this.autoPositionWindowButtons = true, +class HeaderBarStyle { + const HeaderBarStyle({ this.isTransparent = false, - this.padding = const EdgeInsets.only(left: 3, right: 5), - this.titlebarSpace = 6, - this.height = 51, - VoidCallback? onMinimize, - VoidCallback? onMaximize, - VoidCallback? onClose, - }) : closeBtn = AdwWindowButton( - onPressed: onClose, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.close, - ), - maximizeBtn = AdwWindowButton( - onPressed: onMaximize, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.maximize, - ), - minimizeBtn = AdwWindowButton( - themeType: themeType, - onPressed: onMinimize, - windowDecor: windowDecor, - buttonType: WindowButtonType.minimize, - ), - super(key: key); - - const AdwHeaderBar.custom({ - Key? key, - this.onDoubleTap, - this.onHeaderDrag, - this.start = const [], - this.title = const SizedBox(), - this.end = const [], this.textStyle, + this.height = 51, this.autoPositionWindowButtons = true, - this.isTransparent = false, this.padding = const EdgeInsets.only(left: 3, right: 5), this.titlebarSpace = 6, - this.height = 51, - this.minimizeBtn, - this.maximizeBtn, - this.closeBtn, - }) : super(key: key); + }); - AdwHeaderBar.bitsdojo({ - Key? key, + /// If true, background color and border color + /// will be transparent + final bool isTransparent; - /// The appWindow object from libadwaita_bitsdojo package - required dynamic appWindow, - Widget Function( - String name, - dynamic type, - void Function()? onPressed, - )? - windowDecor, - dynamic themeType, - this.start = const [], - this.title = const SizedBox(), - this.end = const [], - this.textStyle, - this.autoPositionWindowButtons = true, - this.isTransparent = false, - this.padding = const EdgeInsets.only(left: 3, right: 5), - this.titlebarSpace = 6, - this.height = 51, - bool showMinimize = true, - bool showMaximize = true, - bool showClose = true, - }) : closeBtn = showClose - ? AdwWindowButton( - onPressed: appWindow?.close as void Function()?, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.close, - ) - : null, - maximizeBtn = showMaximize - ? AdwWindowButton( - onPressed: appWindow?.maximize as void Function()?, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.maximize, - ) - : null, - minimizeBtn = showMinimize - ? AdwWindowButton( - onPressed: appWindow?.minimize as void Function()?, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.minimize, - ) - : null, - onHeaderDrag = appWindow?.startDragging as void Function()?, - onDoubleTap = appWindow?.maximizeOrRestore as void Function()?, - super(key: key); + /// Default text style applied to the child widget. + final TextStyle? textStyle; - AdwHeaderBar.customBitsdojo({ - Key? key, + /// The height of the headerbar + final double height; - /// The appWindow object from libadwaita_bitsdojo package - required dynamic appWindow, - this.start = const [], - this.title = const SizedBox(), - this.end = const [], - this.textStyle, - this.autoPositionWindowButtons = true, - this.isTransparent = false, - this.padding = const EdgeInsets.only(left: 3, right: 5), - this.titlebarSpace = 6, - this.height = 51, - Widget Function(VoidCallback onTap)? minimizeBtn, - Widget Function(VoidCallback onTap)? maximizeBtn, - Widget Function(VoidCallback onTap)? closeBtn, - }) : onHeaderDrag = appWindow?.startDragging as void Function()?, - onDoubleTap = appWindow?.maximizeOrRestore as void Function()?, - minimizeBtn = minimizeBtn?.call(appWindow?.minimize as void Function()), - maximizeBtn = - maximizeBtn?.call(appWindow?.maximizeOrRestore as void Function()), - closeBtn = closeBtn?.call(appWindow?.close as void Function()), - super(key: key); + /// Whether to automatically place the window buttons according to + /// the Platform, defaults to true + /// If false then it will follow the general Windows like window buttons + /// placement + final bool autoPositionWindowButtons; - AdwHeaderBar.nativeshell({ - Key? key, + /// The padding inside the headerbar + final EdgeInsets padding; - /// The Window.of(context) object from nativeshell package - required dynamic window, - Widget Function( - String name, - dynamic type, - void Function()? onPressed, - )? - windowDecor, - dynamic themeType, - this.start = const [], - this.title = const SizedBox(), - this.end = const [], - this.textStyle, - this.autoPositionWindowButtons = true, - this.isTransparent = false, - this.padding = const EdgeInsets.only(left: 3, right: 5), - this.titlebarSpace = 6, - this.height = 51, - bool showMinimize = true, - bool showMaximize = true, - bool showClose = true, - }) : onHeaderDrag = window?.performDrag as void Function()?, - onDoubleTap = null, - minimizeBtn = AdwWindowButton( - onPressed: showMinimize ? () => window.setMinimized(true) : null, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.minimize, - ), - maximizeBtn = AdwWindowButton( - onPressed: showMaximize ? () => _maximizeOrRestore(window) : null, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.maximize, - ), - closeBtn = AdwWindowButton( - onPressed: showClose ? window.close as void Function()? : null, - themeType: themeType, - windowDecor: windowDecor, - buttonType: WindowButtonType.close, - ), - super(key: key); + /// The horizontal spacing before or after the window buttons + final double titlebarSpace; +} - AdwHeaderBar.customNativeshell({ +class AdwHeaderBar extends StatefulWidget { + /// If you use with titlebar_buttons + /// If you don't want that. use AdwHeaderBar.custom + AdwHeaderBar({ Key? key, - - /// The Window.of(context) object from nativeshell package - required dynamic window, + this.title, this.start = const [], - this.title = const SizedBox(), this.end = const [], - this.textStyle, - this.autoPositionWindowButtons = true, - this.isTransparent = false, - this.padding = const EdgeInsets.only(left: 3, right: 5), - this.titlebarSpace = 6, - this.height = 51, - Widget Function(VoidCallback onTap)? minimizeBtn, - Widget Function(VoidCallback onTap)? maximizeBtn, - Widget Function(VoidCallback onTap)? closeBtn, - }) : onHeaderDrag = window?.performDrag as void Function()?, - onDoubleTap = (() => _maximizeOrRestore(window)), - minimizeBtn = minimizeBtn?.call(() => window.setMinimized(true)), - maximizeBtn = maximizeBtn?.call(() => _maximizeOrRestore(window)), - closeBtn = closeBtn?.call(window.close as void Function()), + this.style = const HeaderBarStyle(), + required AdwActions actions, + AdwControls? controls, + }) : closeBtn = controls != null + ? controls.closeBtn(actions.onClose) + : AdwWindowButton( + buttonType: WindowButtonType.close, + onPressed: actions.onClose, + ), + maximizeBtn = controls != null + ? controls.maximizeBtn(actions.onMaximize) + : AdwWindowButton( + buttonType: WindowButtonType.maximize, + onPressed: actions.onMaximize, + ), + minimizeBtn = controls != null + ? controls.minimizeBtn(actions.onMinimize) + : AdwWindowButton( + buttonType: WindowButtonType.minimize, + onPressed: actions.onMinimize, + ), + onHeaderDrag = actions.onHeaderDrag, + onDoubleTap = actions.onDoubleTap, super(key: key); /// The leading widget for the headerbar @@ -234,40 +85,21 @@ class AdwHeaderBar extends StatefulWidget { /// The trailing widget for the headerbar final List end; - /// If true, background color and border color - /// will be transparent - final bool isTransparent; - - /// Default text style applied to the child widget. - final TextStyle? textStyle; - final Widget? minimizeBtn; final Widget? maximizeBtn; final Widget? closeBtn; - /// The height of the headerbar - final double height; - - /// Whether to automatically place the window buttons according to - /// the Platform, defaults to true - /// If false then it will follow the general Windows like window buttons - /// placement - final bool autoPositionWindowButtons; - - /// The padding inside the headerbar - final EdgeInsets padding; - - /// The horizontal spacing before or after the window buttons - final double titlebarSpace; - /// Called when headerbar is dragged final VoidCallback? onHeaderDrag; /// Called when headerbar is double tapped final VoidCallback? onDoubleTap; + /// Default style applied to this [AdwHeaderBar] widget. + final HeaderBarStyle style; + @override State createState() => _AdwHeaderBarState(); } @@ -278,16 +110,19 @@ class _AdwHeaderBarState extends State { widget.minimizeBtn != null || widget.maximizeBtn != null; - late ValueNotifier> seperator = ValueNotifier([ - '', - 'minimize,maximize,close', - ]); + late ValueNotifier> seperator = + !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) + ? ValueNotifier>([ + '', + 'minimize,maximize,close', + ]) + : ValueNotifier>(['', '']); @override void initState() { super.initState(); - if (widget.autoPositionWindowButtons) { + if (widget.style.autoPositionWindowButtons) { void updateSep(String order) { if (!mounted) return; seperator.value = order.split(':'); @@ -308,8 +143,6 @@ class _AdwHeaderBarState extends State { updateSep(buttonLayout.value); } }); - } else { - updateSep(':'); } } } @@ -331,17 +164,17 @@ class _AdwHeaderBarState extends State { alignment: Alignment.topCenter, child: Container( decoration: BoxDecoration( - color: !widget.isTransparent + color: !widget.style.isTransparent ? Theme.of(context).appBarTheme.backgroundColor : null, - border: !widget.isTransparent + border: !widget.style.isTransparent ? Border( top: BorderSide(color: Theme.of(context).backgroundColor), bottom: BorderSide(color: context.borderColor), ) : null, ), - height: widget.height, + height: widget.style.height, width: double.infinity, child: Stack( children: [ @@ -355,13 +188,13 @@ class _AdwHeaderBarState extends State { style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, - ).merge(widget.textStyle), + ).merge(widget.style.textStyle), child: NavigationToolbar( leading: Row( mainAxisSize: MainAxisSize.min, children: [ if (hasWindowControls && sep[0].split(',').isNotEmpty) - SizedBox(width: widget.titlebarSpace), + SizedBox(width: widget.style.titlebarSpace), for (var i in sep[0].split(',')) if (windowButtons[i] != null) windowButtons[i]!, ...widget.start @@ -373,10 +206,10 @@ class _AdwHeaderBarState extends State { children: [ ...widget.end, if (hasWindowControls && sep[1].split(',').isNotEmpty) - SizedBox(width: widget.titlebarSpace), + SizedBox(width: widget.style.titlebarSpace), for (var i in sep[1].split(',')) if (windowButtons[i] != null) windowButtons[i]!, - SizedBox(width: widget.titlebarSpace), + SizedBox(width: widget.style.titlebarSpace), ], ), ), diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index 6599c40..46ccacb 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -10,20 +10,8 @@ class AdwWindowButton extends StatelessWidget { Key? key, required this.buttonType, required this.onPressed, - this.themeType, - this.windowDecor, }) : super(key: key); - /// The ThemeType from the window_decorations package, nullable - final dynamic themeType; - - /// The windowDecor object from window_decorations package - final Widget Function( - String name, - dynamic type, - void Function()? windowDecor, - )? windowDecor; - /// Executed when this button is pressed final VoidCallback? onPressed; @@ -33,21 +21,19 @@ class AdwWindowButton extends StatelessWidget { @override Widget build(BuildContext context) { return onPressed != null - ? windowDecor != null - ? windowDecor!(buttonType.name, themeType, onPressed) - : AdwButton.circular( - size: 24, - margin: const EdgeInsets.all(6), - onPressed: onPressed, - child: Center( - child: SvgPicture.asset( - 'packages/libadwaita/assets/icons/${buttonType.name}.svg', - width: 16, - height: 16, - color: context.textColor, - ), - ), - ) + ? AdwButton.circular( + size: 24, + margin: const EdgeInsets.all(6), + onPressed: onPressed, + child: Center( + child: SvgPicture.asset( + 'packages/libadwaita/assets/icons/${buttonType.name}.svg', + width: 16, + height: 16, + color: context.textColor, + ), + ), + ) : const SizedBox(); } } diff --git a/pubspec.yaml b/pubspec.yaml index c4f2097..2545429 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,6 +3,8 @@ description: Libadwaita's widgets for Flutter. Following Gnome HIG and available version: 1.0.2 homepage: https://github.com/gtk-flutter/libadwaita +publish: none + environment: sdk: ">=2.12.0 <3.0.0" flutter: ">=1.17.0" @@ -21,6 +23,8 @@ dependencies: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" + libadwaita_core: + path: ../plugins/libadwaita_core package_info_plus: ">=1.3.0 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" url_launcher: ">=6.0.18 < 7.0.0" From 7e2e2960577219c2814d922b481f1bde2ab48f50 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Fri, 18 Feb 2022 17:58:23 +0530 Subject: [PATCH 11/77] Add horizontal_title_gap property Bump version to 1.2.0 --- README.md | 23 +------------- example/pubspec.lock | 48 ++++++++++++++++------------- example/pubspec.yaml | 17 ++++++++-- lib/src/widgets/adw/action_row.dart | 6 +++- lib/src/widgets/adw/combo_row.dart | 6 +++- lib/src/widgets/adw/header_bar.dart | 6 ++-- pubspec.yaml | 7 ++--- 7 files changed, 58 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 1cec92c..4cce9b8 100644 --- a/README.md +++ b/README.md @@ -25,28 +25,7 @@ Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platf - If you want custom titlebar then you can follow the steps for that on [`libadwaita_bitsdojo`](https://pub.dev/packages/libadwaita_bitsdojo) package. - Here is the list of widgets imported from libadwaita library : [widgets.dart](https://github.com/gtk-flutter/libadwaita/blob/main/lib/src/widgets/widgets.dart). -See the example app in the `example` folder for more info. - -## Documentation - -### AdwHeaderBar -There are 6 types of `AdwHeaderBar` constructor: - -If you want to use default adwaita style window icons or icons using titlebar_buttons package then you have to use any one of the following HeaderBar's: - -| Widget | Docs | -| ------ | ---- | -| `AdwHeaderBar` | Default HeaderBar | -| `AdwHeaderBar.bitsdojo` | HeaderBar to be used with [`bitsdojo`](#libadwaita_bitsdojo) package | -| `AdwHeaderBar.nativeshell` | HeaderBar to be used with [`nativeshell`](#nativeshell) package | - -If you want to have a custom icon for window button then you have to use any one of the following HeaderBar's: - -| Widget | Docs | -| ------ | ---- | -| `AdwHeaderBar.custom` | HeaderBar with custom icon | -| `AdwHeaderBar.customBitsdojo` | HeaderBar to be used with [`bitsdojo`](#libadwaita_bitsdojo) package with custom icon | -| `AdwHeaderBar.customNativeshell` | HeaderBar to be used with [`nativeshell`](#nativeshell) package with custom icon | +See the example app in the [`example`](example) folder for more info. ## Relavant Links - [libadwaita documentation](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/index.html#classes) diff --git a/example/pubspec.lock b/example/pubspec.lock index 684c0d3..e08bef2 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -23,18 +23,22 @@ packages: source: hosted version: "2.8.2" bitsdojo_window_linux: - dependency: transitive + dependency: "direct overridden" description: - name: bitsdojo_window_linux - url: "https://pub.dartlang.org" - source: hosted + path: bitsdojo_window_linux + ref: HEAD + resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" + url: "https://github.com/prateekmedia/bitsdojo_window.git" + source: git version: "0.1.1" bitsdojo_window_macos: - dependency: transitive + dependency: "direct overridden" description: - name: bitsdojo_window_macos - url: "https://pub.dartlang.org" - source: hosted + path: bitsdojo_window_macos + ref: HEAD + resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" + url: "https://github.com/prateekmedia/bitsdojo_window.git" + source: git version: "0.1.0" bitsdojo_window_platform_interface: dependency: transitive @@ -44,11 +48,13 @@ packages: source: hosted version: "0.1.0" bitsdojo_window_windows: - dependency: transitive + dependency: "direct overridden" description: - name: bitsdojo_window_windows - url: "https://pub.dartlang.org" - source: hosted + path: bitsdojo_window_windows + ref: HEAD + resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" + url: "https://github.com/prateekmedia/bitsdojo_window.git" + source: git version: "0.1.0" boolean_selector: dependency: transitive @@ -176,21 +182,21 @@ packages: path: ".." relative: true source: path - version: "1.0.2" + version: "1.2.0" libadwaita_bitsdojo: dependency: "direct main" description: - path: "../../plugins/libadwaita_bitsdojo" - relative: true - source: path - version: "0.5.1" + name: libadwaita_bitsdojo + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.3" libadwaita_core: dependency: transitive description: - path: "../../plugins/libadwaita_core" - relative: true - source: path - version: "0.5.0" + name: libadwaita_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.1" matcher: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index dff1373..cb764de 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,8 +14,21 @@ dependencies: sdk: flutter libadwaita: path: ../ - libadwaita_bitsdojo: - path: ../../plugins/libadwaita_bitsdojo + libadwaita_bitsdojo: ^0.5.3 + +dependency_overrides: + bitsdojo_window_linux: + git: + url: https://github.com/prateekmedia/bitsdojo_window.git + path: bitsdojo_window_linux + bitsdojo_window_macos: + git: + url: https://github.com/prateekmedia/bitsdojo_window.git + path: bitsdojo_window_macos + bitsdojo_window_windows: + git: + url: https://github.com/prateekmedia/bitsdojo_window.git + path: bitsdojo_window_windows dev_dependencies: flutter_test: diff --git a/lib/src/widgets/adw/action_row.dart b/lib/src/widgets/adw/action_row.dart index 203a0dd..73312a2 100644 --- a/lib/src/widgets/adw/action_row.dart +++ b/lib/src/widgets/adw/action_row.dart @@ -8,6 +8,7 @@ class AdwActionRow extends StatelessWidget { required this.title, this.onActivated, this.subtitle, + this.horizontalTitleGap = 8, this.autofocus = false, this.enabled = true, this.contentPadding, @@ -35,6 +36,9 @@ class AdwActionRow extends StatelessWidget { /// Whether this action row is enabled or not, defaults to true final bool enabled; + /// The horizontal gap between the titles and the leading/trailing widgets. + final double horizontalTitleGap; + /// The padding b/w content of this Action row final EdgeInsets? contentPadding; @@ -43,7 +47,7 @@ class AdwActionRow extends StatelessWidget { return ListTile( autofocus: autofocus, enabled: enabled, - horizontalTitleGap: 0, + horizontalTitleGap: horizontalTitleGap, contentPadding: contentPadding, leading: start != null ? SizedBox(height: double.infinity, child: start) diff --git a/lib/src/widgets/adw/combo_row.dart b/lib/src/widgets/adw/combo_row.dart index 6f1cbf7..a5d7aaf 100644 --- a/lib/src/widgets/adw/combo_row.dart +++ b/lib/src/widgets/adw/combo_row.dart @@ -13,6 +13,7 @@ class AdwComboRow extends StatefulWidget { required this.onSelected, required this.title, this.subtitle, + this.horizontalTitleGap = 8, this.autofocus = false, this.enabled = true, this.contentPadding, @@ -46,6 +47,9 @@ class AdwComboRow extends StatefulWidget { /// Whether this combo row is enabled or not, defaults to true final bool enabled; + /// The horizontal gap between the titles and the leading/trailing widgets. + final double horizontalTitleGap; + /// The padding b/w content of this Combo row final EdgeInsets? contentPadding; @@ -81,7 +85,7 @@ class _AdwComboRowState extends State { autofocus: widget.autofocus, enabled: widget.enabled, contentPadding: widget.contentPadding, - horizontalTitleGap: 0, + horizontalTitleGap: widget.horizontalTitleGap, leading: widget.start, title: Text(widget.title), subtitle: widget.subtitle != null && widget.subtitle!.isNotEmpty diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 7cff905..9b219b4 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -55,19 +55,19 @@ class AdwHeaderBar extends StatefulWidget { required AdwActions actions, AdwControls? controls, }) : closeBtn = controls != null - ? controls.closeBtn(actions.onClose) + ? controls.closeBtn?.call(actions.onClose) : AdwWindowButton( buttonType: WindowButtonType.close, onPressed: actions.onClose, ), maximizeBtn = controls != null - ? controls.maximizeBtn(actions.onMaximize) + ? controls.maximizeBtn?.call(actions.onMaximize) : AdwWindowButton( buttonType: WindowButtonType.maximize, onPressed: actions.onMaximize, ), minimizeBtn = controls != null - ? controls.minimizeBtn(actions.onMinimize) + ? controls.minimizeBtn?.call(actions.onMinimize) : AdwWindowButton( buttonType: WindowButtonType.minimize, onPressed: actions.onMinimize, diff --git a/pubspec.yaml b/pubspec.yaml index 2545429..a5afcfd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,8 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.0.2 +version: 1.2.0 homepage: https://github.com/gtk-flutter/libadwaita -publish: none - environment: sdk: ">=2.12.0 <3.0.0" flutter: ">=1.17.0" @@ -23,8 +21,7 @@ dependencies: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" - libadwaita_core: - path: ../plugins/libadwaita_core + libadwaita_core: ">=0.5.1 < 2.0.0" package_info_plus: ">=1.3.0 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" url_launcher: ">=6.0.18 < 7.0.0" From a7d358aa79ce9755ba54ab0fc5c3e41f52bab86f Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 01:51:01 +0530 Subject: [PATCH 12/77] Add flapOptions property Deprecate headerbar for scaffold and about window Init Translations --- example/lib/flap/flap_home_page.dart | 38 +++---- example/lib/home_page.dart | 156 +++++++++++++------------- lib/src/translations/app_en.arb | 6 + lib/src/widgets/adw/about_window.dart | 37 ++++-- lib/src/widgets/adw/flap.dart | 40 ++++--- lib/src/widgets/adw/header_bar.dart | 2 - lib/src/widgets/adw/new/scaffold.dart | 38 ++++++- 7 files changed, 186 insertions(+), 131 deletions(-) create mode 100644 lib/src/translations/app_en.arb diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index bbd44ec..ee4413f 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -48,25 +48,23 @@ class _FlapHomePageState extends State { Widget build(BuildContext context) { return AdwScaffold( flapController: _flapController, - headerbar: (_) => AdwHeaderBar( - actions: AdwActions().bitsdojo, - start: [ - Builder( - builder: (context) { - return AdwHeaderButton( - icon: const Icon(Icons.view_sidebar, size: 15), - isActive: _flapController.isOpen, - onPressed: () => _flapController.toggle(), - ); - }, - ), - AdwHeaderButton( - icon: const Icon(Icons.nightlight_round, size: 15), - onPressed: changeTheme, - ), - ], - title: const Text('AdwFlap Demo'), - ), + actions: AdwActions().bitsdojo, + start: [ + Builder( + builder: (context) { + return AdwHeaderButton( + icon: const Icon(Icons.view_sidebar, size: 15), + isActive: _flapController.isOpen, + onPressed: () => _flapController.toggle(), + ); + }, + ), + AdwHeaderButton( + icon: const Icon(Icons.nightlight_round, size: 15), + onPressed: changeTheme, + ), + ], + title: const Text('AdwFlap Demo'), flap: (isDrawer) => AdwSidebar( currentIndex: _currentIndex, isDrawer: isDrawer, @@ -85,6 +83,8 @@ class _FlapHomePageState extends State { ), flapStyle: FlapStyle( locked: locked, + ), + flapOptions: FlapOptions( flapPosition: flapPosition, foldPolicy: FoldPolicy.values[selectionIndex], ), diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index a3f12bc..913e921 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -65,92 +65,90 @@ class _MyHomePageState extends State { return AdwScaffold( flapController: _flapController, - headerbar: (_) => AdwHeaderBar( - actions: AdwActions().bitsdojo, - start: [ - AdwHeaderButton( - icon: const Icon(Icons.view_sidebar_outlined, size: 19), - isActive: _flapController.isOpen, - onPressed: () => _flapController.toggle(), - ), - AdwHeaderButton( - icon: const Icon(Icons.nightlight_round, size: 15), - onPressed: changeTheme, - ), - ], - title: const Text('Libadwaita Demo'), - end: [ - AdwPopupMenu( - body: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - AdwButton.flat( - onPressed: () { - counter.value = 0; - Navigator.of(context).pop(); - }, - padding: AdwButton.defaultButtonPadding.copyWith( - top: 10, - bottom: 10, - ), - child: const Text( - 'Reset Counter', - style: TextStyle(fontSize: 15), - ), + actions: AdwActions().bitsdojo, + start: [ + AdwHeaderButton( + icon: const Icon(Icons.view_sidebar_outlined, size: 19), + isActive: _flapController.isOpen, + onPressed: () => _flapController.toggle(), + ), + AdwHeaderButton( + icon: const Icon(Icons.nightlight_round, size: 15), + onPressed: changeTheme, + ), + ], + title: const Text('Libadwaita Demo'), + end: [ + AdwPopupMenu( + body: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + AdwButton.flat( + onPressed: () { + counter.value = 0; + Navigator.of(context).pop(); + }, + padding: AdwButton.defaultButtonPadding.copyWith( + top: 10, + bottom: 10, ), - const Divider(), - AdwButton.flat( - padding: AdwButton.defaultButtonPadding.copyWith( - top: 10, - bottom: 10, - ), - child: const Text( - 'Preferences', - style: TextStyle(fontSize: 15), - ), + child: const Text( + 'Reset Counter', + style: TextStyle(fontSize: 15), ), - AdwButton.flat( - padding: AdwButton.defaultButtonPadding.copyWith( - top: 10, - bottom: 10, - ), - onPressed: () => showDialog( - context: context, - builder: (ctx) => AdwAboutWindow( - issueTrackerLink: - 'https://github.com/gtk-flutter/libadwaita/issues', - appIcon: Image.asset('assets/logo.png'), - credits: [ - AdwPreferencesGroup.credits( - title: 'Developers', - children: developers.entries - .map( - (e) => AdwActionRow( - title: e.key, - onActivated: () => - launch('https://github.com/${e.value}'), - ), - ) - .toList(), - ), - ], - copyright: 'Copyright 2021-2022 Gtk-Flutter Developers', - license: const Text( - 'GNU LGPL-3.0, This program comes with no warranty.', + ), + const Divider(), + AdwButton.flat( + padding: AdwButton.defaultButtonPadding.copyWith( + top: 10, + bottom: 10, + ), + child: const Text( + 'Preferences', + style: TextStyle(fontSize: 15), + ), + ), + AdwButton.flat( + padding: AdwButton.defaultButtonPadding.copyWith( + top: 10, + bottom: 10, + ), + onPressed: () => showDialog( + context: context, + builder: (ctx) => AdwAboutWindow( + issueTrackerLink: + 'https://github.com/gtk-flutter/libadwaita/issues', + appIcon: Image.asset('assets/logo.png'), + credits: [ + AdwPreferencesGroup.credits( + title: 'Developers', + children: developers.entries + .map( + (e) => AdwActionRow( + title: e.key, + onActivated: () => + launch('https://github.com/${e.value}'), + ), + ) + .toList(), ), + ], + copyright: 'Copyright 2021-2022 Gtk-Flutter Developers', + license: const Text( + 'GNU LGPL-3.0, This program comes with no warranty.', ), ), - child: const Text( - 'About this Demo', - style: TextStyle(fontSize: 15), - ), ), - ], - ), + child: const Text( + 'About this Demo', + style: TextStyle(fontSize: 15), + ), + ), + ], ), - ], - ), + ), + ], flap: (isDrawer) => AdwSidebar( currentIndex: _currentIndex, isDrawer: isDrawer, diff --git a/lib/src/translations/app_en.arb b/lib/src/translations/app_en.arb new file mode 100644 index 0000000..1520722 --- /dev/null +++ b/lib/src/translations/app_en.arb @@ -0,0 +1,6 @@ +{ + "version": "Version", + "credits": "Credits", + "legal": "Legal", + "reportAnIssue": "Report an issue" +} \ No newline at end of file diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index 4db4302..da2b07b 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -25,15 +25,26 @@ class AdwAboutWindow extends StatefulWidget { this.nextPageIcon, this.launchEndIcon, this.width = 360, - this.headerbar, + @Deprecated('headerbar is deprecated, use the properties separately') + AdwHeaderBar? Function(Widget?)? headerbar, + this.headerBarStyle, + this.start, + this.end, + this.actions, + this.controls, this.copyright, this.issueTrackerLink, this.license, this.credits, }) : super(key: key); - /// The HeaderBar for About Window, defaults to transparent [AdwHeaderBar] - final AdwHeaderBar Function(List leading, Widget title)? headerbar; + final HeaderBarStyle? headerBarStyle; + + final List? start; + final List? end; + + final AdwActions? actions; + final AdwControls? controls; /// The width of the about window dialog final double width; @@ -100,18 +111,24 @@ class _AdwAboutWindowState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - widget.headerbar?.call([leading], text) ?? - AdwHeaderBar( - title: text, - start: [leading], - actions: AdwActions( + AdwHeaderBar( + title: text, + start: [ + leading, + if (widget.start != null) ...widget.start!, + ], + end: widget.end ?? [], + actions: widget.actions ?? + AdwActions( onClose: Navigator.of(context).pop, ), - style: const HeaderBarStyle( + controls: widget.controls, + style: widget.headerBarStyle ?? + const HeaderBarStyle( autoPositionWindowButtons: false, isTransparent: true, ), - ), + ), Flexible( child: SingleChildScrollView( padding: commonPadding, diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index f8b9011..5678045 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -7,24 +7,29 @@ import 'package:libadwaita/src/utils/colors.dart'; enum FoldPolicy { never, always, auto } enum FlapPosition { start, end } -class FlapStyle { - FlapStyle({ - this.seperator, - this.locked = false, - this.breakpoint = 900, - this.flapWidth = 270.0, +class FlapOptions { + const FlapOptions({ this.foldPolicy = FoldPolicy.auto, this.flapPosition = FlapPosition.start, }); - /// The seperator b/w flap and the content - final Widget? seperator; - /// The FoldPolicy of this flap, defaults to auto final FoldPolicy foldPolicy; /// The FlapPosition of this flap, defaults to start final FlapPosition flapPosition; +} + +class FlapStyle { + const FlapStyle({ + this.seperator, + this.locked = false, + this.breakpoint = 900, + this.flapWidth = 270.0, + }); + + /// The seperator b/w flap and the content + final Widget? seperator; /// The breakpoint for small devices final double breakpoint; @@ -40,13 +45,15 @@ class FlapStyle { } class AdwFlap extends StatefulWidget { - AdwFlap({ + const AdwFlap({ Key? key, required this.flap, required this.child, this.controller, FlapStyle? style, - }) : style = style ?? FlapStyle(), + FlapOptions? options, + }) : style = style ?? const FlapStyle(), + options = options ?? const FlapOptions(), super(key: key); /// The flap widget itself, Mainly is a `AdwSidebar` instance @@ -58,6 +65,9 @@ class AdwFlap extends StatefulWidget { /// The style of this flap final FlapStyle style; + /// The options for this flap + final FlapOptions options; + /// The controller for this flap final FlapController? controller; @@ -89,8 +99,8 @@ class _AdwFlapState extends State { void updateFlapData() { _controller - ..policy = widget.style.foldPolicy - ..position = widget.style.flapPosition + ..policy = widget.options.foldPolicy + ..position = widget.options.flapPosition ..locked = widget.style.locked; } @@ -131,7 +141,7 @@ class _AdwFlapState extends State { color: context.borderColor, ); - final widgets = widget.style.flapPosition == FlapPosition.start + final widgets = widget.options.flapPosition == FlapPosition.start ? [flap, seperator, content] : [content, seperator, flap]; @@ -147,7 +157,7 @@ class _AdwFlapState extends State { final isMobile = size.width < widget.style.breakpoint; _controller.updateModalState(context, state: isMobile); - switch (widget.style.foldPolicy) { + switch (widget.options.foldPolicy) { case FoldPolicy.never: case FoldPolicy.always: break; diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 9b219b4..5cc3299 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -44,8 +44,6 @@ class HeaderBarStyle { } class AdwHeaderBar extends StatefulWidget { - /// If you use with titlebar_buttons - /// If you don't want that. use AdwHeaderBar.custom AdwHeaderBar({ Key? key, this.title, diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 555cdca..fb8145b 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/src/controllers/flap_controller.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; +import 'package:libadwaita_core/libadwaita_core.dart'; class AdwScaffold extends StatefulWidget { const AdwScaffold({ @@ -8,10 +9,22 @@ class AdwScaffold extends StatefulWidget { required this.body, this.flap, this.flapStyle, + this.flapOptions, this.flapController, - this.headerbar, + @Deprecated('headerbar is deprecated, use the properties separately') + AdwHeaderBar? Function(Widget?)? headerbar, this.viewSwitcher, - }) : super(key: key); + this.headerBarStyle, + this.start, + this.title, + this.end, + this.actions, + this.controls, + }) : assert( + viewSwitcher != null && actions != null, + 'If viewSwitcher is there, then actions are also needed to be' + ' provided!'), + super(key: key); final Widget body; @@ -20,8 +33,16 @@ class AdwScaffold extends StatefulWidget { final FlapController? flapController; final FlapStyle? flapStyle; + final FlapOptions? flapOptions; - final Widget? Function(Widget? viewSwitcher)? headerbar; + final HeaderBarStyle? headerBarStyle; + + final List? start; + final Widget? title; + final List? end; + + final AdwActions? actions; + final AdwControls? controls; final Widget? viewSwitcher; @@ -41,8 +62,6 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { final isMobile = MediaQuery.of(context).size.width <= 600; - final headerbar = - widget.headerbar?.call(!isMobile ? widget.viewSwitcher : null); final flap = widget.flap != null ? SizedBox( width: 200, @@ -53,7 +72,14 @@ class _AdwScaffoldState extends State { return SafeArea( child: Column( children: [ - if (headerbar != null) headerbar, + AdwHeaderBar( + actions: widget.actions!, + controls: widget.controls, + title: widget.viewSwitcher ?? widget.title, + end: widget.end ?? [], + start: widget.start ?? [], + style: widget.headerBarStyle ?? const HeaderBarStyle(), + ), Expanded( child: Scaffold( drawerEnableOpenDragGesture: _flapController From 40ff1a9865cfa44e591441c919d2d474527697d9 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 01:51:40 +0530 Subject: [PATCH 13/77] Fix Warnings --- example/lib/view_switcher/view_switcher_home_page.dart | 5 +---- lib/src/widgets/adw/new/scaffold.dart | 7 ++++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example/lib/view_switcher/view_switcher_home_page.dart b/example/lib/view_switcher/view_switcher_home_page.dart index 862830a..55f3e6f 100644 --- a/example/lib/view_switcher/view_switcher_home_page.dart +++ b/example/lib/view_switcher/view_switcher_home_page.dart @@ -17,10 +17,7 @@ class _ViewSwitcherHomePageState extends State { return ValueListenableBuilder( valueListenable: index, builder: (context, int value, child) => AdwScaffold( - headerbar: (viewSwitcher) => AdwHeaderBar( - actions: AdwActions().bitsdojo, - title: viewSwitcher, - ), + actions: AdwActions().bitsdojo, viewSwitcher: AdwViewSwitcher( tabs: const [ ViewSwitcherData( diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index fb8145b..cb22993 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -21,9 +21,10 @@ class AdwScaffold extends StatefulWidget { this.actions, this.controls, }) : assert( - viewSwitcher != null && actions != null, - 'If viewSwitcher is there, then actions are also needed to be' - ' provided!'), + viewSwitcher != null && actions != null, + 'If viewSwitcher is there, then actions are also needed to be' + ' provided!', + ), super(key: key); final Widget body; From ed568a3f87b21ae0c3175931f5d146234dc30bce Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 02:00:13 +0530 Subject: [PATCH 14/77] Link to external examples --- example/example.md | 181 +++------------------------------------------ 1 file changed, 10 insertions(+), 171 deletions(-) diff --git a/example/example.md b/example/example.md index bdc5f21..cfc2839 100644 --- a/example/example.md +++ b/example/example.md @@ -3,178 +3,17 @@ ## Demo App [Here](https://github.com/gtk-flutter/libadwaita/tree/main/example) is a demo app made with libadwaita package. -## Minimal [`libadwaita_bitsdojo`](https://pub.dev/packages/libadwaita_bitsdojo) usage -```yaml -#pubspec.yaml -dependencies: - adwaita: - libadwaita: - libadwaita_bitsdojo: -``` +## Search Bar example +[Link](https://pub.dev/packages/libadwaita_searchbar/example) -```dart -// main.dart +## Search Bar with Auto complete example +[Link](https://pub.dev/packages/libadwaita_searchbar_ac/example) -import 'package:adwaita/adwaita.dart'; -import 'package:flutter/material.dart'; -import 'package:libadwaita/libadwaita.dart'; -import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart'; +## [`bitsdojo_window`](https://pub.dev/packages/bitsdojo_window) example +[Link](https://pub.dev/packages/libadwaita_bitsdojo/example) -void main() => runApp(MyApp()); +## [`nativeshell`](https://pub.dev/packages/nativeshell) example +[Link](https://pub.dev/packages/libadwaita_nativeshell/example) -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - theme: AdwaitaThemeData.light(), - darkTheme: AdwaitaThemeData.dark(), - home: MyHomePage(), - ); - } -} - -class MyHomePage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return AdwScaffold( - headerbar: (_) => AdwHeaderBar.bitsdojo( - appWindow: appWindow, - start: const [ - AdwHeaderButton( - icon: Icon(Icons.nightlight_round, size: 15), - ), - ], - title: const Text('Bitsdojo Window'), - ), - body: const Center( - child: Text('Welcome to Bitsdojo Window Example!'), - ), - ); - } -} -``` - -## Minimal [`nativeshell`](https://pub.dev/packages/nativeshell) usage -```yaml -#pubspec.yaml -dependencies: - adwaita: - libadwaita: - nativeshell: -``` - -```dart -// main.dart - -import 'package:adwaita/adwaita.dart'; -import 'package:flutter/material.dart'; -import 'package:libadwaita/libadwaita.dart'; -import 'package:nativeshell/nativeshell.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - theme: AdwaitaThemeData.light(), - darkTheme: AdwaitaThemeData.dark(), - home: WindowWidget( - onCreateState: (dynamic _) { - WindowState? state; - return state ??= MainWindowState(); - }, - ), - ); - } -} - -class MainWindowState extends WindowState { - @override - Future initializeWindow(Size contentSize) async { - await window.setStyle(WindowStyle(frame: WindowFrame.noTitle)); - await window.show(); - } - - @override - WindowSizingMode get windowSizingMode => - WindowSizingMode.atLeastIntrinsicSize; - - @override - Widget build(BuildContext context) { - return WindowLayoutProbe( - child: AdwScaffold( - headerbar: (_) => AdwHeaderBar.nativeshell( - window: window, - start: const [ - AdwHeaderButton( - icon: Icon(Icons.nightlight_round, size: 15), - ), - ], - title: const Text('Nativeshell'), - ), - body: const Center( - child: Text('Welcome to NativeShell Example!'), - ), - ), - ); - } -} -``` - -## Minimal [`titlebar_buttons`](https://pub.dev/packages/titlebar_buttons) usage -```yaml -#pubspec.yaml -dependencies: - adwaita: - libadwaita: - titlebar_buttons: -``` - -```dart -// main.dart - -import 'package:adwaita/adwaita.dart'; -import 'package:flutter/material.dart'; -import 'package:libadwaita/libadwaita.dart'; -import 'package:titlebar_buttons/titlebar_buttons.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - theme: AdwaitaThemeData.light(), - darkTheme: AdwaitaThemeData.dark(), - home: MyHomePage(), - ); - } -} - -class MyHomePage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return AdwScaffold( - headerbar: (_) => AdwHeaderBar( - windowDecor: windowDecor, - onClose: () {}, - onMaximize: () {}, - onMinimize: () {}, - start: const [ - AdwHeaderButton( - icon: Icon(Icons.nightlight_round, size: 15), - ), - ], - title: const Text('Window Decorations'), - ), - body: const Center( - child: Text('Welcome to Window Decorations Example!'), - ), - ); - } -} -``` +## [`titlebar_buttons`](https://pub.dev/packages/titlebar_buttons) example +[Link](https://pub.dev/packages/libadwaita_titlebar_buttons/example) \ No newline at end of file From 06ebf768f507356f1b424ba8cdb948b23de1f397 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 02:17:59 +0530 Subject: [PATCH 15/77] Update CHANGELOG Rename seperator to separator Fix Lint error --- CHANGELOG.md | 65 ++++++++++++++++++++++++++ example/example.md | 2 +- lib/src/widgets/adw/flap.dart | 12 ++--- lib/src/widgets/adw/header_bar.dart | 6 +-- lib/src/widgets/gtk/stack_sidebar.dart | 6 +-- 5 files changed, 78 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d16da..e0cb905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,70 @@ # Changelog +## 1.2.0 + +### BREAKING + +* `flapPolicy` and `flapPosition` are now removed from `FlapStyle` use `FlapOptions` and options parameter of `AdwFlap`. + * Previously + ```dart + AdwFlap( + style: FlapStyle( + width: ..., + breakpoint: ..., + flapPosition: ..., + flapPolicy: ..., + ) + ) + ``` + * Now + ```dart + AdwFlap( + style: FlapStyle( + width: ..., + breakpoint: ..., + ), + options: FlapOptions( + flapPosition: ..., + flapPolicy: ..., + ) + ) + ``` +* Fix spelling by renaming `seperator` to `separator` everywhere + + +### DEPRECATED + +* `headerbar` parameter from `AdwScaffold` and `AdwAboutWindow` is deprecated + * Previously + ```dart + AdwScaffold( + headerbar: (_) => AdwHeaderBar( + start: start, + end: end, + title: title, + ) + ) + ``` + * Now + ```dart + AdwScaffold( + start: start, + end: end, + title: title, + ) + ``` + +### ADDED + +* `actions` and `controls` parameter for `AdwHeaderBar` +* Add ability to change `horizontalTitleGap` for `AdwActionRow` and `AdwComboRow` +* Init Translations + +### CHANGED +* Changed default value of `horizontalTitleGap` to 8 +* Switch to `titlebar_buttons` package as `window_decorations` is deprecated +* Link to external examples in example.md + ## 1.0.2 * Fix License in README diff --git a/example/example.md b/example/example.md index cfc2839..315933b 100644 --- a/example/example.md +++ b/example/example.md @@ -6,7 +6,7 @@ ## Search Bar example [Link](https://pub.dev/packages/libadwaita_searchbar/example) -## Search Bar with Auto complete example +## Search Bar with autocomplete example [Link](https://pub.dev/packages/libadwaita_searchbar_ac/example) ## [`bitsdojo_window`](https://pub.dev/packages/bitsdojo_window) example diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 5678045..36525d4 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -22,14 +22,14 @@ class FlapOptions { class FlapStyle { const FlapStyle({ - this.seperator, + this.separator, this.locked = false, this.breakpoint = 900, this.flapWidth = 270.0, }); - /// The seperator b/w flap and the content - final Widget? seperator; + /// The separator b/w flap and the content + final Widget? separator; /// The breakpoint for small devices final double breakpoint; @@ -135,15 +135,15 @@ class _AdwFlapState extends State { ), ); - final seperator = widget.style.seperator ?? + final separator = widget.style.separator ?? Container( width: 1, color: context.borderColor, ); final widgets = widget.options.flapPosition == FlapPosition.start - ? [flap, seperator, content] - : [content, seperator, flap]; + ? [flap, separator, content] + : [content, separator, flap]; return WindowResizeListener( onResize: (Size size) { diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 5cc3299..c68aae3 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -108,7 +108,7 @@ class _AdwHeaderBarState extends State { widget.minimizeBtn != null || widget.maximizeBtn != null; - late ValueNotifier> seperator = + late ValueNotifier> separator = !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) ? ValueNotifier>([ '', @@ -123,7 +123,7 @@ class _AdwHeaderBarState extends State { if (widget.style.autoPositionWindowButtons) { void updateSep(String order) { if (!mounted) return; - seperator.value = order.split(':'); + separator.value = order.split(':'); } if (Platform.isWindows) { @@ -181,7 +181,7 @@ class _AdwHeaderBarState extends State { onDoubleTap: widget.onDoubleTap, ), ValueListenableBuilder>( - valueListenable: seperator, + valueListenable: separator, builder: (context, sep, _) => DefaultTextStyle.merge( style: const TextStyle( fontSize: 14, diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index e8d6158..7ef946f 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -7,7 +7,7 @@ class AdwStackSidebar extends StatefulWidget { Key? key, required this.sidebar, required this.content, - this.seperator, + this.separator, required this.onContentPopupClosed, this.breakpoint = 800, this.sidebarWidth = 250, @@ -17,7 +17,7 @@ class AdwStackSidebar extends StatefulWidget { final Widget sidebar; final Widget content; - final Widget? seperator; + final Widget? separator; /// Keeps track of the content index final int? contentIndex; @@ -94,7 +94,7 @@ class _AdwStackSidebarState extends State { width: widget.sidebarWidth, child: widget.sidebar, ), - widget.seperator ?? Container(width: 1, color: context.borderColor), + widget.separator ?? Container(width: 1, color: context.borderColor), Flexible(child: widget.content), ]; return Row( From 168f1835f0f8082a5a5ef8d2dc466804ee261e52 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 02:39:52 +0530 Subject: [PATCH 16/77] Update Logic --- lib/src/widgets/adw/new/scaffold.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index cb22993..8dd5b40 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -21,7 +21,7 @@ class AdwScaffold extends StatefulWidget { this.actions, this.controls, }) : assert( - viewSwitcher != null && actions != null, + viewSwitcher != null || actions != null, 'If viewSwitcher is there, then actions are also needed to be' ' provided!', ), @@ -66,7 +66,10 @@ class _AdwScaffoldState extends State { final flap = widget.flap != null ? SizedBox( width: 200, - child: Drawer(elevation: 25, child: widget.flap!(true)), + child: Drawer( + elevation: 25, + child: widget.flap!(true), + ), ) : null; From f5e33b789f6b6370152cf33073ef9c1836e27a7f Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 03:13:09 +0530 Subject: [PATCH 17/77] Add appName and appVersion parameter --- lib/src/widgets/adw/about_window.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index da2b07b..ec80f3b 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -22,6 +22,8 @@ class AdwAboutWindow extends StatefulWidget { const AdwAboutWindow({ Key? key, required this.appIcon, + this.appName, + this.appVersion, this.nextPageIcon, this.launchEndIcon, this.width = 360, @@ -52,6 +54,12 @@ class AdwAboutWindow extends StatefulWidget { /// The app icon to show in the about window final Widget appIcon; + /// The app name to show in the about window, not required + final String? appName; + + /// The app version to show in the about window, not required + final String? appVersion; + /// The end icon of The Credits and Legal button, /// defaults to chevron_right Material Icon final Widget? nextPageIcon; @@ -143,7 +151,8 @@ class _AdwAboutWindowState extends State { child: widget.appIcon, ), Text( - isNotNull ? data!.appName : '---', + widget.appName ?? + (isNotNull ? data!.appName : '---'), style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -155,7 +164,8 @@ class _AdwAboutWindowState extends State { AdwActionRow( title: 'Version', end: Text( - isNotNull ? data!.version : '0', + widget.appVersion ?? + (isNotNull ? data!.version : '0'), ), ), if (widget.issueTrackerLink != null) From cc2af9d7897e654ba59b610c0dbc0cc620bbf8d4 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 03:16:34 +0530 Subject: [PATCH 18/77] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0cb905..4775243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ ### ADDED +* Add `appName` and `appVersion` parameter * `actions` and `controls` parameter for `AdwHeaderBar` * Add ability to change `horizontalTitleGap` for `AdwActionRow` and `AdwComboRow` * Init Translations From 0f3d41c2656287320d2b7cb55ce740eb21705041 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 19 Feb 2022 16:59:04 +0530 Subject: [PATCH 19/77] Require actions parameter for Scaffold --- lib/src/widgets/adw/new/scaffold.dart | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 8dd5b40..d043a0b 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -18,14 +18,9 @@ class AdwScaffold extends StatefulWidget { this.start, this.title, this.end, - this.actions, + required this.actions, this.controls, - }) : assert( - viewSwitcher != null || actions != null, - 'If viewSwitcher is there, then actions are also needed to be' - ' provided!', - ), - super(key: key); + }) : super(key: key); final Widget body; @@ -42,7 +37,7 @@ class AdwScaffold extends StatefulWidget { final Widget? title; final List? end; - final AdwActions? actions; + final AdwActions actions; final AdwControls? controls; final Widget? viewSwitcher; @@ -77,7 +72,7 @@ class _AdwScaffoldState extends State { child: Column( children: [ AdwHeaderBar( - actions: widget.actions!, + actions: widget.actions, controls: widget.controls, title: widget.viewSwitcher ?? widget.title, end: widget.end ?? [], From b2d8d6918c183ed809147ecc66fe0ad18c2a2457 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 01:22:20 +0530 Subject: [PATCH 20/77] Add visible parameter to FlapOptions Add AdwSwitchRow --- example/lib/flap/flap_home_page.dart | 10 ++++ lib/src/controllers/flap_controller.dart | 8 +-- lib/src/widgets/adw/flap.dart | 57 ++++++++++--------- lib/src/widgets/adw/new/scaffold.dart | 9 ++- lib/src/widgets/adw/switch_row.dart | 70 ++++++++++++++++++++++++ lib/src/widgets/widgets.dart | 1 + 6 files changed, 124 insertions(+), 31 deletions(-) create mode 100644 lib/src/widgets/adw/switch_row.dart diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index ee4413f..1232ee2 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -20,6 +20,7 @@ class _FlapHomePageState extends State { FlapPosition flapPosition = FlapPosition.start; FoldPolicy foldPolicy = FoldPolicy.auto; bool locked = false; + bool visible = true; int selectionIndex = 0; @override @@ -87,6 +88,7 @@ class _FlapHomePageState extends State { flapOptions: FlapOptions( flapPosition: flapPosition, foldPolicy: FoldPolicy.values[selectionIndex], + visible: visible, ), body: AdwViewStack( index: _currentIndex, @@ -144,6 +146,14 @@ Sidebar visibility doesn't change when fold state changes""", onSelected: (val) {}, choices: const ['Over', 'Under', 'Slide'], ), + AdwSwitchRow( + value: visible, + onChanged: (val) { + visible = val ?? true; + setState(() {}); + }, + title: 'Visible', + ), ], ), ), diff --git a/lib/src/controllers/flap_controller.dart b/lib/src/controllers/flap_controller.dart index 3fe584f..d96b31a 100644 --- a/lib/src/controllers/flap_controller.dart +++ b/lib/src/controllers/flap_controller.dart @@ -63,7 +63,7 @@ class FlapController extends ChangeNotifier { } } - void open({BuildContext? context}) { + void open([BuildContext? context]) { if (!isOpen) { isOpen = true; // Usually open only should set the isOpen variable, but if we have a @@ -83,7 +83,7 @@ class FlapController extends ChangeNotifier { } } - void close({BuildContext? context}) { + void close([BuildContext? context]) { if (isOpen) { isOpen = false; final scaffold = Scaffold.of(context ?? this.context!); @@ -100,9 +100,9 @@ class FlapController extends ChangeNotifier { void toggle({BuildContext? context}) { if (isOpen) { - close(context: context ?? this.context); + close(context ?? this.context); } else { - open(context: context ?? this.context); + open(context ?? this.context); } } } diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 36525d4..42b5ef7 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -11,6 +11,7 @@ class FlapOptions { const FlapOptions({ this.foldPolicy = FoldPolicy.auto, this.flapPosition = FlapPosition.start, + this.visible = true, }); /// The FoldPolicy of this flap, defaults to auto @@ -18,6 +19,9 @@ class FlapOptions { /// The FlapPosition of this flap, defaults to start final FlapPosition flapPosition; + + /// The visiblity of this flap, defaults to true + final bool visible; } class FlapStyle { @@ -145,31 +149,34 @@ class _AdwFlapState extends State { ? [flap, separator, content] : [content, separator, flap]; - return WindowResizeListener( - onResize: (Size size) { - WidgetsBinding.instance!.addPostFrameCallback((_) { - // The stuff that happens when the window is resized - // We check for the mobile state and update it on every resize - // Do nothin if FoldPolicy is never / always, because they are not - // affected by window resizes. - // If FoldPolicy is auto, then close / open the sidebar depending on the - // state - final isMobile = size.width < widget.style.breakpoint; - _controller.updateModalState(context, state: isMobile); - - switch (widget.options.foldPolicy) { - case FoldPolicy.never: - case FoldPolicy.always: - break; - case FoldPolicy.auto: - _controller.updateOpenState(state: !isMobile); - break; - } - }); - }, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: widgets, + return Visibility( + visible: widget.options.visible, + child: WindowResizeListener( + onResize: (Size size) { + WidgetsBinding.instance!.addPostFrameCallback((_) { + // The stuff that happens when the window is resized + // We check for the mobile state and update it on every resize + // Do nothin if FoldPolicy is never / always, because they are not + // affected by window resizes. + // If FoldPolicy is auto, then close / open the sidebar depending on the + // state + final isMobile = size.width < widget.style.breakpoint; + _controller.updateModalState(context, state: isMobile); + + switch (widget.options.foldPolicy) { + case FoldPolicy.never: + case FoldPolicy.always: + break; + case FoldPolicy.auto: + _controller.updateOpenState(state: !isMobile); + break; + } + }); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: widgets, + ), ), ); } diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index d043a0b..96ade00 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -58,7 +58,9 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { final isMobile = MediaQuery.of(context).size.width <= 600; - final flap = widget.flap != null + final flap = widget.flap != null && + widget.flapOptions != null && + widget.flapOptions!.visible ? SizedBox( width: 200, child: Drawer( @@ -90,11 +92,14 @@ class _AdwScaffoldState extends State { onDrawerChanged: _flapController?.onDrawerChanged, drawer: flap, endDrawer: flap, - body: widget.flap != null + body: widget.flap != null && + widget.flapOptions != null && + widget.flapOptions!.visible ? AdwFlap( flap: widget.flap!(false), controller: widget.flapController, style: widget.flapStyle, + options: widget.flapOptions, child: widget.body, ) : widget.body, diff --git a/lib/src/widgets/adw/switch_row.dart b/lib/src/widgets/adw/switch_row.dart new file mode 100644 index 0000000..e21ce13 --- /dev/null +++ b/lib/src/widgets/adw/switch_row.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:libadwaita/libadwaita.dart'; + +class AdwSwitchRow extends StatefulWidget { + const AdwSwitchRow({ + Key? key, + this.start, + this.end, + required this.value, + required this.onChanged, + required this.title, + this.subtitle, + this.horizontalTitleGap = 8, + this.autofocus = false, + this.enabled = true, + this.contentPadding, + }) : super(key: key); + + /// The index of the selected choice + final bool value; + + /// Executed when a choice is selected + final ValueSetter onChanged; + + /// The starting elemets of this row + final Widget? start; + + /// The ending elements of this row + final Widget? end; + + /// The title of this row + final String title; + + /// The subtitle of this row + final String? subtitle; + + /// Whether to focus automatically when this widget is visible + /// defaults to false + final bool autofocus; + + /// Whether this combo row is enabled or not, defaults to true + final bool enabled; + + /// The horizontal gap between the titles and the leading/trailing widgets. + final double horizontalTitleGap; + + /// The padding b/w content of this Combo row + final EdgeInsets? contentPadding; + + @override + State createState() => _AdwSwitchRowState(); +} + +class _AdwSwitchRowState extends State { + _AdwSwitchRowState(); + + @override + Widget build(BuildContext context) { + return MergeSemantics( + child: AdwActionRow( + title: widget.title, + contentPadding: widget.contentPadding, + end: AdwSwitch( + value: widget.value, + onChanged: widget.onChanged, + ), + ), + ); + } +} diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index 8d101d5..7b11eda 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -11,6 +11,7 @@ export 'adw/flap.dart'; export 'adw/header_bar.dart'; export 'adw/preferences_group.dart'; export 'adw/switch.dart'; +export 'adw/switch_row.dart'; export 'adw/view_stack.dart'; export 'adw/view_switcher.dart'; export 'adw/view_switcher_tab.dart'; From 55adb1b2757863a6dab8ec613f2e4c30396768b7 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 01:25:08 +0530 Subject: [PATCH 21/77] Base Combo Row with Action Row Move Switch Row to new folder --- lib/src/widgets/adw/combo_row.dart | 13 +++++-------- lib/src/widgets/adw/{ => new}/switch_row.dart | 4 ++-- lib/src/widgets/widgets.dart | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) rename lib/src/widgets/adw/{ => new}/switch_row.dart (95%) diff --git a/lib/src/widgets/adw/combo_row.dart b/lib/src/widgets/adw/combo_row.dart index a5d7aaf..5395c09 100644 --- a/lib/src/widgets/adw/combo_row.dart +++ b/lib/src/widgets/adw/combo_row.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:libadwaita/src/utils/colors.dart'; -import 'package:libadwaita/src/widgets/adw/button.dart'; +import 'package:libadwaita/libadwaita.dart'; import 'package:popover_gtk/popover_gtk.dart'; class AdwComboRow extends StatefulWidget { @@ -81,16 +80,14 @@ class _AdwComboRowState extends State { child: Row( children: [ Expanded( - child: ListTile( + child: AdwActionRow( autofocus: widget.autofocus, enabled: widget.enabled, contentPadding: widget.contentPadding, horizontalTitleGap: widget.horizontalTitleGap, - leading: widget.start, - title: Text(widget.title), - subtitle: widget.subtitle != null && widget.subtitle!.isNotEmpty - ? Text(widget.subtitle!) - : null, + start: widget.start, + title: widget.title, + subtitle: widget.subtitle, ), ), Flexible( diff --git a/lib/src/widgets/adw/switch_row.dart b/lib/src/widgets/adw/new/switch_row.dart similarity index 95% rename from lib/src/widgets/adw/switch_row.dart rename to lib/src/widgets/adw/new/switch_row.dart index e21ce13..fbd1ef7 100644 --- a/lib/src/widgets/adw/switch_row.dart +++ b/lib/src/widgets/adw/new/switch_row.dart @@ -16,10 +16,10 @@ class AdwSwitchRow extends StatefulWidget { this.contentPadding, }) : super(key: key); - /// The index of the selected choice + /// The value of the switch final bool value; - /// Executed when a choice is selected + /// Executed when the switch is toggled final ValueSetter onChanged; /// The starting elemets of this row diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index 7b11eda..72cc272 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -11,7 +11,7 @@ export 'adw/flap.dart'; export 'adw/header_bar.dart'; export 'adw/preferences_group.dart'; export 'adw/switch.dart'; -export 'adw/switch_row.dart'; +export 'adw/new/switch_row.dart'; export 'adw/view_stack.dart'; export 'adw/view_switcher.dart'; export 'adw/view_switcher_tab.dart'; From 4d5563727b17f531a5517f10c049d36ec41240fa Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 01:26:56 +0530 Subject: [PATCH 22/77] Change switch value on tap of AdwSwitchRow --- lib/src/widgets/adw/new/switch_row.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/widgets/adw/new/switch_row.dart b/lib/src/widgets/adw/new/switch_row.dart index fbd1ef7..f0704f8 100644 --- a/lib/src/widgets/adw/new/switch_row.dart +++ b/lib/src/widgets/adw/new/switch_row.dart @@ -60,6 +60,7 @@ class _AdwSwitchRowState extends State { child: AdwActionRow( title: widget.title, contentPadding: widget.contentPadding, + onActivated: () => widget.onChanged(!widget.value), end: AdwSwitch( value: widget.value, onChanged: widget.onChanged, From b08edd84a7e84330cfcda028123978d5dcf24d26 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 01:38:57 +0530 Subject: [PATCH 23/77] Update examples --- example/lib/flap/flap_home_page.dart | 33 +++++++++++++------------ example/lib/pages/lists_page.dart | 21 ++++++++++------ lib/src/widgets/adw/new/scaffold.dart | 11 ++++----- lib/src/widgets/adw/new/switch_row.dart | 6 +---- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index 1232ee2..2b58f44 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -21,7 +21,7 @@ class _FlapHomePageState extends State { FoldPolicy foldPolicy = FoldPolicy.auto; bool locked = false; bool visible = true; - int selectionIndex = 0; + int selectionIndex = 2; @override void initState() { @@ -102,17 +102,15 @@ class _FlapHomePageState extends State { onSelected: (val) => setState(() => selectionIndex = val), choices: FoldPolicy.values.map((e) => e.name).toList(), ), - AdwActionRow( + AdwSwitchRow( title: 'Locked', subtitle: """ Sidebar visibility doesn't change when fold state changes""", - end: AdwSwitch( - value: locked, - onChanged: (val) { - locked = val; - setState(() {}); - }, - ), + value: locked, + onChanged: (val) { + locked = val; + setState(() {}); + }, ) ], ), @@ -149,7 +147,7 @@ Sidebar visibility doesn't change when fold state changes""", AdwSwitchRow( value: visible, onChanged: (val) { - visible = val ?? true; + visible = val; setState(() {}); }, title: 'Visible', @@ -160,19 +158,22 @@ Sidebar visibility doesn't change when fold state changes""", AdwClamp.scrollable( child: AdwPreferencesGroup( children: [ - AdwActionRow( + AdwSwitchRow( title: 'Modal', subtitle: ''' Clicking outside the sidebar or pressing Esc will close it when folded''', - end: AdwSwitch(value: true, onChanged: (val) {}), + value: true, + onChanged: (val) {}, ), - AdwActionRow( + AdwSwitchRow( title: 'Swipe to Open', - end: AdwSwitch(value: true, onChanged: (val) {}), + value: true, + onChanged: (val) {}, ), - AdwActionRow( + AdwSwitchRow( title: 'Swipe to Close', - end: AdwSwitch(value: true, onChanged: (val) {}), + value: true, + onChanged: (val) {}, ), ], ), diff --git a/example/lib/pages/lists_page.dart b/example/lib/pages/lists_page.dart index 9b2d1b9..78b95a7 100644 --- a/example/lib/pages/lists_page.dart +++ b/example/lib/pages/lists_page.dart @@ -82,14 +82,19 @@ class ListsPage extends StatelessWidget { ) ], ), - ValueListenableBuilder( - valueListenable: switchVal, - builder: (context, val, _) => AdwSwitch( - value: val, - onChanged: (v) { - switchVal.value = v; - }, - ), + AdwPreferencesGroup( + children: [ + ValueListenableBuilder( + valueListenable: switchVal, + builder: (context, val, _) => AdwSwitchRow( + title: 'Switch example', + value: val, + onChanged: (v) { + switchVal.value = v; + }, + ), + ), + ], ), ] .map( diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 96ade00..4eaf9ff 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -58,9 +58,10 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { final isMobile = MediaQuery.of(context).size.width <= 600; - final flap = widget.flap != null && - widget.flapOptions != null && - widget.flapOptions!.visible + final isFlapVisible = widget.flap != null && widget.flapOptions == null || + widget.flapOptions!.visible; + + final flap = isFlapVisible ? SizedBox( width: 200, child: Drawer( @@ -92,9 +93,7 @@ class _AdwScaffoldState extends State { onDrawerChanged: _flapController?.onDrawerChanged, drawer: flap, endDrawer: flap, - body: widget.flap != null && - widget.flapOptions != null && - widget.flapOptions!.visible + body: isFlapVisible ? AdwFlap( flap: widget.flap!(false), controller: widget.flapController, diff --git a/lib/src/widgets/adw/new/switch_row.dart b/lib/src/widgets/adw/new/switch_row.dart index f0704f8..8b9de83 100644 --- a/lib/src/widgets/adw/new/switch_row.dart +++ b/lib/src/widgets/adw/new/switch_row.dart @@ -5,7 +5,6 @@ class AdwSwitchRow extends StatefulWidget { const AdwSwitchRow({ Key? key, this.start, - this.end, required this.value, required this.onChanged, required this.title, @@ -20,14 +19,11 @@ class AdwSwitchRow extends StatefulWidget { final bool value; /// Executed when the switch is toggled - final ValueSetter onChanged; + final ValueSetter onChanged; /// The starting elemets of this row final Widget? start; - /// The ending elements of this row - final Widget? end; - /// The title of this row final String title; From 1ed646075caece4b021e5865b049e4a21b14b34b Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 02:33:37 +0530 Subject: [PATCH 24/77] Update visible flap code --- lib/src/widgets/adw/flap.dart | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 42b5ef7..1de38a3 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -145,14 +145,21 @@ class _AdwFlapState extends State { color: context.borderColor, ); - final widgets = widget.options.flapPosition == FlapPosition.start - ? [flap, separator, content] - : [content, separator, flap]; - - return Visibility( - visible: widget.options.visible, - child: WindowResizeListener( - onResize: (Size size) { + final children = [ + if (widget.options.visible) ...[ + flap, + separator, + ], + content, + ]; + + final finalChildren = widget.options.flapPosition == FlapPosition.start + ? children + : children.reversed.toList(); + + return WindowResizeListener( + onResize: (Size size) { + if (widget.options.visible) { WidgetsBinding.instance!.addPostFrameCallback((_) { // The stuff that happens when the window is resized // We check for the mobile state and update it on every resize @@ -172,11 +179,11 @@ class _AdwFlapState extends State { break; } }); - }, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: widgets, - ), + } + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: finalChildren, ), ); } From 5184370a4b1fb8774ada0187ae7c63ad575775f9 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 03:10:26 +0530 Subject: [PATCH 25/77] Fix error on logic --- lib/src/widgets/adw/new/scaffold.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 4eaf9ff..37383f5 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -58,8 +58,8 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { final isMobile = MediaQuery.of(context).size.width <= 600; - final isFlapVisible = widget.flap != null && widget.flapOptions == null || - widget.flapOptions!.visible; + final isFlapVisible = widget.flap != null && + (widget.flapOptions == null || widget.flapOptions!.visible); final flap = isFlapVisible ? SizedBox( From fafe7356f9449b932ebaf83d9e0cf7e23318c50d Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 03:28:21 +0530 Subject: [PATCH 26/77] Update visible logic again --- lib/src/widgets/adw/flap.dart | 53 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 1de38a3..2fce6d4 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -82,9 +82,7 @@ class AdwFlap extends StatefulWidget { class _AdwFlapState extends State { late FlapController _controller; - void rebuild() { - setState(() {}); - } + void rebuild() => setState(() {}); @override void initState() { @@ -145,42 +143,35 @@ class _AdwFlapState extends State { color: context.borderColor, ); - final children = [ - if (widget.options.visible) ...[ - flap, - separator, - ], - content, - ]; + final children = [flap, separator, content]; final finalChildren = widget.options.flapPosition == FlapPosition.start ? children : children.reversed.toList(); + if (!widget.options.visible) widget.controller?.close(); + return WindowResizeListener( - onResize: (Size size) { - if (widget.options.visible) { + onResize: (Size size) => WidgetsBinding.instance!.addPostFrameCallback((_) { - // The stuff that happens when the window is resized - // We check for the mobile state and update it on every resize - // Do nothin if FoldPolicy is never / always, because they are not - // affected by window resizes. - // If FoldPolicy is auto, then close / open the sidebar depending on the - // state - final isMobile = size.width < widget.style.breakpoint; - _controller.updateModalState(context, state: isMobile); - - switch (widget.options.foldPolicy) { - case FoldPolicy.never: - case FoldPolicy.always: - break; - case FoldPolicy.auto: - _controller.updateOpenState(state: !isMobile); - break; - } - }); + // The stuff that happens when the window is resized + // We check for the mobile state and update it on every resize + // Do nothin if FoldPolicy is never / always, because they are not + // affected by window resizes. + // If FoldPolicy is auto, then close / open the sidebar depending on the + // state + final isMobile = size.width < widget.style.breakpoint; + _controller.updateModalState(context, state: isMobile); + if (!widget.options.visible) return; + switch (widget.options.foldPolicy) { + case FoldPolicy.never: + case FoldPolicy.always: + break; + case FoldPolicy.auto: + _controller.updateOpenState(state: !isMobile); + break; } - }, + }), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: finalChildren, From d1df6cc0a3b9857de3d76d345673813969de5dc9 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 03:34:17 +0530 Subject: [PATCH 27/77] Update scaffold logic too --- lib/src/widgets/adw/new/scaffold.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 37383f5..55cd7be 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -58,8 +58,7 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { final isMobile = MediaQuery.of(context).size.width <= 600; - final isFlapVisible = widget.flap != null && - (widget.flapOptions == null || widget.flapOptions!.visible); + final isFlapVisible = widget.flap != null; final flap = isFlapVisible ? SizedBox( From 85ede7b575de215e9c2758bcb08a687a093a61f5 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 03:47:49 +0530 Subject: [PATCH 28/77] Fix ViewSwitcher visibility Add viewSwitcherConstraint property --- lib/src/widgets/adw/new/scaffold.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 55cd7be..ec3bba5 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -14,6 +14,7 @@ class AdwScaffold extends StatefulWidget { @Deprecated('headerbar is deprecated, use the properties separately') AdwHeaderBar? Function(Widget?)? headerbar, this.viewSwitcher, + this.viewSwitcherConstraint, this.headerBarStyle, this.start, this.title, @@ -41,6 +42,7 @@ class AdwScaffold extends StatefulWidget { final AdwControls? controls; final Widget? viewSwitcher; + final double? viewSwitcherConstraint; @override _AdwScaffoldState createState() => _AdwScaffoldState(); @@ -57,8 +59,10 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { - final isMobile = MediaQuery.of(context).size.width <= 600; + final isMobile = MediaQuery.of(context).size.width <= + (widget.viewSwitcherConstraint ?? 600); final isFlapVisible = widget.flap != null; + final isViewSwitcherVisible = widget.viewSwitcher != null; final flap = isFlapVisible ? SizedBox( @@ -76,7 +80,9 @@ class _AdwScaffoldState extends State { AdwHeaderBar( actions: widget.actions, controls: widget.controls, - title: widget.viewSwitcher ?? widget.title, + title: isViewSwitcherVisible && !isMobile + ? widget.viewSwitcher + : widget.title, end: widget.end ?? [], start: widget.start ?? [], style: widget.headerBarStyle ?? const HeaderBarStyle(), @@ -101,9 +107,11 @@ class _AdwScaffoldState extends State { child: widget.body, ) : widget.body, - bottomNavigationBar: widget.viewSwitcher != null && isMobile + bottomNavigationBar: isViewSwitcherVisible && isMobile ? SizedBox( - height: 51, + height: widget.headerBarStyle != null + ? widget.headerBarStyle!.height + : 51, child: Column( mainAxisSize: MainAxisSize.min, children: [ From c62ea2e4e99a083398d276c8b251d492a88c3323 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 18:23:01 +0530 Subject: [PATCH 29/77] Fix auto position window buttons --- lib/src/widgets/adw/header_bar.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index c68aae3..902216e 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -109,11 +109,12 @@ class _AdwHeaderBarState extends State { widget.maximizeBtn != null; late ValueNotifier> separator = - !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) - ? ValueNotifier>([ - '', - 'minimize,maximize,close', - ]) + widget.style.autoPositionWindowButtons || + !kIsWeb && + (Platform.isLinux || Platform.isWindows || Platform.isMacOS) + ? ValueNotifier>( + ['', 'minimize,maximize,close'], + ) : ValueNotifier>(['', '']); @override From 1054a696b4a601240c2c5d8747f6e34a0471ad84 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 20 Feb 2022 18:36:51 +0530 Subject: [PATCH 30/77] Fix logic --- lib/src/widgets/adw/header_bar.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 902216e..13e737a 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -109,7 +109,7 @@ class _AdwHeaderBarState extends State { widget.maximizeBtn != null; late ValueNotifier> separator = - widget.style.autoPositionWindowButtons || + !widget.style.autoPositionWindowButtons || !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) ? ValueNotifier>( From b92bc72c28548e02f65eb6ce1abe654fe3118c4a Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 21 Feb 2022 20:35:00 +0530 Subject: [PATCH 31/77] Update CHANGELOG --- CHANGELOG.md | 9 ++++++--- lib/src/widgets/adw/header_bar.dart | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4775243..ef1f1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,11 +38,12 @@ * Previously ```dart AdwScaffold( - headerbar: (_) => AdwHeaderBar( + headerbar: (viewS) => AdwHeaderBar( start: start, end: end, - title: title, - ) + title: viewS ?? title, + ), + viewSwitcher: viewSwitcher, ) ``` * Now @@ -51,6 +52,7 @@ start: start, end: end, title: title, + viewSwitcher: viewSwitcher, ) ``` @@ -59,6 +61,7 @@ * Add `appName` and `appVersion` parameter * `actions` and `controls` parameter for `AdwHeaderBar` * Add ability to change `horizontalTitleGap` for `AdwActionRow` and `AdwComboRow` +* Add `visible` property of `FlapOptions` * Init Translations ### CHANGED diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 13e737a..36b84f9 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -1,5 +1,3 @@ -// ignore_for_file: avoid_dynamic_calls - import 'dart:io'; import 'package:dbus/dbus.dart'; From 6fe37e4f42417ac1e7488b547ea92addc8677362 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 21 Feb 2022 20:44:10 +0530 Subject: [PATCH 32/77] Update Screenshot in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cce9b8..6abf80d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -![libadwaita example screenshot](https://user-images.githubusercontent.com/41370460/152782085-cd178e63-6f2e-49cb-a63c-d03698b9cc29.png) +![libadwaita example screenshot](https://user-images.githubusercontent.com/41370460/154982398-70778cd9-b25e-410f-99bb-5804b33bfe38.png) **NOTE:** For getting colors from gtk 3.0 theme use version [`<=0.9.8+1`](https://pub.dev/packages/gtk/versions/0.9.8+1) From 0dd4328d617dc0c29a32bdba7ff56ad10ab81496 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Mon, 21 Feb 2022 20:46:47 +0530 Subject: [PATCH 33/77] Add searchbar autocomplete demo --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 6abf80d..760e669 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,19 @@ import 'package:libadwaita_searchbar/libadwaita_searchbar.dart'; bool searchedTerm = ''; AdwSearchBar( + onSubmitted: (str) => setState(() => searchedTerm = str), + controller: const TextEditingController(), +) +``` + +#### [**`libadwaita_searchbar_ac`**](https://pub.dev/packages/libadwaita_searchbar_ac) +Example: +```dart +import 'package:libadwaita_searchbar_ac/libadwaita_searchbar_ac.dart'; + +bool searchedTerm = ''; + +AdwSearchBarAc( suggestions: const ['Hi', 'Hello'], onSubmitted: (str) => setState(() => searchedTerm = str), controller: const TextEditingController(), From 7f8f902b941ea9bf14c7c43eb6c0f45a69c82adb Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 22 Feb 2022 19:45:00 +0530 Subject: [PATCH 34/77] Add `border` to ViewSwitcher in mobile view --- CHANGELOG.md | 1 + lib/src/widgets/adw/new/scaffold.dart | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1f1f7..78d065f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ * `actions` and `controls` parameter for `AdwHeaderBar` * Add ability to change `horizontalTitleGap` for `AdwActionRow` and `AdwComboRow` * Add `visible` property of `FlapOptions` +* Add `border` to ViewSwitcher in mobile view * Init Translations ### CHANGED diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index ec3bba5..73aa12e 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/src/controllers/flap_controller.dart'; +import 'package:libadwaita/src/utils/colors.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; import 'package:libadwaita_core/libadwaita_core.dart'; @@ -108,10 +109,17 @@ class _AdwScaffoldState extends State { ) : widget.body, bottomNavigationBar: isViewSwitcherVisible && isMobile - ? SizedBox( + ? Container( height: widget.headerBarStyle != null ? widget.headerBarStyle!.height : 51, + decoration: BoxDecoration( + border: Border( + top: BorderSide( + color: context.borderColor, + ), + ), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ From c9967f7b9dbda652d4a7999836973f74e05afc69 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 22 Feb 2022 20:16:23 +0530 Subject: [PATCH 35/77] add(gtk): GtkDialog breaking(gtk): Prefix all gtk widgets with Gtk instead of Adw --- CHANGELOG.md | 4 + example/lib/flap/flap_home_page.dart | 2 +- example/lib/home_page.dart | 7 +- lib/src/widgets/adw/about_window.dart | 222 +++++++++++-------------- lib/src/widgets/gtk/dialog.dart | 82 +++++++++ lib/src/widgets/gtk/popup_menu.dart | 11 +- lib/src/widgets/gtk/stack_sidebar.dart | 11 +- lib/src/widgets/gtk/toggle_button.dart | 7 +- lib/src/widgets/widgets.dart | 3 +- 9 files changed, 212 insertions(+), 137 deletions(-) create mode 100644 lib/src/widgets/gtk/dialog.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 78d065f..498f361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ ) ``` * Fix spelling by renaming `seperator` to `separator` everywhere +* `AdwPopupMenu` is now `GtkPopupMenu` +* `AdwStackSwitcher` is now `GtkStackSwitcher` +* `AdwToggleButton` is now `GtkToggleButton` ### DEPRECATED @@ -58,6 +61,7 @@ ### ADDED +* Add `GtkDialog` * Add `appName` and `appVersion` parameter * `actions` and `controls` parameter for `AdwHeaderBar` * Add ability to change `horizontalTitleGap` for `AdwActionRow` and `AdwComboRow` diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index 2b58f44..8b69837 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -120,7 +120,7 @@ Sidebar visibility doesn't change when fold state changes""", children: [ AdwActionRow( title: 'Flap position', - end: AdwToggleButton( + end: GtkToggleButton( isSelected: [ flapPosition.index == 0, flapPosition.index == 1 diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 913e921..1394922 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -79,7 +79,7 @@ class _MyHomePageState extends State { ], title: const Text('Libadwaita Demo'), end: [ - AdwPopupMenu( + GtkPopupMenu( body: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -120,6 +120,11 @@ class _MyHomePageState extends State { issueTrackerLink: 'https://github.com/gtk-flutter/libadwaita/issues', appIcon: Image.asset('assets/logo.png'), + actions: AdwActions( + onClose: Navigator.of(context).pop, + onHeaderDrag: appWindow?.startDragging, + onDoubleTap: appWindow?.maximizeOrRestore, + ), credits: [ AdwPreferencesGroup.credits( title: 'Developers', diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index ec80f3b..32e5918 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -106,137 +106,111 @@ class _AdwAboutWindowState extends State { builder: (context, snapshot) { final data = snapshot.hasData ? snapshot.data : null; final isNotNull = data != null; - return Dialog( - shape: - RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - child: ClipRRect( - borderRadius: BorderRadius.circular(12), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: widget.width, - minHeight: 350, + return GtkDialog( + constraints: BoxConstraints( + maxWidth: widget.width, + minHeight: 350, + maxHeight: 400, + ), + title: text, + start: [ + leading, + if (widget.start != null) ...widget.start!, + ], + end: widget.end ?? [], + actions: widget.actions ?? + AdwActions( + onClose: Navigator.of(context).pop, ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - AdwHeaderBar( - title: text, - start: [ - leading, - if (widget.start != null) ...widget.start!, - ], - end: widget.end ?? [], - actions: widget.actions ?? - AdwActions( - onClose: Navigator.of(context).pop, + controls: widget.controls, + headerBarStyle: widget.headerBarStyle ?? + const HeaderBarStyle( + autoPositionWindowButtons: false, + isTransparent: true, + ), + padding: commonPadding, + children: currentPage == 0 + ? [ + Container( + margin: const EdgeInsets.symmetric(vertical: 3), + width: 80, + child: widget.appIcon, + ), + Text( + widget.appName ?? (isNotNull ? data!.appName : '---'), + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 6), + AdwPreferencesGroup( + children: [ + AdwActionRow( + title: 'Version', + end: Text( + widget.appVersion ?? + (isNotNull ? data!.version : '0'), ), - controls: widget.controls, - style: widget.headerBarStyle ?? - const HeaderBarStyle( - autoPositionWindowButtons: false, - isTransparent: true, + ), + if (widget.issueTrackerLink != null) + AdwActionRow( + title: 'Report an issue', + onActivated: () => launch( + widget.issueTrackerLink!, + ), + end: widget.launchEndIcon ?? + const Icon( + Icons.open_in_new_outlined, + size: 20, + ), ), + ], ), - Flexible( - child: SingleChildScrollView( - padding: commonPadding, - child: Column( - mainAxisSize: MainAxisSize.min, - children: currentPage == 0 - ? [ - Container( - margin: - const EdgeInsets.symmetric(vertical: 3), - width: 80, - child: widget.appIcon, + if ((widget.credits != null) || + widget.copyright != null || + widget.license != null) ...[ + const SizedBox(height: 8), + AdwPreferencesGroup( + children: [ + if (widget.credits != null) + AdwActionRow( + title: 'Credits', + onActivated: () => setState(() => currentPage = 1), + end: widget.nextPageIcon ?? + const Icon( + Icons.chevron_right, ), - Text( - widget.appName ?? - (isNotNull ? data!.appName : '---'), - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), + ), + if (widget.copyright != null || widget.license != null) + AdwActionRow( + title: 'Legal', + onActivated: () => setState(() => currentPage = 2), + end: widget.nextPageIcon ?? + const Icon( + Icons.chevron_right, ), - const SizedBox(height: 6), - AdwPreferencesGroup( - children: [ - AdwActionRow( - title: 'Version', - end: Text( - widget.appVersion ?? - (isNotNull ? data!.version : '0'), - ), - ), - if (widget.issueTrackerLink != null) - AdwActionRow( - title: 'Report an issue', - onActivated: () => launch( - widget.issueTrackerLink!, - ), - end: widget.launchEndIcon ?? - const Icon( - Icons.open_in_new_outlined, - size: 20, - ), - ), - ], - ), - if ((widget.credits != null) || - widget.copyright != null || - widget.license != null) ...[ - const SizedBox(height: 8), - AdwPreferencesGroup( - children: [ - if (widget.credits != null) - AdwActionRow( - title: 'Credits', - onActivated: () => - setState(() => currentPage = 1), - end: widget.nextPageIcon ?? - const Icon( - Icons.chevron_right, - ), - ), - if (widget.copyright != null || - widget.license != null) - AdwActionRow( - title: 'Legal', - onActivated: () => - setState(() => currentPage = 2), - end: widget.nextPageIcon ?? - const Icon( - Icons.chevron_right, - ), - ), - ], - ), - ], - ] - : currentPage == 1 - ? widget.credits! - .map( - (e) => Padding( - padding: const EdgeInsets.only( - bottom: 10, - ), - child: e, - ), - ) - .toList() - : [ - if (widget.copyright != null) - Text(widget.copyright!), - const SizedBox(height: 5), - if (widget.license != null) widget.license!, - ], - ), + ), + ], ), - ), - ], - ), - ), - ), + ], + ] + : currentPage == 1 + ? widget.credits! + .map( + (e) => Padding( + padding: const EdgeInsets.only( + bottom: 10, + ), + child: e, + ), + ) + .toList() + : [ + if (widget.copyright != null) Text(widget.copyright!), + const SizedBox(height: 5), + if (widget.license != null) widget.license!, + ], ); }, ); diff --git a/lib/src/widgets/gtk/dialog.dart b/lib/src/widgets/gtk/dialog.dart new file mode 100644 index 0000000..6835bd5 --- /dev/null +++ b/lib/src/widgets/gtk/dialog.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:libadwaita/src/widgets/widgets.dart'; +import 'package:libadwaita_core/libadwaita_core.dart'; + +class GtkDialog extends StatelessWidget { + const GtkDialog({ + Key? key, + this.headerBarStyle, + this.start, + this.title, + this.end, + this.actions, + this.controls, + this.padding, + this.constraints, + this.height, + this.width, + required this.children, + }) : super(key: key); + + final HeaderBarStyle? headerBarStyle; + + final List? start; + final Widget? title; + final List? end; + + final AdwActions? actions; + final AdwControls? controls; + + final EdgeInsets? padding; + final List children; + + final BoxConstraints? constraints; + final double? height; + final double? width; + + @override + Widget build(BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: ConstrainedBox( + constraints: constraints ?? + BoxConstraints( + maxWidth: width ?? 600, + maxHeight: height ?? 600, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + AdwHeaderBar( + title: title, + start: start ?? [], + end: end ?? [], + actions: actions ?? + AdwActions( + onClose: Navigator.of(context).pop, + ), + controls: controls, + style: headerBarStyle ?? + const HeaderBarStyle( + autoPositionWindowButtons: false, + isTransparent: true, + ), + ), + Flexible( + child: SingleChildScrollView( + padding: padding, + child: Column( + mainAxisSize: MainAxisSize.min, + children: children, + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/src/widgets/gtk/popup_menu.dart b/lib/src/widgets/gtk/popup_menu.dart index b796bc6..245ee37 100644 --- a/lib/src/widgets/gtk/popup_menu.dart +++ b/lib/src/widgets/gtk/popup_menu.dart @@ -3,8 +3,11 @@ import 'package:libadwaita/src/utils/colors.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; import 'package:popover_gtk/popover_gtk.dart'; -class AdwPopupMenu extends StatefulWidget { - const AdwPopupMenu({ +@Deprecated('Use GtkPopupMenu instead') +class AdwPopupMenu {} + +class GtkPopupMenu extends StatefulWidget { + const GtkPopupMenu({ Key? key, required this.body, this.icon = const Icon(Icons.menu, size: 17), @@ -25,10 +28,10 @@ class AdwPopupMenu extends StatefulWidget { final double? popupHeight; @override - State createState() => _AdwPopupMenuState(); + State createState() => _GtkPopupMenuState(); } -class _AdwPopupMenuState extends State { +class _GtkPopupMenuState extends State { bool isActive = false; @override diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 7ef946f..48aec9f 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -2,8 +2,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:libadwaita/src/utils/colors.dart'; -class AdwStackSidebar extends StatefulWidget { - const AdwStackSidebar({ +@Deprecated('Use GtkStackSidebar instead') +class AdwStackSidebar {} + +class GtkStackSidebar extends StatefulWidget { + const GtkStackSidebar({ Key? key, required this.sidebar, required this.content, @@ -36,10 +39,10 @@ class AdwStackSidebar extends StatefulWidget { final Function(int? contentIndex, Widget content)? fullContentBuilder; @override - _AdwStackSidebarState createState() => _AdwStackSidebarState(); + _GtkStackSidebarState createState() => _GtkStackSidebarState(); } -class _AdwStackSidebarState extends State { +class _GtkStackSidebarState extends State { bool _popupNotOpen = true; bool get canSplitPanes => diff --git a/lib/src/widgets/gtk/toggle_button.dart b/lib/src/widgets/gtk/toggle_button.dart index 6114321..1b35ce6 100644 --- a/lib/src/widgets/gtk/toggle_button.dart +++ b/lib/src/widgets/gtk/toggle_button.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; -class AdwToggleButton extends StatelessWidget { - const AdwToggleButton({ +@Deprecated('Use GtkToggleButton instead') +class AdwToggleButton {} + +class GtkToggleButton extends StatelessWidget { + const GtkToggleButton({ Key? key, required this.children, required this.onPressed, diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index 72cc272..754cfd6 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -24,7 +24,8 @@ export 'adw/new/text_button.dart'; export 'adw/new/text_field.dart'; export 'adw/new/window_button.dart'; -// All the widgets imported from Gtk4 +// All the widgets imported from Gtk4 / Gtk3 +export 'gtk/dialog.dart'; export 'gtk/popup_menu.dart'; export 'gtk/stack_sidebar.dart'; export 'gtk/toggle_button.dart'; From 3be6b30c914b633e5646284d89b5196aefc88d65 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 22 Feb 2022 23:02:35 +0530 Subject: [PATCH 36/77] Add onTapCancel callback --- lib/src/widgets/adw/button.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/widgets/adw/button.dart b/lib/src/widgets/adw/button.dart index 5ad121b..4877b7f 100644 --- a/lib/src/widgets/adw/button.dart +++ b/lib/src/widgets/adw/button.dart @@ -302,6 +302,7 @@ class _AdwButtonState extends State { onTap: widget.onPressed, onTapDown: (_) => setState(() => _status = AdwButtonStatus.tapDown), onTapUp: (_) => setState(reset), + onTapCancel: () => setState(() => _status = AdwButtonStatus.enabled), child: AnimatedContainer( padding: widget.padding, constraints: widget.constraints, From aa801c198ff37ca027338b9f5b57c98a49e7071b Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Thu, 24 Feb 2022 13:04:09 +0530 Subject: [PATCH 37/77] Change version to 1.2.0-dev --- CHANGELOG.md | 2 +- example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 498f361..3bb6864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.2.0 +## 1.2.0-dev ### BREAKING diff --git a/example/pubspec.lock b/example/pubspec.lock index e08bef2..1b2e4b2 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -182,7 +182,7 @@ packages: path: ".." relative: true source: path - version: "1.2.0" + version: "1.2.0-dev" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a5afcfd..6ecec8d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.2.0 +version: 1.2.0-dev homepage: https://github.com/gtk-flutter/libadwaita environment: From 73293ad57b74b0ff1ef256f1ba53a8fda3601b58 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Thu, 24 Feb 2022 14:32:30 +0530 Subject: [PATCH 38/77] Add pageRoute parameter to GtkStackSidebar --- lib/src/widgets/gtk/stack_sidebar.dart | 30 +++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 48aec9f..7ba5487 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -15,6 +15,7 @@ class GtkStackSidebar extends StatefulWidget { this.breakpoint = 800, this.sidebarWidth = 250, this.contentIndex, + this.pageRoute, this.fullContentBuilder, }) : super(key: key); @@ -25,6 +26,9 @@ class GtkStackSidebar extends StatefulWidget { /// Keeps track of the content index final int? contentIndex; + /// Custom route for then next page of [GtkStackSidebar] + final Route Function(Widget child)? pageRoute; + /// Called when content screen is closed and sidebar is shown final void Function() onContentPopupClosed; @@ -53,22 +57,22 @@ class _GtkStackSidebarState extends State { if (_popupNotOpen) { _popupNotOpen = false; SchedulerBinding.instance!.addPostFrameCallback((_) async { + final child = Scaffold( + body: widget.fullContentBuilder != null + ? widget.fullContentBuilder!( + widget.contentIndex, + widget.content, + ) as Widget? + : widget.content, + ); // sets _popupNotOpen to true after popup is closed await Navigator.of(context) .push( - MaterialPageRoute( - builder: (BuildContext context) { - return Scaffold( - body: widget.fullContentBuilder != null - ? widget.fullContentBuilder!( - widget.contentIndex, - widget.content, - ) as Widget? - : widget.content, - ); - }, - fullscreenDialog: true, - ), + widget.pageRoute?.call(child) ?? + MaterialPageRoute( + builder: (BuildContext context) => child, + fullscreenDialog: true, + ), ) .then((_) { // less code than wapping in a WillPopScope From c1752a952912ce462cfda16696d7d182ff1c3157 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sat, 14 May 2022 11:15:15 +0530 Subject: [PATCH 39/77] Bump version to 1.2.0 --- CHANGELOG.md | 4 +- example/lib/home_page.dart | 5 +- example/pubspec.lock | 60 ++++++++++---------- lib/src/internal/window_resize_listener.dart | 8 +-- lib/src/widgets/adw/about_window.dart | 4 +- lib/src/widgets/adw/flap.dart | 3 +- lib/src/widgets/adw/header_bar.dart | 2 +- lib/src/widgets/gtk/stack_sidebar.dart | 4 +- lib/src/widgets/gtk/toggle_button.dart | 3 + pubspec.yaml | 8 +-- 10 files changed, 54 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bb6864..f62c929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.2.0-dev +## 1.2.0 ### BREAKING @@ -70,6 +70,8 @@ * Init Translations ### CHANGED +* Remove null checks from WidgetsBinding (Flutter 3.0.0) +* Changed launch to launchUrl for url_launcher package * Changed default value of `horizontalTitleGap` to 8 * Switch to `titlebar_buttons` package as `window_decorations` is deprecated * Link to external examples in example.md diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 1394922..e1e5344 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -132,8 +132,9 @@ class _MyHomePageState extends State { .map( (e) => AdwActionRow( title: e.key, - onActivated: () => - launch('https://github.com/${e.value}'), + onActivated: () => launchUrl( + Uri.parse('https://github.com/${e.value}'), + ), ), ) .toList(), diff --git a/example/pubspec.lock b/example/pubspec.lock index 1b2e4b2..b36accb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -14,7 +14,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.1" async: dependency: transitive description: @@ -90,35 +90,35 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" dbus: dependency: transitive description: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.1" + version: "0.7.3" desktop_multi_window: dependency: "direct main" description: name: desktop_multi_window url: "https://pub.dartlang.org" source: hosted - version: "0.0.1" + version: "0.0.2" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.1" file: dependency: transitive description: @@ -182,7 +182,7 @@ packages: path: ".." relative: true source: path - version: "1.2.0-dev" + version: "1.2.0" libadwaita_bitsdojo: dependency: "direct main" description: @@ -210,7 +210,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -224,14 +224,14 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.4.2" package_info_plus_linux: dependency: transitive description: name: package_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.5" package_info_plus_macos: dependency: transitive description: @@ -252,14 +252,14 @@ packages: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" path: dependency: transitive description: @@ -287,7 +287,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "5.0.0" platform: dependency: transitive description: @@ -301,7 +301,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.2" popover_gtk: dependency: transitive description: @@ -327,7 +327,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -369,70 +369,70 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" url_launcher: dependency: transitive description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.18" + version: "6.1.2" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.14" + version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.14" + version: "6.0.16" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.11" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" very_good_analysis: dependency: "direct dev" description: @@ -446,21 +446,21 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.3.3" + version: "2.5.2" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.1" + version: "5.4.1" sdks: - dart: ">=2.16.0-100.0.dev <3.0.0" - flutter: ">=2.5.0" + dart: ">=2.17.0-0 <3.0.0" + flutter: ">=2.10.0" diff --git a/lib/src/internal/window_resize_listener.dart b/lib/src/internal/window_resize_listener.dart index 8cc6ab4..aec5a3c 100644 --- a/lib/src/internal/window_resize_listener.dart +++ b/lib/src/internal/window_resize_listener.dart @@ -20,8 +20,8 @@ class _WindowResizeListenerState extends State @override void initState() { - _lastSize = WidgetsBinding.instance!.window.physicalSize; - WidgetsBinding.instance!.addObserver(this); + _lastSize = WidgetsBinding.instance.window.physicalSize; + WidgetsBinding.instance.addObserver(this); widget.onResize(_lastSize); @@ -30,13 +30,13 @@ class _WindowResizeListenerState extends State @override void dispose() { - WidgetsBinding.instance!.removeObserver(this); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } @override void didChangeMetrics() { - final winSize = WidgetsBinding.instance!.window.physicalSize; + final winSize = WidgetsBinding.instance.window.physicalSize; if (winSize != _lastSize) { widget.onResize(winSize); diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index 32e5918..28721c6 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -156,8 +156,8 @@ class _AdwAboutWindowState extends State { if (widget.issueTrackerLink != null) AdwActionRow( title: 'Report an issue', - onActivated: () => launch( - widget.issueTrackerLink!, + onActivated: () => launchUrl( + Uri.parse(widget.issueTrackerLink!), ), end: widget.launchEndIcon ?? const Icon( diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 2fce6d4..635ffd8 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -5,6 +5,7 @@ import 'package:libadwaita/src/internal/window_resize_listener.dart'; import 'package:libadwaita/src/utils/colors.dart'; enum FoldPolicy { never, always, auto } + enum FlapPosition { start, end } class FlapOptions { @@ -153,7 +154,7 @@ class _AdwFlapState extends State { return WindowResizeListener( onResize: (Size size) => - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { // The stuff that happens when the window is resized // We check for the mobile state and update it on every resize // Do nothin if FoldPolicy is never / always, because they are not diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 36b84f9..1fdc543 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -134,7 +134,7 @@ class _AdwHeaderBarState extends State { final schema = GSettings('org.gnome.desktop.wm.preferences'); - WidgetsBinding.instance?.addPostFrameCallback((_) async { + WidgetsBinding.instance.addPostFrameCallback((_) async { final buttonLayout = await schema.get('button-layout') as DBusString?; if (buttonLayout != null) { updateSep(buttonLayout.value); diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 7ba5487..21e2208 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -56,7 +56,7 @@ class _GtkStackSidebarState extends State { Future loadContentPage(BuildContext context) async { if (_popupNotOpen) { _popupNotOpen = false; - SchedulerBinding.instance!.addPostFrameCallback((_) async { + SchedulerBinding.instance.addPostFrameCallback((_) async { final child = Scaffold( body: widget.fullContentBuilder != null ? widget.fullContentBuilder!( @@ -87,7 +87,7 @@ class _GtkStackSidebarState extends State { /// closes popup wind void _closePopup() { if (!_popupNotOpen) { - SchedulerBinding.instance! + SchedulerBinding.instance .addPostFrameCallback((_) => Navigator.pop(context)); } } diff --git a/lib/src/widgets/gtk/toggle_button.dart b/lib/src/widgets/gtk/toggle_button.dart index 1b35ce6..d5519e4 100644 --- a/lib/src/widgets/gtk/toggle_button.dart +++ b/lib/src/widgets/gtk/toggle_button.dart @@ -12,8 +12,11 @@ class GtkToggleButton extends StatelessWidget { required this.isSelected, }) : super(key: key); + /// The List of all the children widgets of this toggle button final List children; + final void Function(int index) onPressed; + final List isSelected; @override diff --git a/pubspec.yaml b/pubspec.yaml index 6ecec8d..c785be3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.2.0-dev +version: 1.2.0 homepage: https://github.com/gtk-flutter/libadwaita environment: @@ -16,15 +16,15 @@ platforms: windows: dependencies: - dbus: ">=0.7.1 <1.0.0" + dbus: ">=0.7.3 <1.0.0" flutter: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" libadwaita_core: ">=0.5.1 < 2.0.0" - package_info_plus: ">=1.3.0 < 2.0.0" + package_info_plus: ">=1.4.2 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" - url_launcher: ">=6.0.18 < 7.0.0" + url_launcher: ">=6.1.2 < 7.0.0" dev_dependencies: very_good_analysis: ^2.4.0 From 50d79d715839e8a0e907206e8d08704b02925ee8 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 14 May 2022 11:44:22 +0530 Subject: [PATCH 40/77] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e74e351..841ed02 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Publish - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 + uses: sakebook/actions-flutter-pub-publisher@v1.4.0 with: credential: ${{ secrets.CREDENTIAL_JSON }} flutter_package: false From 20e1491ac8419c3f5c7b8f2bcd7f4d1fa3225d2a Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 14 May 2022 11:51:01 +0530 Subject: [PATCH 41/77] Update publish.yml --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 841ed02..30799b0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,7 @@ name: Publish plugin on: release: types: [published] + workflow_dispatch: jobs: publish: @@ -13,8 +14,9 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Publish - uses: sakebook/actions-flutter-pub-publisher@v1.4.0 + uses: sakebook/actions-flutter-pub-publisher@v1.3.1 with: credential: ${{ secrets.CREDENTIAL_JSON }} flutter_package: false skip_test: true + dry_run: false From 5cc53c0505232ca4908696507f2c0184d5bd12db Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 26 Jul 2022 21:04:41 +0530 Subject: [PATCH 42/77] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 760e669..ed6d90f 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,14 @@ AdwHeaderBar( [Classic API Docs](https://pub.dev/documentation/libadwaita/latest/) +## Support the development + +To sustain the development of this library we need someone who can help this library either through code or by donating to it. Donation will help us to live up in the world of unmaintained open source packages and to dedicate more time in improving this to live up to the mark. We will also add the name of the contributors or the donaters in the README section. + +To donate directly you can use below link, don't forget to leave a message there: + +Buy Me A Coffee + ## License `Mozilla Public License 2.0` From cdb0c54cedb22557dbf9394216be7b01a8aba708 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 26 Jul 2022 21:17:43 +0530 Subject: [PATCH 43/77] Add Contributors list --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index ed6d90f..c6259b8 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,15 @@ AdwHeaderBar( [Classic API Docs](https://pub.dev/documentation/libadwaita/latest/) +## Contributors +*Based on [Insights](https://github.com/gtk-flutter/libadwaita/graphs/contributors) ranking and the value of commits* + +- [@prateekmedia](https://github.com/prateekmedia) - Creator and Maintainer of this library +- [@simrat39](https://github.com/simrat39) - Added various widgets and Improved example app +- [@MalcolmMielle](https://github.com/MalcolmMielle) - Worked on theming side of adwaita and created CI +- [@jesusrp98](https://github.com/jesusrp98) - Added widgets like `AdwButton`, `AdwAvatar` and improved some widgets +- [@pablojimpas](https://github.com/pablojimpas) - Added `very_good_analysis` and Fixed some code + ## Support the development To sustain the development of this library we need someone who can help this library either through code or by donating to it. Donation will help us to live up in the world of unmaintained open source packages and to dedicate more time in improving this to live up to the mark. We will also add the name of the contributors or the donaters in the README section. From dba57ced67573d8ef00121b0c24fae2b3e74c3ac Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 26 Jul 2022 21:26:19 +0530 Subject: [PATCH 44/77] Update Documentation --- README.md | 56 +++++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index c6259b8..345efd5 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ See the example app in the [`example`](example) folder for more info. ### **This package works great with** -[**`adwaita`**](https://pub.dev/packages/adwaita) / [**`yaru`**](https://github.com/ubuntu/yaru.dart) +[**`adwaita`**](https://pub.dev/packages/adwaita) / [**`yaru`**](https://pub.dev/packages/yaru) For theming ### **Optional packages** @@ -43,19 +43,14 @@ For theming #### [**`adwaita_icons`**](https://pub.dev/packages/adwaita_icons) For Adwaita Icons -#### [**`libadwaita_bitsdojo`**](https://pub.dev/packages/libadwaita_bitsdojo) -Can be used with -- `AdwHeaderBar.bitsdojo` -- `AdwHeaderBar.customBitsdojo` - +#### [**`libadwaita_bitsdojo`**](https://pub.dev/packages/bitsdojo) Example: ```dart import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart'; -AdwHeaderBar.bitsdojo( - ... - appWindow: appWindow, - ... +AdwHeaderBar( + actions: AdwActions().bitsdojo, +//... ) ``` @@ -67,8 +62,9 @@ import 'package:libadwaita_searchbar/libadwaita_searchbar.dart'; bool searchedTerm = ''; AdwSearchBar( - onSubmitted: (str) => setState(() => searchedTerm = str), - controller: const TextEditingController(), + onSubmitted: (str) => setState(() => searchedTerm = str), + controller: const TextEditingController(), +//... ) ``` @@ -80,42 +76,32 @@ import 'package:libadwaita_searchbar_ac/libadwaita_searchbar_ac.dart'; bool searchedTerm = ''; AdwSearchBarAc( - suggestions: const ['Hi', 'Hello'], - onSubmitted: (str) => setState(() => searchedTerm = str), - controller: const TextEditingController(), + suggestions: const ['Hi', 'Hello'], + onSubmitted: (str) => setState(() => searchedTerm = str), + controller: const TextEditingController(), +//... ) ``` -#### [**`nativeshell`**](https://pub.dev/packages/nativeshell ) -Can be used with -- `AdwHeaderBar.nativeshell` -- `AdwHeaderBar.customNativeshell` - +#### [**`libadwaita_nativeshell`**](https://pub.dev/packages/nativeshell ) Example: ```dart -import 'package:nativeshell/nativeshell.dart'; +import 'package:libadwaita_nativeshell/libadwaita_nativeshell.dart'; -AdwHeaderBar.nativeshell( - ... - window: Window.of(context), - ... +AdwHeaderBar( + actions: AdwActions().nativeshell(context), +//... ) ``` -#### [**`titlebar_buttons`**](https://pub.dev/packages/titlebar_buttons) -Can be used with -- `AdwHeaderBar` -- `AdwHeaderBar.bitsdojo` -- `AdwHeaderBar.nativeshell` - +#### [**`libadwaita_titlebar_buttons`**](https://pub.dev/packages/titlebar_buttons) Example: ```dart -import 'package:titlebar_buttons/titlebar_buttons.dart'; +import 'package:libadwaita_titlebar_buttons/libadwaita_titlebar_buttons.dart'; AdwHeaderBar( - ... - windowDecor: windowDecor, - ... + controls: AdwControls().titlebarButtons(), +//... ) ``` From 2ce3f55c5c6c6843dc4d3f13ec047d9b0a425c28 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 31 Jul 2022 16:41:40 +0530 Subject: [PATCH 45/77] Add onRightClick method --- example/pubspec.lock | 4 ++-- lib/src/widgets/adw/header_bar.dart | 5 +++++ pubspec.yaml | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index b36accb..89087db 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -182,7 +182,7 @@ packages: path: ".." relative: true source: path - version: "1.2.0" + version: "1.2.1" libadwaita_bitsdojo: dependency: "direct main" description: @@ -196,7 +196,7 @@ packages: name: libadwaita_core url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.5.2" matcher: dependency: transitive description: diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 1fdc543..8940878 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -70,6 +70,7 @@ class AdwHeaderBar extends StatefulWidget { ), onHeaderDrag = actions.onHeaderDrag, onDoubleTap = actions.onDoubleTap, + onRightClick = actions.onRightClick, super(key: key); /// The leading widget for the headerbar @@ -93,6 +94,9 @@ class AdwHeaderBar extends StatefulWidget { /// Called when headerbar is double tapped final VoidCallback? onDoubleTap; + /// Called when headerbar is right clicked + final VoidCallback? onRightClick; + /// Default style applied to this [AdwHeaderBar] widget. final HeaderBarStyle style; @@ -155,6 +159,7 @@ class _AdwHeaderBarState extends State { return Material( type: MaterialType.transparency, child: GestureDetector( + onSecondaryTap: widget.onRightClick, behavior: HitTestBehavior.translucent, onPanStart: (_) => widget.onHeaderDrag?.call(), child: Align( diff --git a/pubspec.yaml b/pubspec.yaml index c785be3..a3b96a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.2.0 +version: 1.2.1 homepage: https://github.com/gtk-flutter/libadwaita environment: @@ -16,12 +16,12 @@ platforms: windows: dependencies: - dbus: ">=0.7.3 <1.0.0" + dbus: ">=0.7.4 <1.0.0" flutter: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" - libadwaita_core: ">=0.5.1 < 2.0.0" + libadwaita_core: ">=0.5.2 < 2.0.0" package_info_plus: ">=1.4.2 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" url_launcher: ">=6.1.2 < 7.0.0" From d817cf28bb1c1b2dfa18bce25e6d1f01aab3ca60 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 31 Jul 2022 17:01:46 +0530 Subject: [PATCH 46/77] Fix build --- example/pubspec.lock | 56 ++++++++++++++++++++------------------------ example/pubspec.yaml | 18 ++------------ pubspec.yaml | 2 +- 3 files changed, 28 insertions(+), 48 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 89087db..df61e03 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -23,39 +23,33 @@ packages: source: hosted version: "2.8.2" bitsdojo_window_linux: - dependency: "direct overridden" - description: - path: bitsdojo_window_linux - ref: HEAD - resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" - url: "https://github.com/prateekmedia/bitsdojo_window.git" - source: git - version: "0.1.1" + dependency: transitive + description: + name: bitsdojo_window_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" bitsdojo_window_macos: - dependency: "direct overridden" + dependency: transitive description: - path: bitsdojo_window_macos - ref: HEAD - resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" - url: "https://github.com/prateekmedia/bitsdojo_window.git" - source: git - version: "0.1.0" + name: bitsdojo_window_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" bitsdojo_window_platform_interface: dependency: transitive description: name: bitsdojo_window_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.2" bitsdojo_window_windows: - dependency: "direct overridden" + dependency: transitive description: - path: bitsdojo_window_windows - ref: HEAD - resolved-ref: "85e5d1481c52c950f488130d26b5b6dcc48b6d64" - url: "https://github.com/prateekmedia/bitsdojo_window.git" - source: git - version: "0.1.0" + name: bitsdojo_window_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" boolean_selector: dependency: transitive description: @@ -97,14 +91,14 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.3" + version: "0.7.4" desktop_multi_window: dependency: "direct main" description: name: desktop_multi_window url: "https://pub.dartlang.org" source: hosted - version: "0.0.2" + version: "0.1.0" fake_async: dependency: transitive description: @@ -137,7 +131,7 @@ packages: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.1.1+1" flutter_test: dependency: "direct dev" description: flutter @@ -189,14 +183,14 @@ packages: name: libadwaita_bitsdojo url: "https://pub.dartlang.org" source: hosted - version: "0.5.3" + version: "0.5.5" libadwaita_core: dependency: transitive description: name: libadwaita_core url: "https://pub.dartlang.org" source: hosted - version: "0.5.2" + version: "0.5.3" matcher: dependency: transitive description: @@ -460,7 +454,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.4.1" + version: "6.1.0" sdks: - dart: ">=2.17.0-0 <3.0.0" - flutter: ">=2.10.0" + dart: ">=2.17.0 <3.0.0" + flutter: ">=3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index cb764de..23e3129 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,26 +9,12 @@ environment: dependencies: adwaita: "0.5.1" - desktop_multi_window: ">=0.0.1 <1.0.0" + desktop_multi_window: ">=0.1.0 <1.0.0" flutter: sdk: flutter libadwaita: path: ../ - libadwaita_bitsdojo: ^0.5.3 - -dependency_overrides: - bitsdojo_window_linux: - git: - url: https://github.com/prateekmedia/bitsdojo_window.git - path: bitsdojo_window_linux - bitsdojo_window_macos: - git: - url: https://github.com/prateekmedia/bitsdojo_window.git - path: bitsdojo_window_macos - bitsdojo_window_windows: - git: - url: https://github.com/prateekmedia/bitsdojo_window.git - path: bitsdojo_window_windows + libadwaita_bitsdojo: ^0.5.5 dev_dependencies: flutter_test: diff --git a/pubspec.yaml b/pubspec.yaml index a3b96a9..00ee2dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" - libadwaita_core: ">=0.5.2 < 2.0.0" + libadwaita_core: ">=0.5.3 < 2.0.0" package_info_plus: ">=1.4.2 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" url_launcher: ">=6.1.2 < 7.0.0" From 769eccb4bc55e3af3dbe33d49a6113d8aab59335 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 31 Jul 2022 17:15:10 +0530 Subject: [PATCH 47/77] Fix example --- example/example.md | 31 +++++++++++++++++++---------- lib/src/widgets/adw/header_bar.dart | 11 +++++++--- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/example/example.md b/example/example.md index 315933b..2936009 100644 --- a/example/example.md +++ b/example/example.md @@ -3,17 +3,28 @@ ## Demo App [Here](https://github.com/gtk-flutter/libadwaita/tree/main/example) is a demo app made with libadwaita package. -## Search Bar example -[Link](https://pub.dev/packages/libadwaita_searchbar/example) - -## Search Bar with autocomplete example -[Link](https://pub.dev/packages/libadwaita_searchbar_ac/example) - -## [`bitsdojo_window`](https://pub.dev/packages/bitsdojo_window) example +## Plugins +### HeaderBar window actions +#### [`bitsdojo_window`](https://pub.dev/packages/bitsdojo_window) example [Link](https://pub.dev/packages/libadwaita_bitsdojo/example) -## [`nativeshell`](https://pub.dev/packages/nativeshell) example +#### [`nativeshell`](https://pub.dev/packages/nativeshell) example [Link](https://pub.dev/packages/libadwaita_nativeshell/example) -## [`titlebar_buttons`](https://pub.dev/packages/titlebar_buttons) example -[Link](https://pub.dev/packages/libadwaita_titlebar_buttons/example) \ No newline at end of file +#### [`window_manager`](https://pub.dev/packages/window_manager) example +[Link](https://pub.dev/packages/libadwaita_window_manager/example) + +--- + +### HeaderBar control buttons +#### [`titlebar_buttons`](https://pub.dev/packages/titlebar_buttons) example +[Link](https://pub.dev/packages/libadwaita_titlebar_buttons/example) + +--- + +### UI Related +#### Search Bar example +[Link](https://pub.dev/packages/libadwaita_searchbar/example) + +#### Search Bar with [autocomplete](https://pub.dev/packages/easy_autocomplete) example +[Link](https://pub.dev/packages/libadwaita_searchbar_ac/example) diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 8940878..eaf92c8 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -139,9 +139,14 @@ class _AdwHeaderBarState extends State { final schema = GSettings('org.gnome.desktop.wm.preferences'); WidgetsBinding.instance.addPostFrameCallback((_) async { - final buttonLayout = await schema.get('button-layout') as DBusString?; - if (buttonLayout != null) { - updateSep(buttonLayout.value); + try { + final buttonLayout = + await schema.get('button-layout') as DBusString?; + if (buttonLayout != null) { + updateSep(buttonLayout.value); + } + } catch (e) { + debugPrint('$e'); } }); } From be9c1b69253f738f8e3e52f7a4a842bac3d1691a Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 31 Jul 2022 17:27:58 +0530 Subject: [PATCH 48/77] Bump core --- example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index df61e03..d069304 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -190,7 +190,7 @@ packages: name: libadwaita_core url: "https://pub.dartlang.org" source: hosted - version: "0.5.3" + version: "0.5.4" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 00ee2dd..55f9e54 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: sdk: flutter flutter_svg: ">=1.0.3 < 2.0.0" gsettings: ">=0.2.5 <1.0.0" - libadwaita_core: ">=0.5.3 < 2.0.0" + libadwaita_core: ">=0.5.4 < 2.0.0" package_info_plus: ">=1.4.2 < 2.0.0" popover_gtk: ">=0.2.6+3 < 1.0.0" url_launcher: ">=6.1.2 < 7.0.0" From 6d12b34a3f59cb6ccdfcface0ce386d8d94fe9a8 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 31 Jul 2022 17:29:18 +0530 Subject: [PATCH 49/77] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f62c929..ae00215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.2.1 + +* Improve Example +* Upgrade Packages +* Add onRightClick parameter for Headerbar's actions + ## 1.2.0 ### BREAKING From bddd75664781e5ec43e897a0cf762f89550a6d53 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 31 Jul 2022 17:37:37 +0530 Subject: [PATCH 50/77] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 30799b0..0c7eb54 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Publish - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 + uses: sakebook/actions-flutter-pub-publisher@latest with: credential: ${{ secrets.CREDENTIAL_JSON }} flutter_package: false From ab0c99445324351fc1c70cbe4cc1bc7e9adb1cd8 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 31 Jul 2022 17:41:37 +0530 Subject: [PATCH 51/77] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c7eb54..fa5f0bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Publish - uses: sakebook/actions-flutter-pub-publisher@latest + uses: sakebook/actions-flutter-pub-publisher@v1.4.1 with: credential: ${{ secrets.CREDENTIAL_JSON }} flutter_package: false From 05277aed79f28decaa04cdab96a40d757dfde323 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Sun, 7 Aug 2022 12:16:39 +0530 Subject: [PATCH 52/77] Set default header buttons to all at right --- CHANGELOG.md | 4 ++ example/.gitignore | 2 +- example/pubspec.lock | 2 +- lib/src/widgets/adw/about_window.dart | 1 - lib/src/widgets/adw/header_bar.dart | 54 ++++++++++++++++----------- pubspec.yaml | 2 +- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae00215..d9eec25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.2.5 + +* Set default header buttons to min, max and close at the right side + ## 1.2.1 * Improve Example diff --git a/example/.gitignore b/example/.gitignore index c40b591..9be4466 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -51,4 +51,4 @@ windows/* linux/* web/* -!./linux/my_application.cc \ No newline at end of file +!linux/my_application.cc \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index d069304..40331bd 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -176,7 +176,7 @@ packages: path: ".." relative: true source: path - version: "1.2.1" + version: "1.2.5" libadwaita_bitsdojo: dependency: "direct main" description: diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index 28721c6..ff5d764 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -125,7 +125,6 @@ class _AdwAboutWindowState extends State { controls: widget.controls, headerBarStyle: widget.headerBarStyle ?? const HeaderBarStyle( - autoPositionWindowButtons: false, isTransparent: true, ), padding: commonPadding, diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index eaf92c8..62b6f94 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -110,14 +110,12 @@ class _AdwHeaderBarState extends State { widget.minimizeBtn != null || widget.maximizeBtn != null; - late ValueNotifier> separator = - !widget.style.autoPositionWindowButtons || - !kIsWeb && - (Platform.isLinux || Platform.isWindows || Platform.isMacOS) - ? ValueNotifier>( + late ValueNotifier?> separator = + !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) + ? ValueNotifier( ['', 'minimize,maximize,close'], ) - : ValueNotifier>(['', '']); + : ValueNotifier(null); @override void initState() { @@ -126,16 +124,23 @@ class _AdwHeaderBarState extends State { if (widget.style.autoPositionWindowButtons) { void updateSep(String order) { if (!mounted) return; - separator.value = order.split(':'); + separator.value = order.split(':') + ..map( + (e) => e + .split(',') + .where( + (element) => + element == 'close' || + element == 'maximize' || + element == 'minimize', + ) + .join(','), + ); } - if (Platform.isWindows) { - updateSep(':minimize,maximize,close'); - } else if (Platform.isMacOS) { + if (Platform.isMacOS) { updateSep('close,maximize,minimize:'); } else if (Platform.isLinux) { - updateSep(':close'); - final schema = GSettings('org.gnome.desktop.wm.preferences'); WidgetsBinding.instance.addPostFrameCallback((_) async { @@ -189,7 +194,7 @@ class _AdwHeaderBarState extends State { behavior: HitTestBehavior.translucent, onDoubleTap: widget.onDoubleTap, ), - ValueListenableBuilder>( + ValueListenableBuilder?>( valueListenable: separator, builder: (context, sep, _) => DefaultTextStyle.merge( style: const TextStyle( @@ -200,11 +205,15 @@ class _AdwHeaderBarState extends State { leading: Row( mainAxisSize: MainAxisSize.min, children: [ - if (hasWindowControls && sep[0].split(',').isNotEmpty) + if (hasWindowControls && + sep != null && + sep[0].split(',').isNotEmpty) ...[ + SizedBox(width: widget.style.titlebarSpace), + for (var i in sep[0].split(',')) + if (windowButtons[i] != null) windowButtons[i]!, SizedBox(width: widget.style.titlebarSpace), - for (var i in sep[0].split(',')) - if (windowButtons[i] != null) windowButtons[i]!, - ...widget.start + ], + ...widget.start, ], ), middle: widget.title, @@ -212,11 +221,14 @@ class _AdwHeaderBarState extends State { mainAxisSize: MainAxisSize.min, children: [ ...widget.end, - if (hasWindowControls && sep[1].split(',').isNotEmpty) + if (hasWindowControls && + sep != null && + sep[1].split(',').isNotEmpty) ...[ + SizedBox(width: widget.style.titlebarSpace), + for (var i in sep[1].split(',')) + if (windowButtons[i] != null) windowButtons[i]!, SizedBox(width: widget.style.titlebarSpace), - for (var i in sep[1].split(',')) - if (windowButtons[i] != null) windowButtons[i]!, - SizedBox(width: widget.style.titlebarSpace), + ], ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 55f9e54..f99d1cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.2.1 +version: 1.2.5 homepage: https://github.com/gtk-flutter/libadwaita environment: From eea8a1da0135a87763b7830f2bc5fea5be79ddb7 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 13 Aug 2022 21:26:41 +0530 Subject: [PATCH 53/77] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 345efd5..154f39c 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ To sustain the development of this library we need someone who can help this lib To donate directly you can use below link, don't forget to leave a message there: -Buy Me A Coffee +Buy Me A Coffee ## License From 18e891499cf4eecde0e28d4ff78a0cfde46ea4a5 Mon Sep 17 00:00:00 2001 From: KevMCarp <88255595+KevMCarp@users.noreply.github.com> Date: Wed, 5 Oct 2022 18:25:18 +0100 Subject: [PATCH 54/77] remove blur from popup (#76) --- lib/src/widgets/gtk/popup_menu.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/src/widgets/gtk/popup_menu.dart b/lib/src/widgets/gtk/popup_menu.dart index 245ee37..3002e1e 100644 --- a/lib/src/widgets/gtk/popup_menu.dart +++ b/lib/src/widgets/gtk/popup_menu.dart @@ -44,12 +44,6 @@ class _GtkPopupMenuState extends State { showPopover( context: context, arrowHeight: 14, - shadow: [ - BoxShadow( - color: context.borderColor, - blurRadius: 6, - ), - ], barrierColor: Colors.transparent, bodyBuilder: (_) => Padding( padding: const EdgeInsets.all(4), From 76c0150943958eaaad3ab3e6f65e6774cc85ccc4 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 23 Aug 2022 11:58:20 +0530 Subject: [PATCH 55/77] fix: :sparkles: fix the svg for window buttons (maximize one is needs change) Temporary change will switch to Custom Painter in future commit --- assets/icons/close.svg | 11 ++++++----- assets/icons/maximize.svg | 11 ++++++----- assets/icons/minimize.svg | 13 ++++++++----- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/assets/icons/close.svg b/assets/icons/close.svg index 95d0d83..21015b5 100644 --- a/assets/icons/close.svg +++ b/assets/icons/close.svg @@ -1,5 +1,6 @@ - - - - - + + + + + + \ No newline at end of file diff --git a/assets/icons/maximize.svg b/assets/icons/maximize.svg index 79b4615..8846b90 100644 --- a/assets/icons/maximize.svg +++ b/assets/icons/maximize.svg @@ -1,5 +1,6 @@ - - - - - + + + + + + \ No newline at end of file diff --git a/assets/icons/minimize.svg b/assets/icons/minimize.svg index 7600084..3e4b457 100644 --- a/assets/icons/minimize.svg +++ b/assets/icons/minimize.svg @@ -1,5 +1,8 @@ - - - - - + + + + + + + + \ No newline at end of file From 08664c5b95bbd301514158935fb018b0de22dcde Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Tue, 23 Aug 2022 12:04:15 +0530 Subject: [PATCH 56/77] fix: headerbar height, add padding to start and end items --- lib/src/widgets/adw/header_bar.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 62b6f94..50561b6 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -12,7 +12,7 @@ class HeaderBarStyle { const HeaderBarStyle({ this.isTransparent = false, this.textStyle, - this.height = 51, + this.height = 47, this.autoPositionWindowButtons = true, this.padding = const EdgeInsets.only(left: 3, right: 5), this.titlebarSpace = 6, @@ -181,7 +181,6 @@ class _AdwHeaderBarState extends State { : null, border: !widget.style.isTransparent ? Border( - top: BorderSide(color: Theme.of(context).backgroundColor), bottom: BorderSide(color: context.borderColor), ) : null, @@ -213,14 +212,24 @@ class _AdwHeaderBarState extends State { if (windowButtons[i] != null) windowButtons[i]!, SizedBox(width: widget.style.titlebarSpace), ], - ...widget.start, + ...widget.start.map( + (e) => Padding( + padding: const EdgeInsets.only(right: 4), + child: e, + ), + ), ], ), middle: widget.title, trailing: Row( mainAxisSize: MainAxisSize.min, children: [ - ...widget.end, + ...widget.end.map( + (e) => Padding( + padding: const EdgeInsets.only(left: 4), + child: e, + ), + ), if (hasWindowControls && sep != null && sep[1].split(',').isNotEmpty) ...[ From d9f99575d939ea9e2e64caf779cef1894531d216 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Wed, 24 Aug 2022 00:36:56 +0530 Subject: [PATCH 57/77] feat: add windows like controls and window_manager for example --- example/.gitignore | 3 +- example/lib/flap/flap_home_page.dart | 4 +- example/lib/home_page.dart | 9 +- example/lib/main.dart | 28 ++ .../view_switcher_home_page.dart | 4 +- example/linux/my_application.cc | 108 ------- example/pubspec.lock | 62 ++-- example/pubspec.yaml | 7 +- lib/src/internal/window_resize_listener.dart | 2 +- lib/src/widgets/adw/header_bar.dart | 16 +- lib/src/widgets/adw/new/sidebar.dart | 2 +- lib/src/widgets/adw/new/text_field.dart | 2 +- lib/src/widgets/adw/new/window_button.dart | 43 ++- .../adw/new/windows_caption_button.dart | 306 ++++++++++++++++++ lib/src/widgets/gtk/stack_sidebar.dart | 4 +- pubspec.yaml | 2 +- 16 files changed, 419 insertions(+), 183 deletions(-) delete mode 100644 example/linux/my_application.cc create mode 100644 lib/src/widgets/adw/new/windows_caption_button.dart diff --git a/example/.gitignore b/example/.gitignore index 9be4466..a9f262e 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -50,5 +50,4 @@ ios/* windows/* linux/* web/* - -!linux/my_application.cc \ No newline at end of file +macos/* diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index 8b69837..2089e89 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; -import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart'; +import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; class FlapHomePage extends StatefulWidget { const FlapHomePage({Key? key, required this.themeNotifier}) : super(key: key); @@ -49,7 +49,7 @@ class _FlapHomePageState extends State { Widget build(BuildContext context) { return AdwScaffold( flapController: _flapController, - actions: AdwActions().bitsdojo, + actions: AdwActions().windowManager, start: [ Builder( builder: (context) { diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index e1e5344..285b35c 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -10,7 +10,7 @@ import 'package:example/pages/welcome.dart'; import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; -import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart'; +import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -65,7 +65,7 @@ class _MyHomePageState extends State { return AdwScaffold( flapController: _flapController, - actions: AdwActions().bitsdojo, + actions: AdwActions().windowManager, start: [ AdwHeaderButton( icon: const Icon(Icons.view_sidebar_outlined, size: 19), @@ -120,11 +120,6 @@ class _MyHomePageState extends State { issueTrackerLink: 'https://github.com/gtk-flutter/libadwaita/issues', appIcon: Image.asset('assets/logo.png'), - actions: AdwActions( - onClose: Navigator.of(context).pop, - onHeaderDrag: appWindow?.startDragging, - onDoubleTap: appWindow?.maximizeOrRestore, - ), credits: [ AdwPreferencesGroup.credits( title: 'Developers', diff --git a/example/lib/main.dart b/example/lib/main.dart index 526112e..e36cc1a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,6 @@ +import 'dart:async'; import 'dart:convert'; +import 'dart:io'; import 'package:adwaita/adwaita.dart'; import 'package:collection/collection.dart'; @@ -6,6 +8,7 @@ import 'package:example/flap/flap_demo.dart'; import 'package:example/home_page.dart'; import 'package:example/view_switcher/view_switcher_demo.dart'; import 'package:flutter/material.dart'; +import 'package:window_manager/window_manager.dart'; Future main(List args) async { if (args.firstOrNull == 'multi_window') { @@ -22,6 +25,26 @@ Future main(List args) async { break; } } else { + WidgetsFlutterBinding.ensureInitialized(); + await windowManager.ensureInitialized(); + + const windowOptions = WindowOptions( + size: Size(1000, 600), + minimumSize: Size(400, 450), + skipTaskbar: false, + backgroundColor: Colors.transparent, + titleBarStyle: TitleBarStyle.hidden, + title: 'PsTube', + ); + + unawaited( + windowManager.waitUntilReadyToShow(windowOptions, () async { + if (Platform.isLinux) await windowManager.setAsFrameless(); + await windowManager.show(); + await windowManager.focus(); + }), + ); + runApp(MyApp()); } } @@ -38,6 +61,11 @@ class MyApp extends StatelessWidget { valueListenable: themeNotifier, builder: (_, ThemeMode currentMode, __) { return MaterialApp( + builder: (context, child) { + final virtualWindowFrame = VirtualWindowFrameInit(); + + return virtualWindowFrame(context, child); + }, theme: AdwaitaThemeData.light(), darkTheme: AdwaitaThemeData.dark(), debugShowCheckedModeBanner: false, diff --git a/example/lib/view_switcher/view_switcher_home_page.dart b/example/lib/view_switcher/view_switcher_home_page.dart index 55f3e6f..0b61766 100644 --- a/example/lib/view_switcher/view_switcher_home_page.dart +++ b/example/lib/view_switcher/view_switcher_home_page.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; -import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart'; +import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; class ViewSwitcherHomePage extends StatefulWidget { const ViewSwitcherHomePage({Key? key}) : super(key: key); @@ -17,7 +17,7 @@ class _ViewSwitcherHomePageState extends State { return ValueListenableBuilder( valueListenable: index, builder: (context, int value, child) => AdwScaffold( - actions: AdwActions().bitsdojo, + actions: AdwActions().windowManager, viewSwitcher: AdwViewSwitcher( tabs: const [ ViewSwitcherData( diff --git a/example/linux/my_application.cc b/example/linux/my_application.cc deleted file mode 100644 index 5a4065a..0000000 --- a/example/linux/my_application.cc +++ /dev/null @@ -1,108 +0,0 @@ -#include -#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); - auto bdw = bitsdojo_window_from(window); - bdw->setCustomFrame(true); - - 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/example/pubspec.lock b/example/pubspec.lock index 40331bd..df76d23 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -22,34 +22,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.8.2" - bitsdojo_window_linux: - dependency: transitive - description: - name: bitsdojo_window_linux - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - bitsdojo_window_macos: - dependency: transitive - description: - name: bitsdojo_window_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - bitsdojo_window_platform_interface: - dependency: transitive - description: - name: bitsdojo_window_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - bitsdojo_window_windows: - dependency: transitive - description: - name: bitsdojo_window_windows - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" boolean_selector: dependency: transitive description: @@ -98,7 +70,7 @@ packages: name: desktop_multi_window url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.2.0" fake_async: dependency: transitive description: @@ -177,13 +149,6 @@ packages: relative: true source: path version: "1.2.5" - libadwaita_bitsdojo: - dependency: "direct main" - description: - name: libadwaita_bitsdojo - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.5" libadwaita_core: dependency: transitive description: @@ -191,6 +156,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.5.4" + libadwaita_window_manager: + dependency: "direct main" + description: + name: libadwaita_window_manager + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.4+1" matcher: dependency: transitive description: @@ -310,6 +282,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.4" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" sky_engine: dependency: transitive description: flutter @@ -433,7 +412,7 @@ packages: name: very_good_analysis url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "3.0.1" win32: dependency: transitive description: @@ -441,6 +420,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.5.2" + window_manager: + dependency: "direct main" + description: + name: window_manager + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.6" xdg_directories: dependency: transitive description: @@ -456,5 +442,5 @@ packages: source: hosted version: "6.1.0" sdks: - dart: ">=2.17.0 <3.0.0" + dart: ">=2.17.6 <3.0.0" flutter: ">=3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 23e3129..48bfe70 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,17 +9,18 @@ environment: dependencies: adwaita: "0.5.1" - desktop_multi_window: ">=0.1.0 <1.0.0" + desktop_multi_window: ">=0.2.0 <1.0.0" flutter: sdk: flutter libadwaita: path: ../ - libadwaita_bitsdojo: ^0.5.5 + libadwaita_window_manager: ^0.5.4+1 + window_manager: ^0.2.6 dev_dependencies: flutter_test: sdk: flutter - very_good_analysis: ^2.4.0 + very_good_analysis: ^3.0.1 flutter: uses-material-design: true diff --git a/lib/src/internal/window_resize_listener.dart b/lib/src/internal/window_resize_listener.dart index aec5a3c..9e2aaef 100644 --- a/lib/src/internal/window_resize_listener.dart +++ b/lib/src/internal/window_resize_listener.dart @@ -7,7 +7,7 @@ class WindowResizeListener extends StatefulWidget { required this.child, }) : super(key: key); - final Function(Size size) onResize; + final void Function(Size size) onResize; final Widget child; @override diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 50561b6..40d3ee2 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -16,6 +16,7 @@ class HeaderBarStyle { this.autoPositionWindowButtons = true, this.padding = const EdgeInsets.only(left: 3, right: 5), this.titlebarSpace = 6, + this.nativeControls = true, }); /// If true, background color and border color @@ -39,6 +40,10 @@ class HeaderBarStyle { /// The horizontal spacing before or after the window buttons final double titlebarSpace; + + /// Whether to show native controls on Windows or Mac os instead of default + /// libadwaita buttons + final bool nativeControls; } class AdwHeaderBar extends StatefulWidget { @@ -53,18 +58,21 @@ class AdwHeaderBar extends StatefulWidget { }) : closeBtn = controls != null ? controls.closeBtn?.call(actions.onClose) : AdwWindowButton( + nativeControls: style.nativeControls, buttonType: WindowButtonType.close, onPressed: actions.onClose, ), maximizeBtn = controls != null ? controls.maximizeBtn?.call(actions.onMaximize) : AdwWindowButton( + nativeControls: style.nativeControls, buttonType: WindowButtonType.maximize, onPressed: actions.onMaximize, ), minimizeBtn = controls != null ? controls.minimizeBtn?.call(actions.onMinimize) : AdwWindowButton( + nativeControls: style.nativeControls, buttonType: WindowButtonType.minimize, onPressed: actions.onMinimize, ), @@ -210,7 +218,9 @@ class _AdwHeaderBarState extends State { SizedBox(width: widget.style.titlebarSpace), for (var i in sep[0].split(',')) if (windowButtons[i] != null) windowButtons[i]!, - SizedBox(width: widget.style.titlebarSpace), + if (!widget.style.nativeControls || + !kIsWeb && Platform.isLinux) + SizedBox(width: widget.style.titlebarSpace), ], ...widget.start.map( (e) => Padding( @@ -236,7 +246,9 @@ class _AdwHeaderBarState extends State { SizedBox(width: widget.style.titlebarSpace), for (var i in sep[1].split(',')) if (windowButtons[i] != null) windowButtons[i]!, - SizedBox(width: widget.style.titlebarSpace), + if (!widget.style.nativeControls || + !kIsWeb && Platform.isLinux) + SizedBox(width: widget.style.titlebarSpace), ], ], ), diff --git a/lib/src/widgets/adw/new/sidebar.dart b/lib/src/widgets/adw/new/sidebar.dart index 6cda8d8..810a816 100644 --- a/lib/src/widgets/adw/new/sidebar.dart +++ b/lib/src/widgets/adw/new/sidebar.dart @@ -72,7 +72,7 @@ class AdwSidebar extends StatelessWidget { final ScrollController? controller; /// Called when one of the Sidebar item is selected. - final Function(int index) onSelected; + final void Function(int index) onSelected; /// Is the Sidebar present in the Drawer of the Scaffold final bool isDrawer; diff --git a/lib/src/widgets/adw/new/text_field.dart b/lib/src/widgets/adw/new/text_field.dart index b094525..70c189c 100644 --- a/lib/src/widgets/adw/new/text_field.dart +++ b/lib/src/widgets/adw/new/text_field.dart @@ -26,7 +26,7 @@ class AdwTextField extends StatelessWidget { final TextInputType? keyboardType; /// Runs when value is changed from this field - final Function(String)? onChanged; + final void Function(String)? onChanged; /// The suffix icon for this field final IconData? icon; diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index 46ccacb..309218f 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -1,6 +1,9 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:libadwaita/src/utils/colors.dart'; +import 'package:libadwaita/src/widgets/adw/new/windows_caption_button.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; enum WindowButtonType { close, maximize, minimize } @@ -10,6 +13,7 @@ class AdwWindowButton extends StatelessWidget { Key? key, required this.buttonType, required this.onPressed, + required this.nativeControls, }) : super(key: key); /// Executed when this button is pressed @@ -18,22 +22,35 @@ class AdwWindowButton extends StatelessWidget { /// The WindowButtonType for this window final WindowButtonType buttonType; + final bool nativeControls; + @override Widget build(BuildContext context) { return onPressed != null - ? AdwButton.circular( - size: 24, - margin: const EdgeInsets.all(6), - onPressed: onPressed, - child: Center( - child: SvgPicture.asset( - 'packages/libadwaita/assets/icons/${buttonType.name}.svg', - width: 16, - height: 16, - color: context.textColor, - ), - ), - ) + ? !nativeControls || Platform.isLinux + ? AdwButton.circular( + size: 24, + margin: const EdgeInsets.all(6), + onPressed: onPressed, + child: Center( + child: SvgPicture.asset( + 'assets/icons/${buttonType.name}.svg', + width: 16, + package: 'libadwaita', + height: 16, + color: context.textColor, + ), + ), + ) + : Platform.isWindows + ? WindowCaptionButton( + onPressed: onPressed, + brightness: Theme.of(context).brightness, + type: buttonType, + ) + : Platform.isMacOS + ? const SizedBox() + : const SizedBox() : const SizedBox(); } } diff --git a/lib/src/widgets/adw/new/windows_caption_button.dart b/lib/src/widgets/adw/new/windows_caption_button.dart new file mode 100644 index 0000000..896e096 --- /dev/null +++ b/lib/src/widgets/adw/new/windows_caption_button.dart @@ -0,0 +1,306 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:libadwaita/libadwaita.dart'; + +class WindowCaptionButtonIcon extends StatelessWidget { + const WindowCaptionButtonIcon({ + Key? key, + required this.type, + required this.color, + }) : super(key: key); + + final WindowButtonType type; + final Color color; + + @override + Widget build(BuildContext context) { + switch (type) { + case WindowButtonType.close: + return CloseIcon(color: color); + case WindowButtonType.maximize: + return MaximizeIcon(color: color); + case WindowButtonType.minimize: + return MinimizeIcon(color: color); + } + } +} + +// ignore: must_be_immutable +class WindowCaptionButton extends StatefulWidget { + WindowCaptionButton({ + Key? key, + this.brightness, + required this.type, + required this.onPressed, + }) : super(key: key) { + if (type == WindowButtonType.close) { + _lightButtonBgColorScheme = _ButtonBgColorScheme( + normal: Colors.transparent, + hovered: const Color(0xffC42B1C), + pressed: const Color(0xffC42B1C).withOpacity(0.9), + ); + _lightButtonIconColorScheme = _ButtonIconColorScheme( + normal: Colors.black.withOpacity(0.8956), + hovered: Colors.white, + pressed: Colors.white.withOpacity(0.7), + disabled: Colors.black.withOpacity(0.3614), + ); + _darkButtonBgColorScheme = _ButtonBgColorScheme( + normal: Colors.transparent, + hovered: const Color(0xffC42B1C), + pressed: const Color(0xffC42B1C).withOpacity(0.9), + ); + _darkButtonIconColorScheme = _ButtonIconColorScheme( + normal: Colors.white, + hovered: Colors.white, + pressed: Colors.white.withOpacity(0.786), + disabled: Colors.black.withOpacity(0.3628), + ); + } + } + + final Brightness? brightness; + final VoidCallback? onPressed; + final WindowButtonType type; + + _ButtonBgColorScheme _lightButtonBgColorScheme = _ButtonBgColorScheme( + normal: Colors.transparent, + hovered: Colors.black.withOpacity(0.0373), + pressed: Colors.black.withOpacity(0.0241), + ); + _ButtonIconColorScheme _lightButtonIconColorScheme = _ButtonIconColorScheme( + normal: Colors.black.withOpacity(0.8956), + hovered: Colors.black.withOpacity(0.8956), + pressed: Colors.black.withOpacity(0.6063), + disabled: Colors.black.withOpacity(0.3614), + ); + _ButtonBgColorScheme _darkButtonBgColorScheme = _ButtonBgColorScheme( + normal: Colors.transparent, + hovered: Colors.white.withOpacity(0.0605), + pressed: Colors.white.withOpacity(0.0419), + ); + _ButtonIconColorScheme _darkButtonIconColorScheme = _ButtonIconColorScheme( + normal: Colors.white, + hovered: Colors.white, + pressed: Colors.white.withOpacity(0.786), + disabled: Colors.black.withOpacity(0.3628), + ); + + _ButtonBgColorScheme get buttonBgColorScheme => brightness != Brightness.dark + ? _lightButtonBgColorScheme + : _darkButtonBgColorScheme; + + _ButtonIconColorScheme get buttonIconColorScheme => + brightness != Brightness.dark + ? _lightButtonIconColorScheme + : _darkButtonIconColorScheme; + + @override + State createState() => _WindowCaptionButtonState(); +} + +class _WindowCaptionButtonState extends State { + bool _isHovering = false; + bool _isPressed = false; + + void _onEntered({required bool hovered}) { + setState(() => _isHovering = hovered); + } + + void _onActive({required bool pressed}) { + setState(() => _isPressed = pressed); + } + + @override + Widget build(BuildContext context) { + var bgColor = widget.buttonBgColorScheme.normal; + var iconColor = widget.buttonIconColorScheme.normal; + + if (_isHovering) { + bgColor = widget.buttonBgColorScheme.hovered; + iconColor = widget.buttonIconColorScheme.hovered; + } + if (_isPressed) { + bgColor = widget.buttonBgColorScheme.pressed; + iconColor = widget.buttonIconColorScheme.pressed; + } + + return MouseRegion( + onExit: (value) => _onEntered(hovered: false), + onHover: (value) => _onEntered(hovered: true), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTapDown: (_) => _onActive(pressed: true), + onTapCancel: () => _onActive(pressed: false), + onTapUp: (_) => _onActive(pressed: false), + onTap: widget.onPressed, + child: Container( + constraints: const BoxConstraints(minWidth: 46, minHeight: 32), + decoration: BoxDecoration( + color: bgColor, + ), + child: Center( + child: SizedBox( + width: 15, + child: WindowCaptionButtonIcon( + type: widget.type, + color: iconColor, + ), + ), + ), + ), + ), + ); + } +} + +class _ButtonBgColorScheme { + _ButtonBgColorScheme({ + required this.normal, + required this.hovered, + required this.pressed, + }); + final Color normal; + final Color hovered; + final Color pressed; +} + +class _ButtonIconColorScheme { + _ButtonIconColorScheme({ + required this.normal, + required this.hovered, + required this.pressed, + required this.disabled, + }); + final Color normal; + final Color hovered; + final Color pressed; + final Color disabled; +} + +// Switched to CustomPaint icons by https://github.com/esDotDev + +/// Close +class CloseIcon extends StatelessWidget { + const CloseIcon({Key? key, required this.color}) : super(key: key); + final Color color; + @override + Widget build(BuildContext context) => Align( + alignment: Alignment.topLeft, + child: Stack( + children: [ + // Use rotated containers instead of a painter because it renders + // slightly crisper than a painter for some reason. + Transform.rotate( + angle: pi * .25, + child: + Center(child: Container(width: 14, height: 1, color: color)), + ), + Transform.rotate( + angle: pi * -.25, + child: + Center(child: Container(width: 14, height: 1, color: color)), + ), + ], + ), + ); +} + +/// Maximize +class MaximizeIcon extends StatelessWidget { + const MaximizeIcon({Key? key, required this.color}) : super(key: key); + final Color color; + @override + Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); +} + +class _MaximizePainter extends _IconPainter { + _MaximizePainter(Color color) : super(color); + @override + void paint(Canvas canvas, Size size) { + final p = getPaint(color); + canvas.drawRect(Rect.fromLTRB(0, 0, size.width - 1, size.height - 1), p); + } +} + +/// Restore +class RestoreIcon extends StatelessWidget { + const RestoreIcon({ + Key? key, + required this.color, + }) : super(key: key); + final Color color; + @override + Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); +} + +class _RestorePainter extends _IconPainter { + _RestorePainter(Color color) : super(color); + @override + void paint(Canvas canvas, Size size) { + final p = getPaint(color); + canvas + ..drawRect(Rect.fromLTRB(0, 2, size.width - 2, size.height), p) + ..drawLine(const Offset(2, 2), const Offset(2, 0), p) + ..drawLine(const Offset(2, 0), Offset(size.width, 0), p) + ..drawLine( + Offset(size.width, 0), + Offset(size.width, size.height - 2), + p, + ) + ..drawLine( + Offset(size.width, size.height - 2), + Offset(size.width - 2, size.height - 2), + p, + ); + } +} + +/// Minimize +class MinimizeIcon extends StatelessWidget { + const MinimizeIcon({Key? key, required this.color}) : super(key: key); + final Color color; + @override + Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); +} + +class _MinimizePainter extends _IconPainter { + _MinimizePainter(Color color) : super(color); + @override + void paint(Canvas canvas, Size size) { + final p = getPaint(color); + canvas.drawLine( + Offset(0, size.height / 2), + Offset(size.width, size.height / 2), + p, + ); + } +} + +/// Helpers +abstract class _IconPainter extends CustomPainter { + _IconPainter(this.color); + final Color color; + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => false; +} + +class _AlignedPaint extends StatelessWidget { + const _AlignedPaint(this.painter, {Key? key}) : super(key: key); + final CustomPainter painter; + + @override + Widget build(BuildContext context) { + return Align( + child: CustomPaint(size: const Size(10, 10), painter: painter), + ); + } +} + +Paint getPaint(Color color, {bool isAntiAlias = false}) => Paint() + ..color = color + ..style = PaintingStyle.stroke + ..isAntiAlias = isAntiAlias + ..strokeWidth = 1; diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 21e2208..90a7a23 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -27,7 +27,7 @@ class GtkStackSidebar extends StatefulWidget { final int? contentIndex; /// Custom route for then next page of [GtkStackSidebar] - final Route Function(Widget child)? pageRoute; + final Route Function(Widget child)? pageRoute; /// Called when content screen is closed and sidebar is shown final void Function() onContentPopupClosed; @@ -40,7 +40,7 @@ class GtkStackSidebar extends StatefulWidget { final double sidebarWidth; // Content builder on smaller screen - final Function(int? contentIndex, Widget content)? fullContentBuilder; + final void Function(int? contentIndex, Widget content)? fullContentBuilder; @override _GtkStackSidebarState createState() => _GtkStackSidebarState(); diff --git a/pubspec.yaml b/pubspec.yaml index f99d1cc..5c588f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: url_launcher: ">=6.1.2 < 7.0.0" dev_dependencies: - very_good_analysis: ^2.4.0 + very_good_analysis: ^3.0.1 flutter: assets: From c0e1fcf803ef3faa7e6fd0f8c6b5aaecfb574629 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Wed, 24 Aug 2022 09:57:36 +0530 Subject: [PATCH 58/77] fix: multi window now works with window manager ' --- example/pubspec.lock | 10 ++++++---- example/pubspec.yaml | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index df76d23..663517f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -67,10 +67,12 @@ packages: desktop_multi_window: dependency: "direct main" description: - name: desktop_multi_window - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" + path: "." + ref: HEAD + resolved-ref: e013c81d75320bbf28adddeaadf462264ee6039d + url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" + source: git + version: "0.1.0" fake_async: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 48bfe70..38651ce 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,7 +9,9 @@ environment: dependencies: adwaita: "0.5.1" - desktop_multi_window: ">=0.2.0 <1.0.0" + desktop_multi_window: + git: + url: https://github.com/Kingtous/rustdesk_desktop_multi_window flutter: sdk: flutter libadwaita: From a813fe2e4aaf312771d4d9c2ae1e9e4acfc5191c Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Thu, 25 Aug 2022 21:49:35 +0530 Subject: [PATCH 59/77] Add builder for Preferences group --- lib/src/widgets/adw/preferences_group.dart | 70 +++++++++++++++++----- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/lib/src/widgets/adw/preferences_group.dart b/lib/src/widgets/adw/preferences_group.dart index b7733e4..1a827b9 100644 --- a/lib/src/widgets/adw/preferences_group.dart +++ b/lib/src/widgets/adw/preferences_group.dart @@ -2,19 +2,20 @@ import 'package:flutter/material.dart'; class AdwPreferencesGroup extends StatelessWidget { const AdwPreferencesGroup({ - Key? key, - required this.children, + super.key, + required List this.children, this.borderRadius = 12, this.title, this.titleStyle, this.description, this.descriptionStyle, this.padding = const EdgeInsets.symmetric(horizontal: 5), - }) : super(key: key); + }) : itemBuilder = null, + itemCount = null; const AdwPreferencesGroup.credits({ - Key? key, - required this.children, + super.key, + required List this.children, this.borderRadius = 12, this.title, this.titleStyle = const TextStyle( @@ -24,9 +25,39 @@ class AdwPreferencesGroup extends StatelessWidget { this.description, this.descriptionStyle, this.padding = const EdgeInsets.symmetric(horizontal: 5), - }) : super(key: key); + }) : itemBuilder = null, + itemCount = null; - final List children; + const AdwPreferencesGroup.builder({ + super.key, + required Widget Function(BuildContext, int) this.itemBuilder, + required int this.itemCount, + this.borderRadius = 12, + this.title, + this.titleStyle, + this.description, + this.descriptionStyle, + this.padding = const EdgeInsets.symmetric(horizontal: 5), + }) : children = null; + + const AdwPreferencesGroup.creditsBuilder({ + super.key, + required Widget Function(BuildContext, int) this.itemBuilder, + required int this.itemCount, + this.borderRadius = 12, + this.title, + this.titleStyle = const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + this.description, + this.descriptionStyle, + this.padding = const EdgeInsets.symmetric(horizontal: 5), + }) : children = null; + + final List? children; + final Widget Function(BuildContext, int)? itemBuilder; + final int? itemCount; final double borderRadius; final String? title; final String? description; @@ -69,15 +100,22 @@ class AdwPreferencesGroup extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: List.generate( - 2 * children.length - 1, - (index) => index.isEven - ? children[index ~/ 2] - : const Divider(height: 4), - ), - ), + child: children != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List.generate( + 2 * children!.length - 1, + (index) => index.isEven + ? children![index ~/ 2] + : const Divider(height: 4), + ), + ) + : ListView.builder( + shrinkWrap: true, + primary: false, + itemBuilder: itemBuilder!, + itemCount: itemCount, + ), ), ], ); From 523bb2d368065402c04c00000a508e615701f2a4 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Thu, 25 Aug 2022 21:50:21 +0530 Subject: [PATCH 60/77] style: :arrow_up: bump dart to 2.17 and fix lint --- example/lib/home_page.dart | 21 +++++++-------- example/lib/main.dart | 2 +- lib/src/animations/slide_hide.dart | 4 +-- lib/src/internal/window_resize_listener.dart | 4 +-- lib/src/widgets/adw/about_window.dart | 9 +++---- lib/src/widgets/adw/action_row.dart | 4 +-- lib/src/widgets/adw/avatar.dart | 4 +-- lib/src/widgets/adw/button.dart | 22 +++++++--------- lib/src/widgets/adw/clamp.dart | 10 +++---- lib/src/widgets/adw/combo_row.dart | 8 +++--- lib/src/widgets/adw/flap.dart | 5 ++-- lib/src/widgets/adw/header_bar.dart | 5 ++-- lib/src/widgets/adw/new/header_button.dart | 4 +-- lib/src/widgets/adw/new/scaffold.dart | 4 +-- lib/src/widgets/adw/new/sidebar.dart | 15 +++++------ lib/src/widgets/adw/new/switch_row.dart | 4 +-- lib/src/widgets/adw/new/text_field.dart | 4 +-- lib/src/widgets/adw/new/window_button.dart | 4 +-- .../adw/new/windows_caption_button.dart | 26 +++++++++---------- lib/src/widgets/adw/switch.dart | 7 +++-- lib/src/widgets/adw/view_stack.dart | 4 +-- lib/src/widgets/adw/view_switcher.dart | 5 ++-- lib/src/widgets/adw/view_switcher_tab.dart | 7 +++-- lib/src/widgets/gtk/dialog.dart | 4 +-- lib/src/widgets/gtk/popup_menu.dart | 4 +-- lib/src/widgets/gtk/stack_sidebar.dart | 4 +-- lib/src/widgets/gtk/toggle_button.dart | 4 +-- pubspec.yaml | 2 +- 28 files changed, 92 insertions(+), 108 deletions(-) diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 285b35c..6f35f02 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -121,18 +121,17 @@ class _MyHomePageState extends State { 'https://github.com/gtk-flutter/libadwaita/issues', appIcon: Image.asset('assets/logo.png'), credits: [ - AdwPreferencesGroup.credits( + AdwPreferencesGroup.creditsBuilder( title: 'Developers', - children: developers.entries - .map( - (e) => AdwActionRow( - title: e.key, - onActivated: () => launchUrl( - Uri.parse('https://github.com/${e.value}'), - ), - ), - ) - .toList(), + itemCount: developers.length, + itemBuilder: (_, index) => AdwActionRow( + title: developers.keys.elementAt(index), + onActivated: () => launchUrl( + Uri.parse( + 'https://github.com/${developers.values.elementAt(index)}', + ), + ), + ), ), ], copyright: 'Copyright 2021-2022 Gtk-Flutter Developers', diff --git a/example/lib/main.dart b/example/lib/main.dart index e36cc1a..a8c0cd8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -34,7 +34,7 @@ Future main(List args) async { skipTaskbar: false, backgroundColor: Colors.transparent, titleBarStyle: TitleBarStyle.hidden, - title: 'PsTube', + title: 'Libadwaita Example', ); unawaited( diff --git a/lib/src/animations/slide_hide.dart b/lib/src/animations/slide_hide.dart index 9f7802a..870e245 100644 --- a/lib/src/animations/slide_hide.dart +++ b/lib/src/animations/slide_hide.dart @@ -2,11 +2,11 @@ import 'package:flutter/widgets.dart'; class SlideHide extends StatefulWidget { const SlideHide({ - Key? key, + super.key, required this.child, required this.isHidden, required this.width, - }) : super(key: key); + }); final Widget child; final bool isHidden; diff --git a/lib/src/internal/window_resize_listener.dart b/lib/src/internal/window_resize_listener.dart index 9e2aaef..ba922e8 100644 --- a/lib/src/internal/window_resize_listener.dart +++ b/lib/src/internal/window_resize_listener.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; class WindowResizeListener extends StatefulWidget { const WindowResizeListener({ - Key? key, + super.key, required this.onResize, required this.child, - }) : super(key: key); + }); final void Function(Size size) onResize; final Widget child; diff --git a/lib/src/widgets/adw/about_window.dart b/lib/src/widgets/adw/about_window.dart index ff5d764..9ea7f1f 100644 --- a/lib/src/widgets/adw/about_window.dart +++ b/lib/src/widgets/adw/about_window.dart @@ -20,7 +20,7 @@ import 'package:url_launcher/url_launcher.dart'; /// ``` class AdwAboutWindow extends StatefulWidget { const AdwAboutWindow({ - Key? key, + super.key, required this.appIcon, this.appName, this.appVersion, @@ -38,7 +38,7 @@ class AdwAboutWindow extends StatefulWidget { this.issueTrackerLink, this.license, this.credits, - }) : super(key: key); + }); final HeaderBarStyle? headerBarStyle; @@ -136,7 +136,7 @@ class _AdwAboutWindowState extends State { child: widget.appIcon, ), Text( - widget.appName ?? (isNotNull ? data!.appName : '---'), + widget.appName ?? (isNotNull ? data.appName : '---'), style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -148,8 +148,7 @@ class _AdwAboutWindowState extends State { AdwActionRow( title: 'Version', end: Text( - widget.appVersion ?? - (isNotNull ? data!.version : '0'), + widget.appVersion ?? (isNotNull ? data.version : '0'), ), ), if (widget.issueTrackerLink != null) diff --git a/lib/src/widgets/adw/action_row.dart b/lib/src/widgets/adw/action_row.dart index 73312a2..363a6b7 100644 --- a/lib/src/widgets/adw/action_row.dart +++ b/lib/src/widgets/adw/action_row.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; class AdwActionRow extends StatelessWidget { const AdwActionRow({ - Key? key, + super.key, this.start, this.end, required this.title, @@ -12,7 +12,7 @@ class AdwActionRow extends StatelessWidget { this.autofocus = false, this.enabled = true, this.contentPadding, - }) : super(key: key); + }); /// The starting elemets of this row final Widget? start; diff --git a/lib/src/widgets/adw/avatar.dart b/lib/src/widgets/adw/avatar.dart index 3b6cf38..6053fa7 100644 --- a/lib/src/widgets/adw/avatar.dart +++ b/lib/src/widgets/adw/avatar.dart @@ -167,12 +167,12 @@ class AdwAvatarColorPalette { /// cohesive inside the avatar. class AdwAvatar extends StatelessWidget { const AdwAvatar({ - Key? key, + super.key, required this.child, this.size = defaultAvatarSize, this.backgroundColor, this.backgroundImage, - }) : super(key: key); + }); /// Constructor that allows the pass of a `String` object in order to render /// the first letters of the first two words inside the widget. diff --git a/lib/src/widgets/adw/button.dart b/lib/src/widgets/adw/button.dart index 4877b7f..1a61445 100644 --- a/lib/src/widgets/adw/button.dart +++ b/lib/src/widgets/adw/button.dart @@ -27,7 +27,7 @@ Either use builder or use child, Both can't be assigned at one"""; /// their background through the [backgroundColorBuilder] callback. class AdwButton extends StatefulWidget { const AdwButton({ - Key? key, + super.key, this.padding = defaultButtonPadding, this.margin = EdgeInsets.zero, this.builder, @@ -47,14 +47,13 @@ class AdwButton extends StatefulWidget { this.animationDuration = const Duration(milliseconds: 200), this.animationCurve = Curves.easeOutQuad, this.isActive = false, - }) : assert( + }) : assert( builder != null || child != null, _bothBuilderAndChildError, - ), - super(key: key); + ); AdwButton.circular({ - Key? key, + super.key, double size = 34, this.padding = EdgeInsets.zero, this.margin = EdgeInsets.zero, @@ -73,11 +72,10 @@ class AdwButton extends StatefulWidget { }) : assert(builder != null || child != null, _bothBuilderAndChildError), constraints = BoxConstraints.tightFor(width: size, height: size), shape = BoxShape.circle, - borderRadius = null, - super(key: key); + borderRadius = null; const AdwButton.pill({ - Key? key, + super.key, this.padding = const EdgeInsets.symmetric(vertical: 10, horizontal: 32), this.margin = EdgeInsets.zero, this.builder, @@ -97,11 +95,10 @@ class AdwButton extends StatefulWidget { Radius.circular(9999), ), shape = BoxShape.rectangle, - assert(builder != null || child != null, _bothBuilderAndChildError), - super(key: key); + assert(builder != null || child != null, _bothBuilderAndChildError); const AdwButton.flat({ - Key? key, + super.key, this.padding = defaultButtonPadding, this.margin = EdgeInsets.zero, this.builder, @@ -121,8 +118,7 @@ class AdwButton extends StatefulWidget { this.animationCurve = Curves.easeOutQuad, this.isActive = false, }) : opaque = false, - assert(builder != null || child != null, _bothBuilderAndChildError), - super(key: key); + assert(builder != null || child != null, _bothBuilderAndChildError); static const defaultButtonConstrains = BoxConstraints( minHeight: 24, diff --git a/lib/src/widgets/adw/clamp.dart b/lib/src/widgets/adw/clamp.dart index ff9c2ae..2210ce5 100644 --- a/lib/src/widgets/adw/clamp.dart +++ b/lib/src/widgets/adw/clamp.dart @@ -2,26 +2,24 @@ import 'package:flutter/material.dart'; class AdwClamp extends StatefulWidget { const AdwClamp({ - Key? key, + super.key, required this.child, this.maximumSize = 580, this.padding = EdgeInsets.zero, this.margin = const EdgeInsets.all(14), this.center = true, }) : isScrollable = false, - controller = null, - super(key: key); + controller = null; const AdwClamp.scrollable({ - Key? key, + super.key, required this.child, this.center = true, this.controller, this.maximumSize = 580, this.padding = EdgeInsets.zero, this.margin = const EdgeInsets.all(14), - }) : isScrollable = true, - super(key: key); + }) : isScrollable = true; /// Whether this clamp is scrollable or not final bool isScrollable; diff --git a/lib/src/widgets/adw/combo_row.dart b/lib/src/widgets/adw/combo_row.dart index 5395c09..f1f6ede 100644 --- a/lib/src/widgets/adw/combo_row.dart +++ b/lib/src/widgets/adw/combo_row.dart @@ -4,7 +4,7 @@ import 'package:popover_gtk/popover_gtk.dart'; class AdwComboRow extends StatefulWidget { const AdwComboRow({ - Key? key, + super.key, this.choices = const [], this.start, this.end, @@ -16,7 +16,7 @@ class AdwComboRow extends StatefulWidget { this.autofocus = false, this.enabled = true, this.contentPadding, - }) : super(key: key); + }); /// The choices available for this combo row final List choices; @@ -122,11 +122,11 @@ class _AdwComboRowState extends State { class AdwComboButton extends StatefulWidget { const AdwComboButton({ - Key? key, + super.key, this.choices = const [], required this.onSelected, required this.selectedIndex, - }) : super(key: key); + }); /// The choices available for this combo row final List choices; diff --git a/lib/src/widgets/adw/flap.dart b/lib/src/widgets/adw/flap.dart index 635ffd8..dd4d46b 100644 --- a/lib/src/widgets/adw/flap.dart +++ b/lib/src/widgets/adw/flap.dart @@ -51,15 +51,14 @@ class FlapStyle { class AdwFlap extends StatefulWidget { const AdwFlap({ - Key? key, + super.key, required this.flap, required this.child, this.controller, FlapStyle? style, FlapOptions? options, }) : style = style ?? const FlapStyle(), - options = options ?? const FlapOptions(), - super(key: key); + options = options ?? const FlapOptions(); /// The flap widget itself, Mainly is a `AdwSidebar` instance final Widget flap; diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 40d3ee2..ed4c5b3 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -48,7 +48,7 @@ class HeaderBarStyle { class AdwHeaderBar extends StatefulWidget { AdwHeaderBar({ - Key? key, + super.key, this.title, this.start = const [], this.end = const [], @@ -78,8 +78,7 @@ class AdwHeaderBar extends StatefulWidget { ), onHeaderDrag = actions.onHeaderDrag, onDoubleTap = actions.onDoubleTap, - onRightClick = actions.onRightClick, - super(key: key); + onRightClick = actions.onRightClick; /// The leading widget for the headerbar final List start; diff --git a/lib/src/widgets/adw/new/header_button.dart b/lib/src/widgets/adw/new/header_button.dart index 82e91ea..f080d9e 100644 --- a/lib/src/widgets/adw/new/header_button.dart +++ b/lib/src/widgets/adw/new/header_button.dart @@ -6,11 +6,11 @@ import 'package:libadwaita/src/widgets/adw/button.dart'; /// Via the `icon` parameter, a widget can be placed inside the button. class AdwHeaderButton extends StatelessWidget { const AdwHeaderButton({ - Key? key, + super.key, required this.icon, this.isActive = false, this.onPressed, - }) : super(key: key); + }); /// The icon of the button. Default size would be `17`. final Widget icon; diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 73aa12e..660affb 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -6,7 +6,7 @@ import 'package:libadwaita_core/libadwaita_core.dart'; class AdwScaffold extends StatefulWidget { const AdwScaffold({ - Key? key, + super.key, required this.body, this.flap, this.flapStyle, @@ -22,7 +22,7 @@ class AdwScaffold extends StatefulWidget { this.end, required this.actions, this.controls, - }) : super(key: key); + }); final Widget body; diff --git a/lib/src/widgets/adw/new/sidebar.dart b/lib/src/widgets/adw/new/sidebar.dart index 810a816..87eb2e2 100644 --- a/lib/src/widgets/adw/new/sidebar.dart +++ b/lib/src/widgets/adw/new/sidebar.dart @@ -11,7 +11,7 @@ Either use label or use labelWidget, both can't be assigned at once."""; /// children on demand. class AdwSidebar extends StatelessWidget { AdwSidebar({ - Key? key, + super.key, required this.currentIndex, required this.onSelected, this.width = 270.0, @@ -20,7 +20,7 @@ class AdwSidebar extends StatelessWidget { this.controller, this.padding = const EdgeInsets.symmetric(vertical: 6, horizontal: 6), required List children, - }) : _childrenDelegate = List.generate( + }) : _childrenDelegate = List.generate( children.length, (index) => _AdwSidebarItemBuilder( item: (context) => children[index], @@ -28,11 +28,10 @@ class AdwSidebar extends StatelessWidget { isSelected: index == currentIndex, onSelected: () => onSelected(index), ), - ), - super(key: key); + ); AdwSidebar.builder({ - Key? key, + super.key, required this.currentIndex, required this.onSelected, this.width = 270.0, @@ -57,8 +56,7 @@ class AdwSidebar extends StatelessWidget { isDrawer: isDrawer, onSelected: () => onSelected(index), ), - ), - super(key: key); + ); /// The current index of the item selected. final int? currentIndex; @@ -152,12 +150,11 @@ class AdwSidebarItem { class _AdwSidebarItemBuilder extends StatelessWidget { const _AdwSidebarItemBuilder({ - Key? key, required this.item, required this.isSelected, required this.isDrawer, this.onSelected, - }) : super(key: key); + }); final AdwSidebarItem Function(BuildContext context) item; final bool isSelected; diff --git a/lib/src/widgets/adw/new/switch_row.dart b/lib/src/widgets/adw/new/switch_row.dart index 8b9de83..e1449d9 100644 --- a/lib/src/widgets/adw/new/switch_row.dart +++ b/lib/src/widgets/adw/new/switch_row.dart @@ -3,7 +3,7 @@ import 'package:libadwaita/libadwaita.dart'; class AdwSwitchRow extends StatefulWidget { const AdwSwitchRow({ - Key? key, + super.key, this.start, required this.value, required this.onChanged, @@ -13,7 +13,7 @@ class AdwSwitchRow extends StatefulWidget { this.autofocus = false, this.enabled = true, this.contentPadding, - }) : super(key: key); + }); /// The value of the switch final bool value; diff --git a/lib/src/widgets/adw/new/text_field.dart b/lib/src/widgets/adw/new/text_field.dart index 70c189c..5b40c0b 100644 --- a/lib/src/widgets/adw/new/text_field.dart +++ b/lib/src/widgets/adw/new/text_field.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; class AdwTextField extends StatelessWidget { const AdwTextField({ - Key? key, + super.key, this.controller, this.keyboardType, this.onChanged, @@ -11,7 +11,7 @@ class AdwTextField extends StatelessWidget { this.onSubmitted, this.initialValue, this.autofocus = false, - }) : super(key: key); + }); /// Will automatically focus on this field when it's visible final bool autofocus; diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index 309218f..fd24d9e 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -10,11 +10,11 @@ enum WindowButtonType { close, maximize, minimize } class AdwWindowButton extends StatelessWidget { const AdwWindowButton({ - Key? key, + super.key, required this.buttonType, required this.onPressed, required this.nativeControls, - }) : super(key: key); + }); /// Executed when this button is pressed final VoidCallback? onPressed; diff --git a/lib/src/widgets/adw/new/windows_caption_button.dart b/lib/src/widgets/adw/new/windows_caption_button.dart index 896e096..5041d58 100644 --- a/lib/src/widgets/adw/new/windows_caption_button.dart +++ b/lib/src/widgets/adw/new/windows_caption_button.dart @@ -5,10 +5,10 @@ import 'package:libadwaita/libadwaita.dart'; class WindowCaptionButtonIcon extends StatelessWidget { const WindowCaptionButtonIcon({ - Key? key, + super.key, required this.type, required this.color, - }) : super(key: key); + }); final WindowButtonType type; final Color color; @@ -29,11 +29,11 @@ class WindowCaptionButtonIcon extends StatelessWidget { // ignore: must_be_immutable class WindowCaptionButton extends StatefulWidget { WindowCaptionButton({ - Key? key, + super.key, this.brightness, required this.type, required this.onPressed, - }) : super(key: key) { + }) { if (type == WindowButtonType.close) { _lightButtonBgColorScheme = _ButtonBgColorScheme( normal: Colors.transparent, @@ -183,7 +183,7 @@ class _ButtonIconColorScheme { /// Close class CloseIcon extends StatelessWidget { - const CloseIcon({Key? key, required this.color}) : super(key: key); + const CloseIcon({super.key, required this.color}); final Color color; @override Widget build(BuildContext context) => Align( @@ -209,14 +209,14 @@ class CloseIcon extends StatelessWidget { /// Maximize class MaximizeIcon extends StatelessWidget { - const MaximizeIcon({Key? key, required this.color}) : super(key: key); + const MaximizeIcon({super.key, required this.color}); final Color color; @override Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); } class _MaximizePainter extends _IconPainter { - _MaximizePainter(Color color) : super(color); + _MaximizePainter(super.color); @override void paint(Canvas canvas, Size size) { final p = getPaint(color); @@ -227,16 +227,16 @@ class _MaximizePainter extends _IconPainter { /// Restore class RestoreIcon extends StatelessWidget { const RestoreIcon({ - Key? key, + super.key, required this.color, - }) : super(key: key); + }); final Color color; @override Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); } class _RestorePainter extends _IconPainter { - _RestorePainter(Color color) : super(color); + _RestorePainter(super.color); @override void paint(Canvas canvas, Size size) { final p = getPaint(color); @@ -259,14 +259,14 @@ class _RestorePainter extends _IconPainter { /// Minimize class MinimizeIcon extends StatelessWidget { - const MinimizeIcon({Key? key, required this.color}) : super(key: key); + const MinimizeIcon({super.key, required this.color}); final Color color; @override Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); } class _MinimizePainter extends _IconPainter { - _MinimizePainter(Color color) : super(color); + _MinimizePainter(super.color); @override void paint(Canvas canvas, Size size) { final p = getPaint(color); @@ -288,7 +288,7 @@ abstract class _IconPainter extends CustomPainter { } class _AlignedPaint extends StatelessWidget { - const _AlignedPaint(this.painter, {Key? key}) : super(key: key); + const _AlignedPaint(this.painter); final CustomPainter painter; @override diff --git a/lib/src/widgets/adw/switch.dart b/lib/src/widgets/adw/switch.dart index 3e08890..78590d2 100644 --- a/lib/src/widgets/adw/switch.dart +++ b/lib/src/widgets/adw/switch.dart @@ -54,14 +54,14 @@ class AdwSwitch extends StatefulWidget { /// The [dragStartBehavior] parameter defaults to [DragStartBehavior.start] /// and must not be null. const AdwSwitch({ - Key? key, + super.key, required this.value, required this.onChanged, this.activeColor, this.trackColor, this.thumbColor, this.dragStartBehavior = DragStartBehavior.start, - }) : super(key: key); + }); /// Whether this switch is on or off. /// @@ -344,7 +344,6 @@ class _AdwSwitchState extends State with TickerProviderStateMixin { class _AdwSwitchRenderObjectWidget extends LeafRenderObjectWidget { const _AdwSwitchRenderObjectWidget({ - Key? key, required this.value, required this.activeColor, required this.trackColor, @@ -352,7 +351,7 @@ class _AdwSwitchRenderObjectWidget extends LeafRenderObjectWidget { required this.onChanged, required this.textDirection, required this.state, - }) : super(key: key); + }); final bool value; final Color activeColor; diff --git a/lib/src/widgets/adw/view_stack.dart b/lib/src/widgets/adw/view_stack.dart index 0207b2b..5e26ec6 100644 --- a/lib/src/widgets/adw/view_stack.dart +++ b/lib/src/widgets/adw/view_stack.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; class AdwViewStack extends StatefulWidget { const AdwViewStack({ - Key? key, + super.key, this.index, required this.children, this.animationDuration = const Duration(milliseconds: 450), - }) : super(key: key); + }); final int? index; final List children; diff --git a/lib/src/widgets/adw/view_switcher.dart b/lib/src/widgets/adw/view_switcher.dart index 330a0df..98d12ee 100644 --- a/lib/src/widgets/adw/view_switcher.dart +++ b/lib/src/widgets/adw/view_switcher.dart @@ -4,7 +4,7 @@ import 'package:libadwaita/src/widgets/widgets.dart'; class AdwViewSwitcher extends StatelessWidget { const AdwViewSwitcher({ - Key? key, + super.key, required this.tabs, required this.onViewChanged, required this.currentIndex, @@ -18,8 +18,7 @@ class AdwViewSwitcher extends StatelessWidget { ) bool? expanded, this.paddingIcon, - }) : assert(tabs.length >= 2, 'Minimum 2 tabs are required'), - super(key: key); + }) : assert(tabs.length >= 2, 'Minimum 2 tabs are required'); /// The color of the badge at the top right of the tab's icon final Color? badgeColor; diff --git a/lib/src/widgets/adw/view_switcher_tab.dart b/lib/src/widgets/adw/view_switcher_tab.dart index 0defee7..0714d05 100644 --- a/lib/src/widgets/adw/view_switcher_tab.dart +++ b/lib/src/widgets/adw/view_switcher_tab.dart @@ -3,14 +3,14 @@ import 'package:libadwaita/libadwaita.dart'; class AdwViewSwitcherTab extends StatelessWidget { const AdwViewSwitcherTab({ - Key? key, + super.key, required this.data, required this.policy, this.badgeColor, this.isSelected = false, this.onSelected, this.paddingIcon, - }) : super(key: key); + }); /// The color of the badge at the top right of the tab's icon final Color? badgeColor; @@ -93,10 +93,9 @@ class AdwViewSwitcherTab extends StatelessWidget { class _AdwViewSwitcherTabLayout extends StatelessWidget { const _AdwViewSwitcherTabLayout({ - Key? key, required this.isRow, required this.children, - }) : super(key: key); + }); final List children; final bool isRow; diff --git a/lib/src/widgets/gtk/dialog.dart b/lib/src/widgets/gtk/dialog.dart index 6835bd5..53cf01b 100644 --- a/lib/src/widgets/gtk/dialog.dart +++ b/lib/src/widgets/gtk/dialog.dart @@ -4,7 +4,7 @@ import 'package:libadwaita_core/libadwaita_core.dart'; class GtkDialog extends StatelessWidget { const GtkDialog({ - Key? key, + super.key, this.headerBarStyle, this.start, this.title, @@ -16,7 +16,7 @@ class GtkDialog extends StatelessWidget { this.height, this.width, required this.children, - }) : super(key: key); + }); final HeaderBarStyle? headerBarStyle; diff --git a/lib/src/widgets/gtk/popup_menu.dart b/lib/src/widgets/gtk/popup_menu.dart index 3002e1e..ef9731e 100644 --- a/lib/src/widgets/gtk/popup_menu.dart +++ b/lib/src/widgets/gtk/popup_menu.dart @@ -8,12 +8,12 @@ class AdwPopupMenu {} class GtkPopupMenu extends StatefulWidget { const GtkPopupMenu({ - Key? key, + super.key, required this.body, this.icon = const Icon(Icons.menu, size: 17), this.popupWidth = 200, this.popupHeight, - }) : super(key: key); + }); /// The body of the popup final Widget body; diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 90a7a23..cbb777e 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -7,7 +7,7 @@ class AdwStackSidebar {} class GtkStackSidebar extends StatefulWidget { const GtkStackSidebar({ - Key? key, + super.key, required this.sidebar, required this.content, this.separator, @@ -17,7 +17,7 @@ class GtkStackSidebar extends StatefulWidget { this.contentIndex, this.pageRoute, this.fullContentBuilder, - }) : super(key: key); + }); final Widget sidebar; final Widget content; diff --git a/lib/src/widgets/gtk/toggle_button.dart b/lib/src/widgets/gtk/toggle_button.dart index d5519e4..ee03f78 100644 --- a/lib/src/widgets/gtk/toggle_button.dart +++ b/lib/src/widgets/gtk/toggle_button.dart @@ -6,11 +6,11 @@ class AdwToggleButton {} class GtkToggleButton extends StatelessWidget { const GtkToggleButton({ - Key? key, + super.key, required this.children, required this.onPressed, required this.isSelected, - }) : super(key: key); + }); /// The List of all the children widgets of this toggle button final List children; diff --git a/pubspec.yaml b/pubspec.yaml index 5c588f3..a54ccb3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.2.5 homepage: https://github.com/gtk-flutter/libadwaita environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" flutter: ">=1.17.0" platforms: From 21e13160aabb70db82b8d12c626329ddd474abe2 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Fri, 26 Aug 2022 11:49:41 +0530 Subject: [PATCH 61/77] fix: return type of flap --- lib/src/widgets/adw/new/scaffold.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 660affb..cb2b27c 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -26,7 +26,7 @@ class AdwScaffold extends StatefulWidget { final Widget body; - final AdwSidebar Function(bool isDrawer)? flap; + final Widget Function(bool isDrawer)? flap; final FlapController? flapController; From 5329b68ad203f9defa13c274086abf61747f8a3d Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Wed, 5 Oct 2022 23:06:33 +0530 Subject: [PATCH 62/77] bump package version --- example/pubspec.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 663517f..3a1154f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -79,7 +79,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -171,21 +171,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_info_plus: dependency: transitive description: @@ -234,7 +234,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_drawing: dependency: transitive description: @@ -302,7 +302,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -323,21 +323,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: From 01a267e1311a154276d8b0dce2fdadb98f6df528 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Wed, 5 Oct 2022 23:24:16 +0530 Subject: [PATCH 63/77] Update width of windows caption button --- lib/src/widgets/adw/new/windows_caption_button.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/new/windows_caption_button.dart b/lib/src/widgets/adw/new/windows_caption_button.dart index 5041d58..35f384b 100644 --- a/lib/src/widgets/adw/new/windows_caption_button.dart +++ b/lib/src/widgets/adw/new/windows_caption_button.dart @@ -136,7 +136,7 @@ class _WindowCaptionButtonState extends State { onTapUp: (_) => _onActive(pressed: false), onTap: widget.onPressed, child: Container( - constraints: const BoxConstraints(minWidth: 46, minHeight: 32), + constraints: const BoxConstraints(minWidth: 58, minHeight: 32), decoration: BoxDecoration( color: bgColor, ), From 5389e2c317343f83bb9634c1d1228c3c03befc91 Mon Sep 17 00:00:00 2001 From: Prateek SU Date: Thu, 13 Oct 2022 19:01:35 +0530 Subject: [PATCH 64/77] Try adding scaffold key --- lib/src/controllers/flap_controller.dart | 4 ++++ lib/src/widgets/adw/new/scaffold.dart | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/src/controllers/flap_controller.dart b/lib/src/controllers/flap_controller.dart index d96b31a..1af21b6 100644 --- a/lib/src/controllers/flap_controller.dart +++ b/lib/src/controllers/flap_controller.dart @@ -2,6 +2,10 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/src/widgets/adw/flap.dart'; class FlapController extends ChangeNotifier { + FlapController([this.key]); + + final Key? key; + bool isOpen = true; bool isModal = false; diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index cb2b27c..155f006 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -7,6 +7,7 @@ import 'package:libadwaita_core/libadwaita_core.dart'; class AdwScaffold extends StatefulWidget { const AdwScaffold({ super.key, + this.scaffoldKey, required this.body, this.flap, this.flapStyle, @@ -24,6 +25,8 @@ class AdwScaffold extends StatefulWidget { this.controls, }); + final Key? scaffoldKey; + final Widget body; final Widget Function(bool isDrawer)? flap; @@ -90,6 +93,7 @@ class _AdwScaffoldState extends State { ), Expanded( child: Scaffold( + key: widget.scaffoldKey, drawerEnableOpenDragGesture: _flapController ?.shouldEnableDrawerGesture(FlapPosition.start) ?? false, From 127b936c385a66cd208fbbde8e3ee3c7867df4d7 Mon Sep 17 00:00:00 2001 From: poojasunal <115683468+poojasunal@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:49:10 +0530 Subject: [PATCH 65/77] Added documentation for various widgets (#78) * Lint fix * docs: added documentation for various widgets --- lib/src/widgets/adw/preferences_group.dart | 12 ++++++++++++ lib/src/widgets/adw/view_stack.dart | 6 ++++++ lib/src/widgets/adw/view_switcher_tab.dart | 3 +++ lib/src/widgets/gtk/dialog.dart | 17 +++++++++++++++++ lib/src/widgets/gtk/popup_menu.dart | 1 - lib/src/widgets/gtk/stack_sidebar.dart | 5 +++++ lib/src/widgets/gtk/toggle_button.dart | 2 ++ 7 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/preferences_group.dart b/lib/src/widgets/adw/preferences_group.dart index b7733e4..a3f0d45 100644 --- a/lib/src/widgets/adw/preferences_group.dart +++ b/lib/src/widgets/adw/preferences_group.dart @@ -26,13 +26,25 @@ class AdwPreferencesGroup extends StatelessWidget { this.padding = const EdgeInsets.symmetric(horizontal: 5), }) : super(key: key); + /// List of all the elements in this group final List children; + + /// The border radius of this visit final double borderRadius; + + /// The title of this preferences group final String? title; + + /// The description of this preferences group final String? description; + + /// The padding around this preferences group final EdgeInsets padding; + /// The style of the title text of this group final TextStyle? titleStyle; + + /// The style of the description text of this group final TextStyle? descriptionStyle; @override diff --git a/lib/src/widgets/adw/view_stack.dart b/lib/src/widgets/adw/view_stack.dart index 0207b2b..b3b1b52 100644 --- a/lib/src/widgets/adw/view_stack.dart +++ b/lib/src/widgets/adw/view_stack.dart @@ -8,8 +8,14 @@ class AdwViewStack extends StatefulWidget { this.animationDuration = const Duration(milliseconds: 450), }) : super(key: key); + /// The selected index of the element in this view stack final int? index; + + /// All the elements in this view stack final List children; + + /// The duration of the animation while switching the elements + /// in this view stack final Duration animationDuration; @override diff --git a/lib/src/widgets/adw/view_switcher_tab.dart b/lib/src/widgets/adw/view_switcher_tab.dart index 0defee7..54b227d 100644 --- a/lib/src/widgets/adw/view_switcher_tab.dart +++ b/lib/src/widgets/adw/view_switcher_tab.dart @@ -98,7 +98,10 @@ class _AdwViewSwitcherTabLayout extends StatelessWidget { required this.children, }) : super(key: key); + /// The list of all the child widget final List children; + + /// Whether this tab layout is row or column final bool isRow; @override diff --git a/lib/src/widgets/gtk/dialog.dart b/lib/src/widgets/gtk/dialog.dart index 6835bd5..663a05e 100644 --- a/lib/src/widgets/gtk/dialog.dart +++ b/lib/src/widgets/gtk/dialog.dart @@ -18,20 +18,37 @@ class GtkDialog extends StatelessWidget { required this.children, }) : super(key: key); + /// The style of the header bar in this dialog final HeaderBarStyle? headerBarStyle; + /// The starting elements of the header bar in this dialog final List? start; + + /// The title of the header bar in this dialog final Widget? title; + + /// The ending elements of the header bar in this dialog final List? end; + /// The window button actions of the header bar in this dialog final AdwActions? actions; + + /// The window button controls of the header bar in this dialog final AdwControls? controls; + /// The padding around the childrens of this dialog final EdgeInsets? padding; + + /// The list of child widgets in this dialog final List children; + /// The box constraints of this dialog final BoxConstraints? constraints; + + /// The height of this dialog, will be ignored when constraints are provided final double? height; + + /// The width of this dialog, will be ignored when constraints are provided final double? width; @override diff --git a/lib/src/widgets/gtk/popup_menu.dart b/lib/src/widgets/gtk/popup_menu.dart index 3002e1e..8c59c3c 100644 --- a/lib/src/widgets/gtk/popup_menu.dart +++ b/lib/src/widgets/gtk/popup_menu.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:libadwaita/src/utils/colors.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; import 'package:popover_gtk/popover_gtk.dart'; diff --git a/lib/src/widgets/gtk/stack_sidebar.dart b/lib/src/widgets/gtk/stack_sidebar.dart index 21e2208..a5f0416 100644 --- a/lib/src/widgets/gtk/stack_sidebar.dart +++ b/lib/src/widgets/gtk/stack_sidebar.dart @@ -19,8 +19,13 @@ class GtkStackSidebar extends StatefulWidget { this.fullContentBuilder, }) : super(key: key); + /// The `AdwSidebar` widget or any other widget as the sidebar final Widget sidebar; + + /// The content section for this stack sidebar final Widget content; + + /// This is a widget between the `sidebar` and the `content` final Widget? separator; /// Keeps track of the content index diff --git a/lib/src/widgets/gtk/toggle_button.dart b/lib/src/widgets/gtk/toggle_button.dart index d5519e4..0e82e01 100644 --- a/lib/src/widgets/gtk/toggle_button.dart +++ b/lib/src/widgets/gtk/toggle_button.dart @@ -15,8 +15,10 @@ class GtkToggleButton extends StatelessWidget { /// The List of all the children widgets of this toggle button final List children; + /// This will toggle to the pressed child final void Function(int index) onPressed; + /// This is the list of selection state of the children final List isSelected; @override From 4bfa4e7a6b3dab0b369b808865a6cc90f60a3571 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Fri, 19 May 2023 16:40:26 +0530 Subject: [PATCH 66/77] feat: add traffic lights headerbar for macos --- .vscode/settings.json | 3 + analysis_options.yaml | 1 + example/lib/flap/flap_demo.dart | 2 +- example/lib/flap/flap_home_page.dart | 2 +- example/lib/home_page.dart | 2 +- example/lib/main.dart | 6 +- example/lib/pages/avatar_page.dart | 2 +- example/lib/pages/counter_page.dart | 2 +- example/lib/pages/flap_page.dart | 2 +- example/lib/pages/lists_page.dart | 2 +- example/lib/pages/run_demo_screen.dart | 13 +- example/lib/pages/settings_page.dart | 2 +- example/lib/pages/style_classes_page.dart | 2 +- example/lib/pages/view_switcher_page.dart | 2 +- example/lib/pages/welcome.dart | 2 +- .../lib/view_switcher/view_switcher_demo.dart | 2 +- .../view_switcher_home_page.dart | 2 +- example/pubspec.lock | 293 ++++++++++-------- example/pubspec.yaml | 13 +- lib/src/internal/window_resize_listener.dart | 8 +- lib/src/utils/colors.dart | 12 +- lib/src/widgets/adw/header_bar.dart | 2 +- .../widgets/adw/new/macos_caption_button.dart | 251 +++++++++++++++ lib/src/widgets/adw/new/sidebar.dart | 5 +- lib/src/widgets/adw/new/text_field.dart | 4 +- lib/src/widgets/adw/new/window_button.dart | 9 +- .../adw/new/windows_caption_button.dart | 2 +- lib/src/widgets/adw/preferences_group.dart | 34 +- pubspec.yaml | 14 +- 29 files changed, 514 insertions(+), 182 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 lib/src/widgets/adw/new/macos_caption_button.dart diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cad7657 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 0e3f2c0..2258921 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -5,6 +5,7 @@ linter: public_member_api_docs: false library_private_types_in_public_api: false avoid_setters_without_getters: false + avoid_positional_boolean_parameters: false # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/example/lib/flap/flap_demo.dart b/example/lib/flap/flap_demo.dart index 101e332..e3d5f93 100644 --- a/example/lib/flap/flap_demo.dart +++ b/example/lib/flap/flap_demo.dart @@ -3,7 +3,7 @@ import 'package:example/flap/flap_home_page.dart'; import 'package:flutter/material.dart'; class FlapDemo extends StatelessWidget { - FlapDemo({Key? key}) : super(key: key); + FlapDemo({super.key}); final ValueNotifier themeNotifier = ValueNotifier(ThemeMode.system); diff --git a/example/lib/flap/flap_home_page.dart b/example/lib/flap/flap_home_page.dart index 2089e89..4ff04f7 100644 --- a/example/lib/flap/flap_home_page.dart +++ b/example/lib/flap/flap_home_page.dart @@ -3,7 +3,7 @@ import 'package:libadwaita/libadwaita.dart'; import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; class FlapHomePage extends StatefulWidget { - const FlapHomePage({Key? key, required this.themeNotifier}) : super(key: key); + const FlapHomePage({super.key, required this.themeNotifier}); final ValueNotifier themeNotifier; diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 6f35f02..5ba3eac 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -15,7 +15,7 @@ import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; import 'package:url_launcher/url_launcher.dart'; class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.themeNotifier}) : super(key: key); + const MyHomePage({super.key, required this.themeNotifier}); final ValueNotifier themeNotifier; diff --git a/example/lib/main.dart b/example/lib/main.dart index a8c0cd8..24e8a0a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,7 +39,9 @@ Future main(List args) async { unawaited( windowManager.waitUntilReadyToShow(windowOptions, () async { - if (Platform.isLinux) await windowManager.setAsFrameless(); + if (Platform.isLinux || Platform.isMacOS) { + await windowManager.setAsFrameless(); + } await windowManager.show(); await windowManager.focus(); }), @@ -50,7 +52,7 @@ Future main(List args) async { } class MyApp extends StatelessWidget { - MyApp({Key? key}) : super(key: key); + MyApp({super.key}); final ValueNotifier themeNotifier = ValueNotifier(ThemeMode.system); diff --git a/example/lib/pages/avatar_page.dart b/example/lib/pages/avatar_page.dart index 39dc722..10dfea4 100644 --- a/example/lib/pages/avatar_page.dart +++ b/example/lib/pages/avatar_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; class AvatarPage extends StatelessWidget { - const AvatarPage({Key? key}) : super(key: key); + const AvatarPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/counter_page.dart b/example/lib/pages/counter_page.dart index c7ca347..6f769bf 100644 --- a/example/lib/pages/counter_page.dart +++ b/example/lib/pages/counter_page.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; class CounterPage extends StatefulWidget { - const CounterPage({Key? key, required this.counter}) : super(key: key); + const CounterPage({super.key, required this.counter}); final ValueNotifier counter; diff --git a/example/lib/pages/flap_page.dart b/example/lib/pages/flap_page.dart index 34af964..3d7651d 100644 --- a/example/lib/pages/flap_page.dart +++ b/example/lib/pages/flap_page.dart @@ -2,7 +2,7 @@ import 'package:example/pages/run_demo_screen.dart'; import 'package:flutter/material.dart'; class FlapPage extends StatelessWidget { - const FlapPage({Key? key}) : super(key: key); + const FlapPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/lists_page.dart b/example/lib/pages/lists_page.dart index 78b95a7..8e158a1 100644 --- a/example/lib/pages/lists_page.dart +++ b/example/lib/pages/lists_page.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; class ListsPage extends StatelessWidget { - const ListsPage({Key? key}) : super(key: key); + const ListsPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/run_demo_screen.dart b/example/lib/pages/run_demo_screen.dart index 3289e39..c470fe5 100644 --- a/example/lib/pages/run_demo_screen.dart +++ b/example/lib/pages/run_demo_screen.dart @@ -8,16 +8,16 @@ import 'package:libadwaita/libadwaita.dart'; class DemoScreen extends StatelessWidget { const DemoScreen({ - Key? key, + super.key, required this.title, required this.description, this.secondDescription, this.image, this.footer, - }) : super(key: key); + }); DemoScreen.runDemo({ - Key? key, + super.key, required this.title, required this.description, this.secondDescription, @@ -36,8 +36,7 @@ class DemoScreen extends StatelessWidget { ..setTitle('$title Example') ..show(), child: const Text('Run the demo'), - ), - super(key: key); + ); final String title; final String description; @@ -57,7 +56,7 @@ class DemoScreen extends StatelessWidget { ], Text( title, - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.displayLarge, ), const SizedBox(height: 15), Text(description), @@ -65,7 +64,7 @@ class DemoScreen extends StatelessWidget { const SizedBox(height: 20), Text( secondDescription!, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.displayMedium, ), ], if (footer != null) ...[ diff --git a/example/lib/pages/settings_page.dart b/example/lib/pages/settings_page.dart index ffe127a..983fa44 100644 --- a/example/lib/pages/settings_page.dart +++ b/example/lib/pages/settings_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; class SettingsPage extends StatelessWidget { - const SettingsPage({Key? key}) : super(key: key); + const SettingsPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/style_classes_page.dart b/example/lib/pages/style_classes_page.dart index f7f7b54..3da9481 100644 --- a/example/lib/pages/style_classes_page.dart +++ b/example/lib/pages/style_classes_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:libadwaita/libadwaita.dart'; class StyleClassesPage extends StatelessWidget { - const StyleClassesPage({Key? key}) : super(key: key); + const StyleClassesPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/view_switcher_page.dart b/example/lib/pages/view_switcher_page.dart index a76c2f6..678bbe5 100644 --- a/example/lib/pages/view_switcher_page.dart +++ b/example/lib/pages/view_switcher_page.dart @@ -2,7 +2,7 @@ import 'package:example/pages/run_demo_screen.dart'; import 'package:flutter/material.dart'; class ViewSwitcherPage extends StatelessWidget { - const ViewSwitcherPage({Key? key}) : super(key: key); + const ViewSwitcherPage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/welcome.dart b/example/lib/pages/welcome.dart index 569c209..d556493 100644 --- a/example/lib/pages/welcome.dart +++ b/example/lib/pages/welcome.dart @@ -2,7 +2,7 @@ import 'package:example/pages/run_demo_screen.dart'; import 'package:flutter/material.dart'; class WelcomePage extends StatelessWidget { - const WelcomePage({Key? key}) : super(key: key); + const WelcomePage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/view_switcher/view_switcher_demo.dart b/example/lib/view_switcher/view_switcher_demo.dart index 4dd476c..1dc3c5c 100644 --- a/example/lib/view_switcher/view_switcher_demo.dart +++ b/example/lib/view_switcher/view_switcher_demo.dart @@ -3,7 +3,7 @@ import 'package:example/view_switcher/view_switcher_home_page.dart'; import 'package:flutter/material.dart'; class ViewSwitcherDemo extends StatelessWidget { - ViewSwitcherDemo({Key? key}) : super(key: key); + ViewSwitcherDemo({super.key}); final ValueNotifier themeNotifier = ValueNotifier(ThemeMode.system); diff --git a/example/lib/view_switcher/view_switcher_home_page.dart b/example/lib/view_switcher/view_switcher_home_page.dart index 0b61766..319d8dc 100644 --- a/example/lib/view_switcher/view_switcher_home_page.dart +++ b/example/lib/view_switcher/view_switcher_home_page.dart @@ -3,7 +3,7 @@ import 'package:libadwaita/libadwaita.dart'; import 'package:libadwaita_window_manager/libadwaita_window_manager.dart'; class ViewSwitcherHomePage extends StatefulWidget { - const ViewSwitcherHomePage({Key? key}) : super(key: key); + const ViewSwitcherHomePage({super.key}); @override _ViewSwitcherHomePageState createState() => _ViewSwitcherHomePageState(); diff --git a/example/pubspec.lock b/example/pubspec.lock index 3a1154f..bd3d66f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,65 +5,74 @@ packages: dependency: "direct main" description: name: adwaita - url: "https://pub.dartlang.org" + sha256: "535781747357779fa2830815e0a1b6b7888c8c538194ba73ac4fc8d82412baec" + url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.5.2" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 + url: "https://pub.dev" source: hosted version: "2.3.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.1" dbus: dependency: transitive description: name: dbus - url: "https://pub.dartlang.org" + sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.8" desktop_multi_window: dependency: "direct main" description: @@ -77,23 +86,27 @@ packages: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "2.0.2" file: - dependency: transitive + dependency: "direct overridden" description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.2" + path: "packages/file" + ref: release + resolved-ref: "63ce488036e2f6fb015fdd638937bef920e96132" + url: "https://github.com/google/file.dart" + source: git + version: "7.0.0" flutter: dependency: "direct main" description: flutter @@ -103,9 +116,10 @@ packages: dependency: transitive description: name: flutter_svg - url: "https://pub.dartlang.org" + sha256: "6ff8c902c8056af9736de2689f63f81c42e2d642b9f4c79dbf8790ae48b63012" + url: "https://pub.dev" source: hosted - version: "1.1.1+1" + version: "2.0.6" flutter_test: dependency: "direct dev" description: flutter @@ -120,30 +134,34 @@ packages: dependency: transitive description: name: gsettings - url: "https://pub.dartlang.org" + sha256: fe90d719e09a6f36607021047e642068a0c98839d9633db00b91633420ae8b0d + url: "https://pub.dev" source: hosted - version: "0.2.5" + version: "0.2.7" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" source: hosted - version: "0.13.4" + version: "0.13.6" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.7" libadwaita: dependency: "direct main" description: @@ -155,142 +173,122 @@ packages: dependency: transitive description: name: libadwaita_core - url: "https://pub.dartlang.org" + sha256: "1a7689e4130e96be4b0ec615863fded25cd86c2b95a682e7cec9659d420de37c" + url: "https://pub.dev" source: hosted version: "0.5.4" libadwaita_window_manager: dependency: "direct main" description: name: libadwaita_window_manager - url: "https://pub.dartlang.org" + sha256: "196b705b9683d2979740e9bfd46bbe1ce69fc16af217215d80df7c84ff8fe30f" + url: "https://pub.dev" source: hosted version: "0.5.4+1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" package_info_plus: dependency: transitive description: name: package_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.2" - package_info_plus_linux: - dependency: transitive - description: - name: package_info_plus_linux - url: "https://pub.dartlang.org" + sha256: d39e8fbff4c5aef4592737e25ad6ac500df006ce7a7a8e1f838ce1256e167542 + url: "https://pub.dev" source: hosted - version: "1.0.5" - package_info_plus_macos: - dependency: transitive - description: - name: package_info_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "4.0.0" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" + sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" + url: "https://pub.dev" source: hosted - version: "1.0.2" - package_info_plus_web: - dependency: transitive - description: - name: package_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_info_plus_windows: - dependency: transitive - description: - name: package_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" + version: "2.0.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - path_drawing: - dependency: transitive - description: - name: path_drawing - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.8.3" path_parsing: dependency: transitive description: name: path_parsing - url: "https://pub.dartlang.org" + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.0.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.4.0" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" source: hosted version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757" + url: "https://pub.dev" source: hosted version: "2.1.2" popover_gtk: dependency: transitive description: name: popover_gtk - url: "https://pub.dartlang.org" + sha256: c293bfa3bcb9436fe189f20f6397199ce996ba40d4b081e26793adcf3ceac45b + url: "https://pub.dev" source: hosted version: "0.2.6+3" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" source: hosted version: "4.2.4" screen_retriever: dependency: transitive description: name: screen_retriever - url: "https://pub.dartlang.org" + sha256: "4931f226ca158123ccd765325e9fbf360bfed0af9b460a10f960f9bb13d58323" + url: "https://pub.dev" source: hosted - version: "0.1.2" + version: "0.1.6" sky_engine: dependency: transitive description: flutter @@ -300,149 +298,194 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.5.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" url_launcher: dependency: transitive description: name: url_launcher - url: "https://pub.dartlang.org" + sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 + url: "https://pub.dev" source: hosted - version: "6.1.2" + version: "6.1.11" url_launcher_android: dependency: transitive description: name: url_launcher_android - url: "https://pub.dartlang.org" + sha256: "1ccd353c1bff66b49863527c02759f4d06b92744bd9777c96a00ca6a9e8e1d2f" + url: "https://pub.dev" source: hosted version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - url: "https://pub.dartlang.org" + sha256: "9ef5f323cfc5e80c1cad254e4602e6be64e9933de63717c7d05944c596b4ee9a" + url: "https://pub.dev" source: hosted version: "6.0.16" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - url: "https://pub.dartlang.org" + sha256: "360fa359ab06bcb4f7c5cd3123a2a9a4d3364d4575d27c4b33468bd4497dd094" + url: "https://pub.dev" source: hosted version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - url: "https://pub.dartlang.org" + sha256: a9b3ea9043eabfaadfa3fb89de67a11210d85569086d22b3854484beab8b3978 + url: "https://pub.dev" source: hosted version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - url: "https://pub.dartlang.org" + sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370" + url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.1.2" url_launcher_web: dependency: transitive description: name: url_launcher_web - url: "https://pub.dartlang.org" + sha256: "1c7d34f93353de7f7ad9cb239e8b1e680e759b73845d4970dedc4e0a926e9abe" + url: "https://pub.dev" source: hosted version: "2.0.11" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - url: "https://pub.dartlang.org" + sha256: e3c3b16d3104260c10eea3b0e34272aaa57921f83148b0619f74c2eced9b7ef1 + url: "https://pub.dev" source: hosted version: "3.0.1" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: b96f10cbdfcbd03a65758633a43e7d04574438f059b1043104b5d61b23d38a4f + url: "https://pub.dev" + source: hosted + version: "1.1.6" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "57a8e6e24662a3bdfe3b3d61257db91768700c0b8f844e235877b56480f31c69" + url: "https://pub.dev" + source: hosted + version: "1.1.6" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "7430f5d834d0db4560d7b19863362cd892f1e52b43838553a3c5cdfc9ab28e5b" + url: "https://pub.dev" + source: hosted + version: "1.1.6" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" very_good_analysis: dependency: "direct dev" description: name: very_good_analysis - url: "https://pub.dartlang.org" + sha256: "396bf7de205dd5b03eb164d04692de3e8335c11a7ddb2f63153de8dfcee921d9" + url: "https://pub.dev" source: hosted version: "3.0.1" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + url: "https://pub.dev" source: hosted - version: "2.5.2" + version: "4.1.4" window_manager: dependency: "direct main" description: name: window_manager - url: "https://pub.dartlang.org" + sha256: "2b2572442b2a5178642730442dc625ac088244f5827b1f0811371b1b7485eb62" + url: "https://pub.dev" source: hosted - version: "0.2.6" + version: "0.3.2" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: "060b6e1c891d956f72b5ac9463466c37cce3fa962a921532fc001e86fe93438e" + url: "https://pub.dev" source: hosted version: "0.2.0+1" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.3.0" sdks: - dart: ">=2.17.6 <3.0.0" - flutter: ">=3.0.0" + dart: ">=3.0.0-0 <4.0.0" + flutter: ">=3.7.0-0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 38651ce..1fa9a0f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,10 +5,10 @@ publish_to: none version: 1.0.0+2 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" dependencies: - adwaita: "0.5.1" + adwaita: "0.5.2" desktop_multi_window: git: url: https://github.com/Kingtous/rustdesk_desktop_multi_window @@ -17,13 +17,20 @@ dependencies: libadwaita: path: ../ libadwaita_window_manager: ^0.5.4+1 - window_manager: ^0.2.6 + window_manager: ^0.3.2 dev_dependencies: flutter_test: sdk: flutter very_good_analysis: ^3.0.1 +dependency_overrides: + file: + git: + url: https://github.com/google/file.dart + ref: release + path: packages/file + flutter: uses-material-design: true assets: diff --git a/lib/src/internal/window_resize_listener.dart b/lib/src/internal/window_resize_listener.dart index ba922e8..3789019 100644 --- a/lib/src/internal/window_resize_listener.dart +++ b/lib/src/internal/window_resize_listener.dart @@ -16,11 +16,13 @@ class WindowResizeListener extends StatefulWidget { class _WindowResizeListenerState extends State with WidgetsBindingObserver { - late Size _lastSize; + Size _lastSize = Size.zero; @override void initState() { - _lastSize = WidgetsBinding.instance.window.physicalSize; + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + widget.onResize(View.of(context).physicalSize); + }); WidgetsBinding.instance.addObserver(this); widget.onResize(_lastSize); @@ -36,7 +38,7 @@ class _WindowResizeListenerState extends State @override void didChangeMetrics() { - final winSize = WidgetsBinding.instance.window.physicalSize; + final winSize = View.of(context).physicalSize; if (winSize != _lastSize) { widget.onResize(winSize); diff --git a/lib/src/utils/colors.dart b/lib/src/utils/colors.dart index 3cee49b..fc1ba42 100644 --- a/lib/src/utils/colors.dart +++ b/lib/src/utils/colors.dart @@ -39,15 +39,15 @@ extension BorderContext on BuildContext { _isDark ? const Color(0xFF535353) : const Color(0xFFE0E0E0); Color get selectColor => _isDark - ? Theme.of(this).backgroundColor.lighten() - : Theme.of(this).backgroundColor.darken(); + ? Theme.of(this).colorScheme.background.lighten() + : Theme.of(this).colorScheme.background.darken(); Color get hoverMenuColor => _isDark - ? Theme.of(this).backgroundColor.lighten(0.05) - : Theme.of(this).backgroundColor.darken(0.05); + ? Theme.of(this).colorScheme.background.lighten(0.05) + : Theme.of(this).colorScheme.background.darken(0.05); Color get hoverColor => _isDark - ? Theme.of(this).backgroundColor.lighten(0.15) - : Theme.of(this).backgroundColor.darken(0.005); + ? Theme.of(this).colorScheme.background.lighten(0.15) + : Theme.of(this).colorScheme.background.darken(0.005); Color get textColor => _isDark ? Colors.white : Colors.black; } diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index ed4c5b3..7811275 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -146,7 +146,7 @@ class _AdwHeaderBarState extends State { } if (Platform.isMacOS) { - updateSep('close,maximize,minimize:'); + updateSep('close,minimize,maximize:'); } else if (Platform.isLinux) { final schema = GSettings('org.gnome.desktop.wm.preferences'); diff --git a/lib/src/widgets/adw/new/macos_caption_button.dart b/lib/src/widgets/adw/new/macos_caption_button.dart new file mode 100644 index 0000000..c8fd452 --- /dev/null +++ b/lib/src/widgets/adw/new/macos_caption_button.dart @@ -0,0 +1,251 @@ +import 'package:flutter/material.dart'; +import 'package:libadwaita/libadwaita.dart'; + +class MacOSCaptionButton extends StatefulWidget { + const MacOSCaptionButton({ + super.key, + required this.type, + required this.onPressed, + }); + + final WindowButtonType type; + final VoidCallback? onPressed; + + @override + State createState() => _MacOSCaptionButtonState(); +} + +class _MacOSCaptionButtonState extends State { + bool _isHovering = false; + bool _isPressed = false; + + void _onEntered({required bool hovered}) { + setState(() => _isHovering = hovered); + } + + void _onActive({required bool pressed}) { + setState(() => _isPressed = pressed); + } + + @override + Widget build(BuildContext context) { + return MouseRegion( + onExit: (value) => _onEntered(hovered: false), + onHover: (value) => _onEntered(hovered: true), + child: GestureDetector( + onTapDown: (_) => _onActive(pressed: true), + onTapCancel: () => _onActive(pressed: false), + onTapUp: (_) => _onActive(pressed: false), + behavior: HitTestBehavior.opaque, + onTap: widget.onPressed, + child: Container( + width: 12, + height: 12, + margin: const EdgeInsets.symmetric(vertical: 4) + .copyWith(left: 2, right: 6), + decoration: BoxDecoration( + border: Border.all( + color: () { + if (_isPressed) { + switch (widget.type) { + case WindowButtonType.close: + return const Color(0xffad3934); + case WindowButtonType.maximize: + return const Color(0xff128622); + case WindowButtonType.minimize: + return const Color(0xffad7d15); + } + } + + switch (widget.type) { + case WindowButtonType.close: + return const Color(0xffe2463f); + case WindowButtonType.maximize: + return const Color(0xff12ac28); + case WindowButtonType.minimize: + return const Color(0xffe1a116); + } + }(), + ), + color: () { + if (_isPressed) { + switch (widget.type) { + case WindowButtonType.close: + return const Color(0xffbf4943); + case WindowButtonType.maximize: + return const Color(0xff1f9a31); + case WindowButtonType.minimize: + return const Color(0xffbf9123); + } + } + switch (widget.type) { + case WindowButtonType.close: + return const Color(0xffff5f57); + case WindowButtonType.maximize: + return const Color(0xff28c940); + case WindowButtonType.minimize: + return const Color(0xffffbd2e); + } + }(), + borderRadius: BorderRadius.circular(100), + ), + child: _isHovering + ? Center( + child: CustomPaint( + size: () { + switch (widget.type) { + case WindowButtonType.close: + return const Size(7, 7); + case WindowButtonType.minimize: + return const Size(7, 7 * .1375); + case WindowButtonType.maximize: + return const Size(7, 7); + } + }(), + painter: () { + switch (widget.type) { + case WindowButtonType.close: + return CloseButton(); + case WindowButtonType.minimize: + return MinimizeButton(); + case WindowButtonType.maximize: + return FullscreenActiveButton(); + } + }(), + ), + ) + : const SizedBox(), + ), + ), + ); + } +} + +/// WIDTH, (WIDTH*1).toDouble() +class FullscreenActiveButton extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + final path_0 = Path() + ..moveTo(size.width, size.height * 0.5696203) + ..lineTo(size.width, size.height * 0.4303797) + ..lineTo(size.width * 0.5696203, size.height * 0.4303797) + ..lineTo(size.width * 0.5696203, 0) + ..lineTo(size.width * 0.4303797, 0) + ..lineTo(size.width * 0.4303797, size.height * 0.4303797) + ..lineTo(0, size.height * 0.4303797) + ..lineTo(0, size.height * 0.5696203) + ..lineTo(size.width * 0.4303797, size.height * 0.5696203) + ..lineTo(size.width * 0.4303797, size.height) + ..lineTo(size.width * 0.5696203, size.height) + ..lineTo(size.width * 0.5696203, size.height * 0.5696203) + ..close(); + + final paint0Fill = Paint() + ..style = PaintingStyle.fill + ..color = const Color(0xff006400).withOpacity(1); + canvas.drawPath(path_0, paint0Fill); + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return true; + } +} + +/// WIDTH, (WIDTH*0.9833333333333334).toDouble() +class FullScreenInactiveButton extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + final path_0 = Path() + ..moveTo(size.width * 0.9000000, 0) + ..lineTo(size.width * 0.2333333, 0) + ..lineTo(size.width, size.height * 0.7627119) + ..lineTo(size.width, size.height * 0.1016949) + ..cubicTo( + size.width * 0.9500000, + size.height * 0.1016949, + size.width * 0.8833333, + size.height * 0.05084746, + size.width * 0.9000000, + 0, + ) + ..close(); + + final paint0Fill = Paint() + ..style = PaintingStyle.fill + ..color = const Color(0xff006400).withOpacity(1); + canvas.drawPath(path_0, paint0Fill); + + final path_1 = Path() + ..moveTo(size.width * 0.1000000, size.height) + ..lineTo(size.width * 0.7666667, size.height) + ..lineTo(0, size.height * 0.2372881) + ..lineTo(0, size.height * 0.8983051) + ..cubicTo( + size.width * 0.05000000, + size.height * 0.8983051, + size.width * 0.1000000, + size.height * 0.9491525, + size.width * 0.1000000, + size.height, + ) + ..close(); + + final paint1Fill = Paint() + ..style = PaintingStyle.fill + ..color = const Color(0xff006400).withOpacity(1); + canvas.drawPath(path_1, paint1Fill); + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return true; + } +} + +/// WIDTH, (WIDTH*0.1375).toDouble() +class MinimizeButton extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + final paint0Fill = Paint() + ..style = PaintingStyle.fill + ..color = const Color(0xff995700).withOpacity(1); + canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), paint0Fill); + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return true; + } +} + +/// WIDTH, (WIDTH*1).toDouble() +class CloseButton extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + final path_0 = Path() + ..moveTo(size.width, size.height * 0.1250000) + ..lineTo(size.width * 0.8750000, 0) + ..lineTo(size.width * 0.5000000, size.height * 0.3750000) + ..lineTo(size.width * 0.1250000, 0) + ..lineTo(0, size.height * 0.1250000) + ..lineTo(size.width * 0.3750000, size.height * 0.5000000) + ..lineTo(0, size.height * 0.8750000) + ..lineTo(size.width * 0.1250000, size.height) + ..lineTo(size.width * 0.5000000, size.height * 0.6250000) + ..lineTo(size.width * 0.8750000, size.height) + ..lineTo(size.width, size.height * 0.8750000) + ..lineTo(size.width * 0.6250000, size.height * 0.5000000) + ..close(); + + final paint0Fill = Paint() + ..style = PaintingStyle.fill + ..color = const Color(0xff4d0000).withOpacity(1); + canvas.drawPath(path_0, paint0Fill); + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return true; + } +} diff --git a/lib/src/widgets/adw/new/sidebar.dart b/lib/src/widgets/adw/new/sidebar.dart index 87eb2e2..2f906f4 100644 --- a/lib/src/widgets/adw/new/sidebar.dart +++ b/lib/src/widgets/adw/new/sidebar.dart @@ -43,8 +43,7 @@ class AdwSidebar extends StatelessWidget { BuildContext context, int index, bool isSelected, - ) - itemBuilder, + ) itemBuilder, required int itemCount, }) : assert(itemCount >= 0, 'Item Count cannot not be negative!'), _childrenDelegate = List.generate( @@ -92,7 +91,7 @@ class AdwSidebar extends StatelessWidget { return Container( constraints: BoxConstraints(maxWidth: width), decoration: BoxDecoration( - color: color ?? Theme.of(context).backgroundColor, + color: color ?? Theme.of(context).colorScheme.background, ), child: ListView( controller: controller, diff --git a/lib/src/widgets/adw/new/text_field.dart b/lib/src/widgets/adw/new/text_field.dart index 5b40c0b..d4dbcef 100644 --- a/lib/src/widgets/adw/new/text_field.dart +++ b/lib/src/widgets/adw/new/text_field.dart @@ -49,13 +49,13 @@ class AdwTextField extends StatelessWidget { prefixIcon: prefixIcon != null ? Icon( prefixIcon, - color: Theme.of(context).textTheme.headline1?.color, + color: Theme.of(context).textTheme.displayLarge?.color, ) : null, suffixIcon: icon != null ? Icon( icon, - color: Theme.of(context).textTheme.headline1?.color, + color: Theme.of(context).textTheme.displayLarge?.color, ) : null, ), diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index fd24d9e..be06577 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:libadwaita/src/utils/colors.dart'; +import 'package:libadwaita/src/widgets/adw/new/macos_caption_button.dart'; import 'package:libadwaita/src/widgets/adw/new/windows_caption_button.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; @@ -38,7 +39,8 @@ class AdwWindowButton extends StatelessWidget { width: 16, package: 'libadwaita', height: 16, - color: context.textColor, + colorFilter: + ColorFilter.mode(context.textColor, BlendMode.srcIn), ), ), ) @@ -49,7 +51,10 @@ class AdwWindowButton extends StatelessWidget { type: buttonType, ) : Platform.isMacOS - ? const SizedBox() + ? MacOSCaptionButton( + onPressed: onPressed, + type: buttonType, + ) : const SizedBox() : const SizedBox(); } diff --git a/lib/src/widgets/adw/new/windows_caption_button.dart b/lib/src/widgets/adw/new/windows_caption_button.dart index 35f384b..3bca2b2 100644 --- a/lib/src/widgets/adw/new/windows_caption_button.dart +++ b/lib/src/widgets/adw/new/windows_caption_button.dart @@ -130,10 +130,10 @@ class _WindowCaptionButtonState extends State { onExit: (value) => _onEntered(hovered: false), onHover: (value) => _onEntered(hovered: true), child: GestureDetector( - behavior: HitTestBehavior.opaque, onTapDown: (_) => _onActive(pressed: true), onTapCancel: () => _onActive(pressed: false), onTapUp: (_) => _onActive(pressed: false), + behavior: HitTestBehavior.opaque, onTap: widget.onPressed, child: Container( constraints: const BoxConstraints(minWidth: 58, minHeight: 32), diff --git a/lib/src/widgets/adw/preferences_group.dart b/lib/src/widgets/adw/preferences_group.dart index 7d00938..39160af 100644 --- a/lib/src/widgets/adw/preferences_group.dart +++ b/lib/src/widgets/adw/preferences_group.dart @@ -13,9 +13,22 @@ class AdwPreferencesGroup extends StatelessWidget { }) : itemBuilder = null, itemCount = null; - const AdwPreferencesGroup.credits({ + const AdwPreferencesGroup.builder({ super.key, - required List this.children, + required Widget Function(BuildContext, int) this.itemBuilder, + required int this.itemCount, + this.borderRadius = 12, + this.title, + this.titleStyle, + this.description, + this.descriptionStyle, + this.padding = const EdgeInsets.symmetric(horizontal: 5), + }) : children = null; + + const AdwPreferencesGroup.creditsBuilder({ + super.key, + required Widget Function(BuildContext, int) this.itemBuilder, + required int this.itemCount, this.borderRadius = 12, this.title, this.titleStyle = const TextStyle( @@ -25,11 +38,17 @@ class AdwPreferencesGroup extends StatelessWidget { this.description, this.descriptionStyle, this.padding = const EdgeInsets.symmetric(horizontal: 5), - }) : itemBuilder = null, - itemCount = null; + }) : children = null; /// List of all the elements in this group - final List children; + final List? children; + + /// Item Builder for this preferences griup + final Widget Function(BuildContext, int)? itemBuilder; + + /// Count of elements in this preferences group, + /// used for itemBuilder + final int? itemCount; /// The border radius of this visit final double borderRadius; @@ -63,13 +82,14 @@ class AdwPreferencesGroup extends StatelessWidget { if (title != null) ...[ Text( title!, - style: titleStyle ?? Theme.of(context).textTheme.headline5, + style: + titleStyle ?? Theme.of(context).textTheme.headlineSmall, ), if (description != null) Text( description!, style: descriptionStyle ?? - Theme.of(context).textTheme.bodyText2, + Theme.of(context).textTheme.bodyMedium, ), const SizedBox(height: 12), ], diff --git a/pubspec.yaml b/pubspec.yaml index a54ccb3..184e94d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.2.5 homepage: https://github.com/gtk-flutter/libadwaita environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" flutter: ">=1.17.0" platforms: @@ -19,12 +19,12 @@ dependencies: dbus: ">=0.7.4 <1.0.0" flutter: sdk: flutter - flutter_svg: ">=1.0.3 < 2.0.0" - gsettings: ">=0.2.5 <1.0.0" - libadwaita_core: ">=0.5.4 < 2.0.0" - package_info_plus: ">=1.4.2 < 2.0.0" - popover_gtk: ">=0.2.6+3 < 1.0.0" - url_launcher: ">=6.1.2 < 7.0.0" + flutter_svg: ">=2.0.6 <3.0.0" + gsettings: ">=0.2.7 <1.0.0" + libadwaita_core: ">=0.5.4 <2.0.0" + package_info_plus: ">=4.0.0 <5.0.0" + popover_gtk: ">=0.2.6+3 <1.0.0" + url_launcher: ">=6.1.11 <7.0.0" dev_dependencies: very_good_analysis: ^3.0.1 From 850c77caa5b9d3e542b36cfa730552d47b135446 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 28 May 2023 09:10:06 +0530 Subject: [PATCH 67/77] fix: update example (#82) --- example/pubspec.lock | 4 ++-- example/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index bd3d66f..f6ecbcd 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: "direct main" description: name: adwaita - sha256: "535781747357779fa2830815e0a1b6b7888c8c538194ba73ac4fc8d82412baec" + sha256: e39ac1b1d4b0790d0ea1f3649a1705754beabdcc7552dbca577dbc849f745e31 url: "https://pub.dev" source: hosted - version: "0.5.2" + version: "1.0.0" args: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1fa9a0f..5a55e10 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: ">=2.17.0 <4.0.0" dependencies: - adwaita: "0.5.2" + adwaita: ^1.0.0 desktop_multi_window: git: url: https://github.com/Kingtous/rustdesk_desktop_multi_window From fe6a735ee42f32bc5c8e63b035553c2eec2c0890 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 30 May 2023 19:06:27 +0530 Subject: [PATCH 68/77] chore: bump to 2.0.0 (#83) --- .vscode/settings.json | 3 --- CHANGELOG.md | 8 ++++++++ example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index cad7657..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "cmake.configureOnOpen": false -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d9eec25..2e99091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.0.0 + +* Add Windows & Mac os headerbar buttons (using `nativeControls` parameter) +* Add builder for `AdwPreferencesGroup` +* Update Documentation for various widgets +* Support Material 3 font naming scheme +* Bump dependencies + ## 1.2.5 * Set default header buttons to min, max and close at the right side diff --git a/example/pubspec.lock b/example/pubspec.lock index f6ecbcd..9ea378c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -168,7 +168,7 @@ packages: path: ".." relative: true source: path - version: "1.2.5" + version: "2.0.0" libadwaita_core: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 184e94d..97c074d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 1.2.5 +version: 2.0.0 homepage: https://github.com/gtk-flutter/libadwaita environment: From 7310538f77e91c9874ba1c4ab7d24811b8ff5099 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 4 Jun 2023 11:09:09 +0530 Subject: [PATCH 69/77] fix: window button --- lib/src/widgets/adw/new/window_button.dart | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index be06577..cacb358 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -28,34 +28,34 @@ class AdwWindowButton extends StatelessWidget { @override Widget build(BuildContext context) { return onPressed != null - ? !nativeControls || Platform.isLinux - ? AdwButton.circular( - size: 24, - margin: const EdgeInsets.all(6), + ? nativeControls && Platform.isWindows + ? WindowCaptionButton( onPressed: onPressed, - child: Center( - child: SvgPicture.asset( - 'assets/icons/${buttonType.name}.svg', - width: 16, - package: 'libadwaita', - height: 16, - colorFilter: - ColorFilter.mode(context.textColor, BlendMode.srcIn), - ), - ), + brightness: Theme.of(context).brightness, + type: buttonType, ) - : Platform.isWindows - ? WindowCaptionButton( + : nativeControls && Platform.isMacOS + ? MacOSCaptionButton( onPressed: onPressed, - brightness: Theme.of(context).brightness, type: buttonType, ) - : Platform.isMacOS - ? MacOSCaptionButton( - onPressed: onPressed, - type: buttonType, - ) - : const SizedBox() + : AdwButton.circular( + size: 24, + margin: const EdgeInsets.all(6), + onPressed: onPressed, + child: Center( + child: SvgPicture.asset( + 'assets/icons/${buttonType.name}.svg', + width: 16, + package: 'libadwaita', + height: 16, + colorFilter: ColorFilter.mode( + context.textColor, + BlendMode.srcIn, + ), + ), + ), + ) : const SizedBox(); } } From 3e741938ee75861a670084ab5aed8d28d31b1002 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 4 Jun 2023 11:13:39 +0530 Subject: [PATCH 70/77] chore: bump to 2.0.1 --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- pubspec.yaml | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e99091..44e1899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.1 + +* Fix window action buttons not visible sometimes + ## 2.0.0 * Add Windows & Mac os headerbar buttons (using `nativeControls` parameter) diff --git a/example/pubspec.lock b/example/pubspec.lock index 9ea378c..d4296d7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -168,7 +168,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0" + version: "2.0.1" libadwaita_core: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 97c074d..d55a6bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,7 @@ name: libadwaita -description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 2.0.0 +description: Libadwaita's widgets for Flutter. + Following Gnome HIG and available on all platforms. +version: 2.0.1 homepage: https://github.com/gtk-flutter/libadwaita environment: From cffa79519c6b02a052bac401ecf2b6be72aa3ea3 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 4 Jun 2023 11:21:46 +0530 Subject: [PATCH 71/77] fix: remove windows from ci --- .github/workflows/ci.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80abd99..3243461 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,6 @@ ---- -# This is a basic workflow to help you get started with Actions name: CI -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request - # events but only for the main branch push: branches: [main] paths-ignore: @@ -13,7 +8,6 @@ on: pull_request: branches: [main] - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: @@ -22,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 @@ -48,11 +42,11 @@ jobs: flutter create --platforms=linux . flutter build linux if: matrix.os == 'ubuntu-latest' - - name: Build (Windows) - run: | - flutter config --enable-windows-desktop - cd example - flutter create --platforms=windows . - flutter doctor - flutter build windows - if: matrix.os == 'windows-latest' + # - name: Build (Windows) + # run: | + # flutter config --enable-windows-desktop + # cd example + # flutter create --platforms=windows . + # flutter doctor + # flutter build windows + # if: matrix.os == 'windows-latest' From 4b5a61167fc1aafa8d58e471c6f5c90a37560cc7 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sun, 4 Jun 2023 11:22:45 +0530 Subject: [PATCH 72/77] fix: typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e1899..90e7f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ## 2.0.0 -* Add Windows & Mac os headerbar buttons (using `nativeControls` parameter) +* Add Windows & macOS headerbar buttons (using `nativeControls` parameter) * Add builder for `AdwPreferencesGroup` * Update Documentation for various widgets * Support Material 3 font naming scheme From 68ce6f1c0aacf3e35aa182485859d7920585e94c Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Mon, 10 Jul 2023 22:10:31 +0530 Subject: [PATCH 73/77] fix: window buttons auto position (for mobile devices) (#86) --- CHANGELOG.md | 4 ++++ lib/src/widgets/adw/header_bar.dart | 4 +++- pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e7f7f..65bfe46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.2 + +* Fix for automatically position window buttons property + ## 2.0.1 * Fix window action buttons not visible sometimes diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 7811275..8215070 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -118,7 +118,9 @@ class _AdwHeaderBarState extends State { widget.maximizeBtn != null; late ValueNotifier?> separator = - !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) + !widget.style.autoPositionWindowButtons || + !kIsWeb && + (Platform.isLinux || Platform.isWindows || Platform.isMacOS) ? ValueNotifier( ['', 'minimize,maximize,close'], ) diff --git a/pubspec.yaml b/pubspec.yaml index d55a6bf..fcfedc4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: libadwaita description: Libadwaita's widgets for Flutter. Following Gnome HIG and available on all platforms. -version: 2.0.1 +version: 2.0.2 homepage: https://github.com/gtk-flutter/libadwaita environment: From ef76db3eff3fe1b0d3f0f9cd98004dc677d86c30 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Thu, 17 Aug 2023 18:40:43 +0530 Subject: [PATCH 74/77] Create FUNDING.yml (#87) --- .github/FUNDING.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..184a4fd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: [prateekmedia] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From e2e5c0596cbd249fb9d1e7b0e6352273754c12df Mon Sep 17 00:00:00 2001 From: cole Date: Sat, 11 Nov 2023 15:06:31 -0500 Subject: [PATCH 75/77] fixes a bug in header_bar.dart where a platform check is done prior to checking if application is running in web --- lib/src/widgets/adw/header_bar.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index 8215070..d1aba4b 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -147,7 +147,9 @@ class _AdwHeaderBarState extends State { ); } - if (Platform.isMacOS) { + if (kIsWeb) { + return; + } else if (Platform.isMacOS) { updateSep('close,minimize,maximize:'); } else if (Platform.isLinux) { final schema = GSettings('org.gnome.desktop.wm.preferences'); From 6074cddeb0fa30b18d30411e7d7d73dc5b055f37 Mon Sep 17 00:00:00 2001 From: Brian Fopiano <29320316+NextdoorPsycho@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:18:29 -0400 Subject: [PATCH 76/77] Updated to UniversalIO (#90) * Updated to UniversalIO * Optional Actions for those of us using it for CrossPlatform --- example/lib/main.dart | 2 +- example/pubspec.lock | 80 +++++++++++++++------- lib/src/widgets/adw/header_bar.dart | 69 +++++++------------ lib/src/widgets/adw/new/scaffold.dart | 26 +++---- lib/src/widgets/adw/new/window_button.dart | 2 +- pubspec.yaml | 2 + 6 files changed, 92 insertions(+), 89 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 24e8a0a..4ef441c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'package:universal_io/io.dart'; import 'package:adwaita/adwaita.dart'; import 'package:collection/collection.dart'; diff --git a/example/pubspec.lock b/example/pubspec.lock index d4296d7..22874d6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.18.0" dbus: dependency: transitive description: @@ -154,21 +154,37 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" - js: + leak_tracker: dependency: transitive description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" libadwaita: dependency: "direct main" description: path: ".." relative: true source: path - version: "2.0.1" + version: "2.0.2" libadwaita_core: dependency: transitive description: @@ -189,26 +205,26 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.11.0" package_info_plus: dependency: transitive description: @@ -229,10 +245,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -298,26 +314,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -338,10 +354,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.1" typed_data: dependency: transitive description: @@ -350,6 +366,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: transitive description: @@ -454,6 +478,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" win32: dependency: transitive description: @@ -487,5 +519,5 @@ packages: source: hosted version: "6.3.0" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=3.2.0-0 <4.0.0" flutter: ">=3.7.0-0" diff --git a/lib/src/widgets/adw/header_bar.dart b/lib/src/widgets/adw/header_bar.dart index d1aba4b..fee4247 100644 --- a/lib/src/widgets/adw/header_bar.dart +++ b/lib/src/widgets/adw/header_bar.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:dbus/dbus.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -7,6 +5,7 @@ import 'package:gsettings/gsettings.dart'; import 'package:libadwaita/src/utils/colors.dart'; import 'package:libadwaita/src/widgets/widgets.dart'; import 'package:libadwaita_core/libadwaita_core.dart'; +import 'package:universal_io/io.dart'; class HeaderBarStyle { const HeaderBarStyle({ @@ -53,32 +52,32 @@ class AdwHeaderBar extends StatefulWidget { this.start = const [], this.end = const [], this.style = const HeaderBarStyle(), - required AdwActions actions, + AdwActions? actions, AdwControls? controls, }) : closeBtn = controls != null - ? controls.closeBtn?.call(actions.onClose) + ? controls.closeBtn?.call(actions?.onClose) : AdwWindowButton( nativeControls: style.nativeControls, buttonType: WindowButtonType.close, - onPressed: actions.onClose, + onPressed: actions?.onClose, ), maximizeBtn = controls != null - ? controls.maximizeBtn?.call(actions.onMaximize) + ? controls.maximizeBtn?.call(actions?.onMaximize) : AdwWindowButton( nativeControls: style.nativeControls, buttonType: WindowButtonType.maximize, - onPressed: actions.onMaximize, + onPressed: actions?.onMaximize, ), minimizeBtn = controls != null - ? controls.minimizeBtn?.call(actions.onMinimize) + ? controls.minimizeBtn?.call(actions?.onMinimize) : AdwWindowButton( nativeControls: style.nativeControls, buttonType: WindowButtonType.minimize, - onPressed: actions.onMinimize, + onPressed: actions?.onMinimize, ), - onHeaderDrag = actions.onHeaderDrag, - onDoubleTap = actions.onDoubleTap, - onRightClick = actions.onRightClick; + onHeaderDrag = actions?.onHeaderDrag, + onDoubleTap = actions?.onDoubleTap, + onRightClick = actions?.onRightClick; /// The leading widget for the headerbar final List start; @@ -112,19 +111,13 @@ class AdwHeaderBar extends StatefulWidget { } class _AdwHeaderBarState extends State { - bool get hasWindowControls => - widget.closeBtn != null || - widget.minimizeBtn != null || - widget.maximizeBtn != null; + bool get hasWindowControls => widget.closeBtn != null || widget.minimizeBtn != null || widget.maximizeBtn != null; - late ValueNotifier?> separator = - !widget.style.autoPositionWindowButtons || - !kIsWeb && - (Platform.isLinux || Platform.isWindows || Platform.isMacOS) - ? ValueNotifier( - ['', 'minimize,maximize,close'], - ) - : ValueNotifier(null); + late ValueNotifier?> separator = !widget.style.autoPositionWindowButtons || !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS) + ? ValueNotifier( + ['', 'minimize,maximize,close'], + ) + : ValueNotifier(null); @override void initState() { @@ -138,10 +131,7 @@ class _AdwHeaderBarState extends State { (e) => e .split(',') .where( - (element) => - element == 'close' || - element == 'maximize' || - element == 'minimize', + (element) => element == 'close' || element == 'maximize' || element == 'minimize', ) .join(','), ); @@ -156,8 +146,7 @@ class _AdwHeaderBarState extends State { WidgetsBinding.instance.addPostFrameCallback((_) async { try { - final buttonLayout = - await schema.get('button-layout') as DBusString?; + final buttonLayout = await schema.get('button-layout') as DBusString?; if (buttonLayout != null) { updateSep(buttonLayout.value); } @@ -187,9 +176,7 @@ class _AdwHeaderBarState extends State { alignment: Alignment.topCenter, child: Container( decoration: BoxDecoration( - color: !widget.style.isTransparent - ? Theme.of(context).appBarTheme.backgroundColor - : null, + color: !widget.style.isTransparent ? Theme.of(context).appBarTheme.backgroundColor : null, border: !widget.style.isTransparent ? Border( bottom: BorderSide(color: context.borderColor), @@ -215,15 +202,11 @@ class _AdwHeaderBarState extends State { leading: Row( mainAxisSize: MainAxisSize.min, children: [ - if (hasWindowControls && - sep != null && - sep[0].split(',').isNotEmpty) ...[ + if (hasWindowControls && sep != null && sep[0].split(',').isNotEmpty) ...[ SizedBox(width: widget.style.titlebarSpace), for (var i in sep[0].split(',')) if (windowButtons[i] != null) windowButtons[i]!, - if (!widget.style.nativeControls || - !kIsWeb && Platform.isLinux) - SizedBox(width: widget.style.titlebarSpace), + if (!widget.style.nativeControls || !kIsWeb && Platform.isLinux) SizedBox(width: widget.style.titlebarSpace), ], ...widget.start.map( (e) => Padding( @@ -243,15 +226,11 @@ class _AdwHeaderBarState extends State { child: e, ), ), - if (hasWindowControls && - sep != null && - sep[1].split(',').isNotEmpty) ...[ + if (hasWindowControls && sep != null && sep[1].split(',').isNotEmpty) ...[ SizedBox(width: widget.style.titlebarSpace), for (var i in sep[1].split(',')) if (windowButtons[i] != null) windowButtons[i]!, - if (!widget.style.nativeControls || - !kIsWeb && Platform.isLinux) - SizedBox(width: widget.style.titlebarSpace), + if (!widget.style.nativeControls || !kIsWeb && Platform.isLinux) SizedBox(width: widget.style.titlebarSpace), ], ], ), diff --git a/lib/src/widgets/adw/new/scaffold.dart b/lib/src/widgets/adw/new/scaffold.dart index 155f006..8852ed9 100644 --- a/lib/src/widgets/adw/new/scaffold.dart +++ b/lib/src/widgets/adw/new/scaffold.dart @@ -13,15 +13,14 @@ class AdwScaffold extends StatefulWidget { this.flapStyle, this.flapOptions, this.flapController, - @Deprecated('headerbar is deprecated, use the properties separately') - AdwHeaderBar? Function(Widget?)? headerbar, + @Deprecated('headerbar is deprecated, use the properties separately') AdwHeaderBar? Function(Widget?)? headerbar, this.viewSwitcher, this.viewSwitcherConstraint, this.headerBarStyle, this.start, this.title, this.end, - required this.actions, + this.actions, this.controls, }); @@ -42,7 +41,7 @@ class AdwScaffold extends StatefulWidget { final Widget? title; final List? end; - final AdwActions actions; + final AdwActions? actions; final AdwControls? controls; final Widget? viewSwitcher; @@ -63,8 +62,7 @@ class _AdwScaffoldState extends State { @override Widget build(BuildContext context) { - final isMobile = MediaQuery.of(context).size.width <= - (widget.viewSwitcherConstraint ?? 600); + final isMobile = MediaQuery.of(context).size.width <= (widget.viewSwitcherConstraint ?? 600); final isFlapVisible = widget.flap != null; final isViewSwitcherVisible = widget.viewSwitcher != null; @@ -84,9 +82,7 @@ class _AdwScaffoldState extends State { AdwHeaderBar( actions: widget.actions, controls: widget.controls, - title: isViewSwitcherVisible && !isMobile - ? widget.viewSwitcher - : widget.title, + title: isViewSwitcherVisible && !isMobile ? widget.viewSwitcher : widget.title, end: widget.end ?? [], start: widget.start ?? [], style: widget.headerBarStyle ?? const HeaderBarStyle(), @@ -94,12 +90,8 @@ class _AdwScaffoldState extends State { Expanded( child: Scaffold( key: widget.scaffoldKey, - drawerEnableOpenDragGesture: _flapController - ?.shouldEnableDrawerGesture(FlapPosition.start) ?? - false, - endDrawerEnableOpenDragGesture: _flapController - ?.shouldEnableDrawerGesture(FlapPosition.end) ?? - false, + drawerEnableOpenDragGesture: _flapController?.shouldEnableDrawerGesture(FlapPosition.start) ?? false, + endDrawerEnableOpenDragGesture: _flapController?.shouldEnableDrawerGesture(FlapPosition.end) ?? false, onDrawerChanged: _flapController?.onDrawerChanged, drawer: flap, endDrawer: flap, @@ -114,9 +106,7 @@ class _AdwScaffoldState extends State { : widget.body, bottomNavigationBar: isViewSwitcherVisible && isMobile ? Container( - height: widget.headerBarStyle != null - ? widget.headerBarStyle!.height - : 51, + height: widget.headerBarStyle != null ? widget.headerBarStyle!.height : 51, decoration: BoxDecoration( border: Border( top: BorderSide( diff --git a/lib/src/widgets/adw/new/window_button.dart b/lib/src/widgets/adw/new/window_button.dart index cacb358..b01ee1e 100644 --- a/lib/src/widgets/adw/new/window_button.dart +++ b/lib/src/widgets/adw/new/window_button.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +import 'package:universal_io/io.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index fcfedc4..709bece 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,8 @@ dependencies: package_info_plus: ">=4.0.0 <5.0.0" popover_gtk: ">=0.2.6+3 <1.0.0" url_launcher: ">=6.1.11 <7.0.0" + universal_io: ^2.2.2 + dev_dependencies: very_good_analysis: ^3.0.1 From ebcff79a4214e3c0f41ba449c199b53f8b2197b8 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 12 Apr 2025 18:17:13 +0530 Subject: [PATCH 77/77] update license info (#93) * update license * update license info in example --- example/lib/home_page.dart | 2 +- lib/src/widgets/adw/switch.dart | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 5ba3eac..9025ea0 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -136,7 +136,7 @@ class _MyHomePageState extends State { ], copyright: 'Copyright 2021-2022 Gtk-Flutter Developers', license: const Text( - 'GNU LGPL-3.0, This program comes with no warranty.', + 'MPL-2.0, This program comes with no warranty.', ), ), ), diff --git a/lib/src/widgets/adw/switch.dart b/lib/src/widgets/adw/switch.dart index 78590d2..875cf49 100644 --- a/lib/src/widgets/adw/switch.dart +++ b/lib/src/widgets/adw/switch.dart @@ -1,5 +1,4 @@ // Copyright 2014 The Flutter Authors => BSD-3 License -// Copyright 2022 Gtk-Flutter Authors => LGPL-3 License import 'dart:ui' show lerpDouble;