Compare commits
102 Commits
Author | SHA1 | Date |
---|---|---|
zoe | eff72ee74e | |
zoe | 6c1e8fca85 | |
zoe | 76e29ce7f5 | |
zoe | 25cf6e770e | |
zoe | 0267214cba | |
zoe | 52151dab7c | |
zoe | 2029c55e95 | |
zoe | f18518ad63 | |
zoe | 6fe0f6967e | |
zoe | d98150007e | |
zoe | b76e53def1 | |
zoe | 0caefbe4b9 | |
zoe | 95cecbed9c | |
zoe | 756deea82c | |
zoe | 7933caa158 | |
zoe | 8e7b0e013d | |
zoe | e633750ced | |
zoe | 0c5f512766 | |
zoe | 481dbfa623 | |
zoe | ee226713ae | |
zoe | 51c3cf8b04 | |
zoe | d7a35beb3a | |
zoe | 2f32510bce | |
zoe | d4a6186a35 | |
zoe | d264fc4504 | |
zoe | a73614b5cc | |
zoe | aa46264c64 | |
zoe | 4d2a45ad6c | |
zoe | 429cca8ddb | |
zoe | 2fe67e7964 | |
zoe | b281ffc061 | |
zoe | ad7aaa5c24 | |
zoe | 3101b19a49 | |
zoe | a60e144602 | |
zoe | 4a48a68de4 | |
zoe | 3743cd800f | |
zoe | 2caa91dad5 | |
zoe | 8eb4763ff3 | |
zoe | d077d9a293 | |
zoe | f324e43be3 | |
zoe | 55fb99d9d9 | |
zoe | d0235cac5d | |
zoe | 8aa49dc2ea | |
zoe | 4ac218b065 | |
zoe | 5c4a28765c | |
zoe | 7d4b3160a8 | |
zoe | 1265136030 | |
zoe | 726f3bebee | |
zoe | 55c6c92678 | |
zoe | 1992182f27 | |
zoe | 074f9c3c82 | |
zoe | e2caa421b8 | |
zoe | 8bec897d52 | |
zoe | 99e9294ece | |
zoe | 4b581400d5 | |
zoe | 631cabbf8d | |
zoe | 0bbb74332d | |
zoe | 9d9d2d163c | |
zoe | fc306dd2e6 | |
zoe | 75df7319d5 | |
zoe | 5515fde880 | |
zoe | 4a797f0f41 | |
zoe | a336e197b5 | |
zoe | 374c129adc | |
zoe | c65641a222 | |
zoe | 1b32158805 | |
zoe | ba9f4942bb | |
zoe | cb064cb806 | |
zoe | 1f557d5734 | |
zoe | 014b3987a1 | |
zoe | 3ef67031c4 | |
zoe | 25fb912c7a | |
zoe | d7383295a1 | |
zoe | 0f01665ad0 | |
zoe | 2b0671d785 | |
zoe | effd78f758 | |
tess | c26680c2bc | |
zoe | 2c4eee1526 | |
zoe | 534e31e634 | |
zoe | d976d9ec22 | |
zoe | 44bdefd99a | |
zoe | 0e844936c7 | |
zoe | 96d7ab25df | |
zoe | ea6b3c52eb | |
zoe | 4f249fd34a | |
zoe | 3549d61045 | |
zoe | e7dd160a58 | |
zoe | 8b849fb6ad | |
zoe | c029461303 | |
zoe | 39accd5a6c | |
zoe | 8f0d26e299 | |
zoe | 7249a6eb52 | |
zoe | 04fea3393b | |
zoe | 3cd7ed542d | |
zoe | cda12adce4 | |
zoe | bd2c192b45 | |
zoe | 7afa031ef7 | |
zoe | f2405f750b | |
zoe | 62fc7a17be | |
zoe | 16750473ce | |
tess | 9187d4fcdb | |
zoe | 1c7e11f503 |
|
@ -33,7 +33,6 @@ migrate_working_dir/
|
|||
/build/
|
||||
|
||||
# Web related
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
|
|
@ -0,0 +1,483 @@
|
|||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS
|
||||
COOPERATIVE NON-VIOLENT PUBLIC LICENSE ("LICENSE"). THE WORK IS
|
||||
PROTECTED BY COPYRIGHT AND ALL OTHER APPLICABLE LAWS. ANY USE OF THE
|
||||
WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS
|
||||
PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED IN THIS
|
||||
LICENSE, YOU AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE.TO THE
|
||||
EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR
|
||||
GRANTS YOU THE RIGHTS CONTAINED HERE IN AS CONSIDERATION FOR ACCEPTING
|
||||
THE TERMS AND CONDITIONS OF THIS LICENSE AND FOR AGREEING TO BE BOUND BY
|
||||
THE TERMS AND CONDITIONS OF THIS LICENSE.
|
||||
|
||||
# Definitions
|
||||
|
||||
An Act of War is any action of one country against any group either with
|
||||
an intention to provoke a conflict or an action that occurs during a
|
||||
declared war or during armed conflict between military forces of any
|
||||
origin. This includes but is not limited to enforcing sanctions or
|
||||
sieges, supplying armed forces, or profiting from the manufacture of
|
||||
tools or weaponry used in military conflict.
|
||||
|
||||
An Adaptation is a work based upon the Work, or upon the Work and other
|
||||
pre-existing works, such as a translation, adaptation, derivative work,
|
||||
arrangement of music or other alterations of a literary or artistic
|
||||
work, or phonogram or performance and includes cinematographic
|
||||
adaptations or any other form in which the Work may be recast,
|
||||
transformed, or adapted including in any form recognizably derived from
|
||||
the original, except that a work that constitutes a Collection will not
|
||||
be considered an Adaptation for the purpose of this License. For the
|
||||
avoidance of doubt, where the Work is a musical work, performance or
|
||||
phonogram, the synchronization of the Work in timed-relation with a
|
||||
moving image ("synching") will be considered an Adaptation for the
|
||||
purpose of this License. In addition, where the Work is designed to
|
||||
output a neural network the output of the neural network will be
|
||||
considered an Adaptation for the purpose of this license.
|
||||
|
||||
Bodily Harm is any physical hurt or injury to a person that interferes
|
||||
with the health or comfort of the person and that is more than merely
|
||||
transient or trifling in nature.
|
||||
|
||||
Distribute is to make available to the public the original and copies of
|
||||
the Work or Adaptation, as appropriate, through sale, gift or any other
|
||||
transfer of possession or ownership.
|
||||
|
||||
Incarceration is Confinement in a jail, prison, or any other place where
|
||||
individuals of any kind are held against either their will or (if their
|
||||
will cannot be determined) the will of their legal guardian or
|
||||
guardians. In the case of a conflict between the will of the individual
|
||||
and the will of their legal guardian or guardians, the will of the
|
||||
individual will take precedence.
|
||||
|
||||
Licensor is The individual, individuals, entity, or entities that
|
||||
offer(s) the Work under the terms of this License
|
||||
|
||||
Original Author is in the case of a literary or artistic work, the
|
||||
individual, individuals, entity or entities who created the Work or if
|
||||
no individual or entity can be identified, the publisher; and in
|
||||
addition
|
||||
|
||||
- in the case of a performance the actors, singers, musicians,
|
||||
dancers, and other persons who act, sing, deliver, declaim, play in,
|
||||
interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore;
|
||||
|
||||
- in the case of a phonogram the producer being the person or legal
|
||||
entity who first fixes the sounds of a performance or other sounds;
|
||||
and,
|
||||
|
||||
- in the case of broadcasts, the organization that transmits the
|
||||
broadcast.
|
||||
|
||||
Work is the literary and/or artistic work offered under the terms of
|
||||
this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book, pamphlet
|
||||
and other writing; a lecture, address, sermon or other work of the same
|
||||
nature; a dramatic or dramatico-musical work; a choreographic work or
|
||||
entertainment in dumb show; a musical composition with or without words;
|
||||
a cinematographic work to which are assimilated works expressed by a
|
||||
process analogous to cinematography; a work of drawing, painting,
|
||||
architecture, sculpture, engraving or lithography; a photographic work
|
||||
to which are assimilated works expressed by a process analogous to
|
||||
photography; a work of applied art; an illustration, map, plan, sketch
|
||||
or three-dimensional work relative to geography, topography,
|
||||
architecture or science; a performance; a broadcast; a phonogram; a
|
||||
compilation of data to the extent it is protected as a copyrightable
|
||||
work; or a work performed by a variety or circus performer to the extent
|
||||
it is not otherwise considered a literary or artistic work.
|
||||
|
||||
You means an individual or entity exercising rights under this License
|
||||
who has not previously violated the terms of this License with respect
|
||||
to the Work, or who has received express permission from the Licensor to
|
||||
exercise rights under this License despite a previous violation.
|
||||
|
||||
Publicly Perform means to perform public recitations of the Work and to
|
||||
communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a place
|
||||
individually chosen by them; to perform the Work to the public by any
|
||||
means or process and the communication to the public of the performances
|
||||
of the Work, including by public digital performance; to broadcast and
|
||||
rebroadcast the Work by any means including signs, sounds or images.
|
||||
|
||||
Reproduce is to make copies of the Work by any means including without
|
||||
limitation by sound or visual recordings and the right of fixation and
|
||||
reproducing fixations of the Work, including storage of a protected
|
||||
performance or phonogram in digital form or other electronic medium.
|
||||
|
||||
Software is any digital Work which, through use of a third-party piece
|
||||
of Software or through the direct usage of itself on a computer system,
|
||||
the memory of the computer is modified dynamically or semi-dynamically.
|
||||
"Software", secondly, processes or interprets information.
|
||||
|
||||
Source Code is Any digital Work which, through use of a third-party
|
||||
piece of Software or through the direct usage of itself on a computer
|
||||
system, the memory of the computer is modified dynamically or
|
||||
semi-dynamically. "Software", secondly, processes or interprets
|
||||
information.
|
||||
|
||||
Surveilling is the use of the Work to either overtly or covertly observe
|
||||
and record persons and or their activities.
|
||||
|
||||
A Network Service is the use of a piece of Software to interpret or
|
||||
modify information that is subsequently and directly served to users
|
||||
over the Internet.
|
||||
|
||||
To Discriminate is the use of a piece of Software to interpret or modify
|
||||
information that is subsequently and directly served to users over the
|
||||
Internet.
|
||||
|
||||
Hate Speech is Communication or any form of expression which is solely
|
||||
for the purpose of expressing hatred for some group or advocating a form
|
||||
of Discrimination between humans.
|
||||
|
||||
Coercion is leveraging of the threat of force or use of force to
|
||||
intimidate a person in order to gain compliance, or to offer large
|
||||
incentives which aim to entice a person to act against their will.
|
||||
|
||||
# Fair Dealing Rights
|
||||
|
||||
Nothing in this License is intended to reduce, limit, or restrict any
|
||||
uses free from copyright or rights arising from limitations or
|
||||
exceptions that are provided for in connection with the copyright
|
||||
protection under copyright law or other applicable laws.
|
||||
|
||||
# License Grant
|
||||
|
||||
Subject to the terms and conditions of this License, Licensor hereby
|
||||
grants You a worldwide, royalty-free, non-exclusive, perpetual (for the
|
||||
duration of the applicable copyright) license to exercise the rights in
|
||||
the Work as stated below:
|
||||
|
||||
To Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections
|
||||
|
||||
To create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made to
|
||||
the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified."
|
||||
|
||||
To Distribute and Publicly Perform the Work including as incorporated in
|
||||
Collections.
|
||||
|
||||
To Distribute and Publicly Perform Adaptations. The above rights may be
|
||||
exercised in all media and formats whether now known or hereafter
|
||||
devised. The above rights include the right to make such modifications
|
||||
as are technically necessary to exercise the rights in other media and
|
||||
formats. This License constitutes the entire agreement between the
|
||||
parties with respect to the Work licensed here. There are no
|
||||
understandings, agreements or representations with respect to the Work
|
||||
not specified here. Licensor shall not be bound by any additional
|
||||
provisions that may appear in any communication from You. This License
|
||||
may not be modified without the mutual written agreement of the Licensor
|
||||
and You. All rights not expressly granted by Licensor are hereby
|
||||
reserved, including but not limited to the rights set forth in
|
||||
Non-waivable Compulsory License Schemes, Waivable Compulsory License
|
||||
Schemes, and Voluntary License Schemes in the restrictions.
|
||||
|
||||
# Restrictions
|
||||
|
||||
The license granted in the license grant above is expressly made subject
|
||||
to and limited by the following restrictions:
|
||||
|
||||
You may Distribute or Publicly Perform the Work only under the terms of
|
||||
this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms on
|
||||
the Work that restrict the terms of this License or the ability of the
|
||||
recipient of the Work to exercise the rights granted to that recipient
|
||||
under the terms of the License. You may not sublicense the Work. You
|
||||
must keep intact all notices that refer to this License and to the
|
||||
disclaimer of warranties with every copy of the Work You Distribute or
|
||||
Publicly Perform. When You Distribute or Publicly Perform the Work, You
|
||||
may not impose any effective technological measures on the Work that
|
||||
restrict the ability of a recipient of the Work from You to exercise the
|
||||
rights granted to that recipient under the terms of the License. This
|
||||
Section applies to the Work as incorporated in a Collection, but this
|
||||
does not require the Collection apart from the Work itself to be made
|
||||
subject to the terms of this License. If You create a Collection, upon
|
||||
notice from any Licensor You must, to the extent practicable, remove
|
||||
from the Collection any credit as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as requested.
|
||||
|
||||
## Commercial Restrictions
|
||||
|
||||
You may not exercise any of the rights granted to You in the above
|
||||
section in any manner that is primarily intended for or directed toward
|
||||
commercial advantage or private monetary compensation unless you meet
|
||||
the following requirements.
|
||||
|
||||
i. You are a worker-owned business or worker-owned collective.
|
||||
|
||||
ii. after tax, all financial gain, surplus, profits and benefits
|
||||
produced by the business or collective are distributed among the
|
||||
worker-owners unless a set amount is to be allocated towards
|
||||
community projects as decided by a previously-established consensus
|
||||
agreement between the worker-owners where all worker-owners agreed.
|
||||
|
||||
iii. You are not using such rights on behalf of a business other than
|
||||
those specified in (i) or (ii) above, nor are using such rights as
|
||||
a proxy on behalf of a business with the intent to circumvent the
|
||||
aforementioned restrictions on such a business.
|
||||
|
||||
The exchange of the Work for other copyrighted works by means of digital
|
||||
file-sharing or otherwise shall not be considered to be intended for or
|
||||
directed toward commercial advantage or private monetary compensation,
|
||||
provided there is no payment of any monetary compensation in connection
|
||||
with the exchange of copyrighted works.
|
||||
|
||||
If the Work meets the definition of Software, You may exercise the
|
||||
rights granted in the license grant only if You provide a copy of the
|
||||
corresponding Source Code from which the Work was derived in digital
|
||||
form, or You provide a URI for the corresponding Source Code of the
|
||||
Work, to any recipients upon request.
|
||||
|
||||
If the Work is used as or for a Network Service, You may exercise the
|
||||
rights granted in the license grant only if You provide a copy of the
|
||||
corresponding Source Code from which the Work was derived in digital
|
||||
form, or You provide a URI for the corresponding Source Code to the
|
||||
Work, to any recipients of the data served or modified by the Web
|
||||
Service.
|
||||
|
||||
Any use by a business that is privately owned and managed, and that
|
||||
seeks to generate profit from the labor of employees paid by salary or
|
||||
other wages, is not permitted under this license.
|
||||
|
||||
##
|
||||
|
||||
You may exercise the rights granted in the license grant for any
|
||||
purposes only if:
|
||||
|
||||
i. You do not use the Work for the purpose of inflicting Bodily Harm on
|
||||
human beings (subject to criminal prosecution or otherwise) outside
|
||||
of providing medical aid or undergoing a voluntary procedure under
|
||||
no form of Coercion.
|
||||
|
||||
ii. You do not use the Work for the purpose of Surveilling or tracking
|
||||
individuals for financial gain.
|
||||
|
||||
iii. You do not use the Work in an Act of War.
|
||||
|
||||
iv. You do not use the Work for the purpose of supporting or profiting
|
||||
from an Act of War.
|
||||
|
||||
v. You do not use the Work for the purpose of Incarceration.
|
||||
|
||||
vi. You do not use the Work for the purpose of extracting, processing,
|
||||
or refining, oil, gas, or coal. Or to in any other way to
|
||||
deliberately pollute the environment as a byproduct of manufacturing
|
||||
or irresponsible disposal of hazardous materials.
|
||||
|
||||
vii. You do not use the Work for the purpose of expediting,
|
||||
coordinating, or facilitating paid work undertaken by individuals
|
||||
under the age of 12 years.
|
||||
|
||||
viii. You do not use the Work to either Discriminate or spread Hate
|
||||
Speech on the basis of sex, sexual orientation, gender identity,
|
||||
race, age, disability, color, national origin, religion, caste, or
|
||||
lower economic status.
|
||||
|
||||
##
|
||||
|
||||
If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made by any Licensor to
|
||||
remove credit from a Collection or Adaptation, keep intact all copyright
|
||||
notices for the Work and provide, reasonable to the medium or means You
|
||||
are utilizing:
|
||||
|
||||
i. the name of the Original Author (or pseudonym, if applicable) if
|
||||
supplied, and/or if the Original Author and/or Licensor designate
|
||||
another party or parties (e.g., a sponsor institute, publishing
|
||||
entity, journal) for attribution ("Attribution Parties") in
|
||||
Licensor's copyright notice, terms of service or by other
|
||||
reasonable means, the name of such party or parties;
|
||||
|
||||
ii. the title of the Work if supplied;
|
||||
|
||||
iii. to the extent reasonably practicable, the URI, if any, that
|
||||
Licensor to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the
|
||||
Work; and,
|
||||
|
||||
iv. in the case of an Adaptation, a credit identifying the use of the
|
||||
Work in the Adaptation (e.g., "French translation of the Work by
|
||||
Original Author," or "Screenplay based on original Work by
|
||||
Original Author").
|
||||
|
||||
If any Licensor has sent notice to request removing credit, You must, to
|
||||
the extent practicable, remove any credit as requested. The credit
|
||||
required by this Section may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of an Adaptation or Collection, at a
|
||||
minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only use
|
||||
the credit required by this Section for the purpose of attribution in
|
||||
the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your use
|
||||
of the Work, without the separate, express prior written permission of
|
||||
the Original Author, Licensor and/or Attribution Parties.
|
||||
|
||||
Non-waivable Compulsory License Schemes. In those jurisdictions in which
|
||||
the right to collect royalties through any statutory or compulsory
|
||||
licensing scheme cannot be waived, the Licensor reserves the exclusive
|
||||
right to collect such royalties for any exercise by You of the rights
|
||||
granted under this License
|
||||
|
||||
Waivable Compulsory License Schemes. In those jurisdictions in which the
|
||||
right to collect royalties through any statutory or compulsory licensing
|
||||
scheme can be waived, the Licensor reserves the exclusive right to
|
||||
collect such royalties for any exercise by You of the rights granted
|
||||
under this License if Your exercise of such rights is for a purpose or
|
||||
use which is otherwise than noncommercial as permitted under Commercial
|
||||
Restrictions and otherwise waives the right to collect royalties through
|
||||
any statutory or compulsory licensing scheme.
|
||||
|
||||
Voluntary License Schemes. The Licensor reserves the right to collect
|
||||
royalties, whether individually or, in the event that the Licensor is a
|
||||
member of a collecting society that administers voluntary licensing
|
||||
schemes, via that society, from any exercise by You of the rights
|
||||
granted under this License that is for a purpose or use which is
|
||||
otherwise than noncommercial as permitted under the license grant.
|
||||
|
||||
Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any Adaptations
|
||||
or Collections, You must not distort, mutilate, modify or take other
|
||||
derogatory action in relation to the Work which would be prejudicial to
|
||||
the Original Author's honor or reputation. Licensor agrees that in
|
||||
those jurisdictions (e.g. Japan), in which any exercise of the right
|
||||
granted in the license grant of this License (the right to make
|
||||
Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your right
|
||||
under the license grant of this License (right to make Adaptations) but
|
||||
not otherwise.
|
||||
|
||||
Do not make any legal claim against anyone accusing the Work, with or
|
||||
without changes, alone or with other works, of infringing any patent
|
||||
claim.
|
||||
|
||||
# Representations Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
# Limitation on Liability
|
||||
|
||||
EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL
|
||||
LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF
|
||||
THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
# Termination
|
||||
|
||||
This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. The Sections on definitions, fair
|
||||
dealing rights, representations, warranties, and disclaimer, limitation
|
||||
on liability, termination, and revised license versions will survive any
|
||||
termination of this License.
|
||||
|
||||
Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
# Revised License Versions
|
||||
|
||||
This License may receive future revisions in the original spirit of the
|
||||
license intended to strengthen This License. Each version of This
|
||||
License has an incrementing version number.
|
||||
|
||||
Unless otherwise specified like in the below subsection The Licensor has
|
||||
only granted this current version of This License for The Work. In this
|
||||
case future revisions do not apply.
|
||||
|
||||
The Licensor may specify that the latest available revision of This
|
||||
License be used for The Work by either explicitly writing so or by
|
||||
suffixing the License URI with a "+" symbol.
|
||||
|
||||
The Licensor may specify that The Work is also available under the terms
|
||||
of This License's current revision as well as specific future
|
||||
revisions. The Licensor may do this by writing it explicitly or
|
||||
suffixing the License URI with any additional version numbers each
|
||||
separated by a comma.
|
||||
|
||||
# Miscellaneous
|
||||
|
||||
Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
|
||||
Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same terms
|
||||
and conditions as the license granted to You under this License.
|
||||
|
||||
If the Work is classified as Software, each time You Distribute or
|
||||
Publicly Perform an Adaptation, Licensor offers to the recipient a copy
|
||||
and/or URI of the corresponding Source Code on the same terms and
|
||||
conditions as the license granted to You under this License.
|
||||
|
||||
If the Work is used as a Network Service, each time You Distribute or
|
||||
Publicly Perform an Adaptation, or serve data derived from the Software,
|
||||
the Licensor offers to any recipients of the data a copy and/or URI of
|
||||
the corresponding Source Code on the same terms and conditions as the
|
||||
license granted to You under this License.
|
||||
|
||||
If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
|
||||
No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
|
||||
This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that may
|
||||
appear in any communication from You. This License may not be modified
|
||||
without the mutual written agreement of the Licensor and You.
|
||||
|
||||
The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and
|
||||
the Universal Copyright Convention (as revised on July 24, 1971). These
|
||||
rights and subject matter take effect in the relevant jurisdiction in
|
||||
which the License terms are sought to be enforced according to the
|
||||
corresponding provisions of the implementation of those treaty
|
||||
provisions in the applicable national law. If the standard suite of
|
||||
rights granted under applicable copyright law includes additional rights
|
||||
not granted under this License, such additional rights are deemed to be
|
||||
included in the License; this License is not intended to restrict the
|
||||
license of any rights under applicable law.
|
16
README.md
16
README.md
|
@ -1,3 +1,17 @@
|
|||
# loris
|
||||
|
||||
the best fedi client for gotosocial and mastodon (soon)(i promise)
|
||||
the best (soon)(i promise) fedi client for gotosocial and mastodon
|
||||
|
||||
## features
|
||||
|
||||
- [x] multi account support
|
||||
- [x] viewing your timeline
|
||||
- [x] notifications
|
||||
- [x] making text posts and replies
|
||||
- [x] liking and boosting posts
|
||||
- [x] content warnings
|
||||
- [x] viewing profiles
|
||||
- [x] viewing posts with full context
|
||||
- [x] search
|
||||
- [x] posting media attachments
|
||||
- [x] chat
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
-keep class androidx.lifecycle.DefaultLifecycleObserver
|
|
@ -1,9 +1,11 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="kittycat.homes.loris">
|
||||
<application
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application
|
||||
android:label="loris"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
|
674
assets/license
674
assets/license
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -1,13 +1,316 @@
|
|||
class AccountModel {
|
||||
late String acct;
|
||||
late String displayName;
|
||||
late String avatar;
|
||||
late String url;
|
||||
import 'dart:convert';
|
||||
|
||||
AccountModel.fromJson(Map<String, dynamic> json) {
|
||||
acct = json["acct"];
|
||||
displayName = json["display_name"];
|
||||
avatar = json["avatar"];
|
||||
url = json["url"];
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
|
||||
class AccountModel {
|
||||
final String acct;
|
||||
final String displayName;
|
||||
final String avatar;
|
||||
final String url;
|
||||
final String id;
|
||||
final String note;
|
||||
final String header;
|
||||
final bool locked;
|
||||
final bool? discoverable;
|
||||
final List<dynamic>? fields;
|
||||
final bool? bot;
|
||||
final bool? suspended;
|
||||
final String identity;
|
||||
final List<Emoji> emojis;
|
||||
|
||||
AccountModel({
|
||||
required this.identity,
|
||||
required this.note,
|
||||
required this.header,
|
||||
required this.locked,
|
||||
this.discoverable,
|
||||
this.fields,
|
||||
this.bot,
|
||||
this.suspended,
|
||||
required this.acct,
|
||||
required this.displayName,
|
||||
required this.avatar,
|
||||
required this.url,
|
||||
required this.id,
|
||||
required this.emojis,
|
||||
});
|
||||
|
||||
factory AccountModel.fromJson(Map<String, dynamic> json, String identity) {
|
||||
List<Emoji> emoji = [];
|
||||
if (json["emojis"] != null) {
|
||||
for (var e in json["emojis"]) {
|
||||
emoji.add(Emoji.fromJson(e));
|
||||
}
|
||||
}
|
||||
|
||||
return AccountModel(
|
||||
identity: identity,
|
||||
id: json["id"],
|
||||
acct: json["acct"],
|
||||
displayName: json["display_name"],
|
||||
avatar: json["avatar"],
|
||||
url: json["url"],
|
||||
note: json["note"],
|
||||
discoverable: json["discoverable"],
|
||||
header: json["header"],
|
||||
locked: json["locked"],
|
||||
bot: json["bot"],
|
||||
fields: json["fields"],
|
||||
suspended: json["suspended"],
|
||||
emojis: emoji,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RelationshipModel {
|
||||
final String identity;
|
||||
final bool blockedBy;
|
||||
final bool blocking;
|
||||
final bool endorsed;
|
||||
final bool followedBy;
|
||||
final bool following;
|
||||
final String id;
|
||||
final bool muting;
|
||||
final bool mutingNotifications;
|
||||
final String note;
|
||||
final bool notifying;
|
||||
final bool requested;
|
||||
final bool showingReblogs;
|
||||
|
||||
RelationshipModel({
|
||||
required this.identity,
|
||||
required this.blockedBy,
|
||||
required this.blocking,
|
||||
required this.endorsed,
|
||||
required this.followedBy,
|
||||
required this.following,
|
||||
required this.id,
|
||||
required this.muting,
|
||||
required this.mutingNotifications,
|
||||
required this.note,
|
||||
required this.notifying,
|
||||
required this.requested,
|
||||
required this.showingReblogs,
|
||||
});
|
||||
|
||||
factory RelationshipModel.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
String identity,
|
||||
) {
|
||||
return RelationshipModel(
|
||||
identity: identity,
|
||||
blockedBy: json["blocked_by"],
|
||||
blocking: json["blocking"],
|
||||
endorsed: json["endorsed"],
|
||||
followedBy: json["followed_by"],
|
||||
following: json["following"],
|
||||
id: json["id"],
|
||||
muting: json["muting"],
|
||||
mutingNotifications: json["muting_notifications"],
|
||||
note: json["note"],
|
||||
notifying: json["notifying"],
|
||||
requested: json["requested"],
|
||||
showingReblogs: json["showing_reblogs"]);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<int, RelationshipModel?>> getRelationship(
|
||||
String identityName, String id) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
|
||||
Map<String, String> headers = identity.getAuthHeaders();
|
||||
headers.addAll(global.defaultHeaders);
|
||||
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/accounts/relationships",
|
||||
queryParameters: {"id": id},
|
||||
);
|
||||
|
||||
final response = await http.get(uri, headers: headers);
|
||||
if (response.statusCode == 200 && jsonDecode(response.body).isNotEmpty) {
|
||||
return {
|
||||
response.statusCode:
|
||||
RelationshipModel.fromJson(jsonDecode(response.body)[0], identityName)
|
||||
};
|
||||
}
|
||||
|
||||
return {response.statusCode: null};
|
||||
}
|
||||
|
||||
Future<Map<int, AccountModel?>> searchModel(
|
||||
String identityName, String url) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
|
||||
Map<String, String> headers = identity.getAuthHeaders();
|
||||
headers.addAll(global.defaultHeaders);
|
||||
|
||||
Map<String, String> params = {
|
||||
"type": "accounts",
|
||||
"q": url,
|
||||
"limit": "1",
|
||||
"resolve": "true",
|
||||
};
|
||||
|
||||
final uri1 = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/search",
|
||||
queryParameters: params,
|
||||
);
|
||||
final uri2 = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v2/search",
|
||||
queryParameters: params,
|
||||
);
|
||||
|
||||
final r1 = await http.get(uri1, headers: headers);
|
||||
if (r1.statusCode == 200) {
|
||||
List<dynamic> accounts = jsonDecode(r1.body)["accounts"];
|
||||
if (accounts.isEmpty) {
|
||||
return {r1.statusCode: null};
|
||||
}
|
||||
return {
|
||||
r1.statusCode: AccountModel.fromJson(
|
||||
jsonDecode(r1.body)["accounts"][0],
|
||||
identityName,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
final r2 = await http.get(uri2, headers: headers);
|
||||
if (r2.statusCode == 200) {
|
||||
List<dynamic> accounts = jsonDecode(r2.body)["accounts"];
|
||||
if (accounts.isEmpty) {
|
||||
return {r2.statusCode: null};
|
||||
}
|
||||
return {
|
||||
r2.statusCode: AccountModel.fromJson(
|
||||
jsonDecode(r2.body)["accounts"][0],
|
||||
identityName,
|
||||
)
|
||||
};
|
||||
}
|
||||
return {r2.statusCode: null};
|
||||
}
|
||||
|
||||
Future<MapEntry<int, List<ThreadModel>?>> getPostsForAccount(
|
||||
AccountModel model,
|
||||
String? maxid,
|
||||
) async {
|
||||
final identity = global.settings!.identities[model.identity];
|
||||
var headers = identity!.getAuthHeaders();
|
||||
headers.addAll(global.defaultHeaders);
|
||||
final params = {
|
||||
"limit": global.settings!.batchSize.toString(),
|
||||
if (maxid != null) "max_id": maxid,
|
||||
};
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/accounts/${model.id}/statuses",
|
||||
queryParameters: params,
|
||||
);
|
||||
|
||||
final r = await http.get(uri, headers: headers);
|
||||
if (r.statusCode != 200) {
|
||||
return MapEntry(r.statusCode, null);
|
||||
}
|
||||
|
||||
List<dynamic> rb = jsonDecode(r.body);
|
||||
List<PostModel> posts = [];
|
||||
for (var element in rb) {
|
||||
posts.add(PostModel.fromJson(element, model.identity));
|
||||
}
|
||||
// posts.sort();
|
||||
|
||||
List<ThreadModel> threads = [];
|
||||
for (var element in posts) {
|
||||
threads.add(
|
||||
await element.getThread(),
|
||||
);
|
||||
}
|
||||
return MapEntry(r.statusCode, threads);
|
||||
}
|
||||
|
||||
enum AccountInteractionTypes {
|
||||
follow,
|
||||
block,
|
||||
mute,
|
||||
}
|
||||
|
||||
extension AccountInteractionTypesExenstion on AccountInteractionTypes {
|
||||
String get slug {
|
||||
switch (this) {
|
||||
case AccountInteractionTypes.block:
|
||||
return "block";
|
||||
case AccountInteractionTypes.follow:
|
||||
return "follow";
|
||||
case AccountInteractionTypes.mute:
|
||||
return "mute";
|
||||
}
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
case AccountInteractionTypes.block:
|
||||
return Icons.block;
|
||||
case AccountInteractionTypes.follow:
|
||||
return Icons.person_add;
|
||||
case AccountInteractionTypes.mute:
|
||||
return Icons.volume_off;
|
||||
}
|
||||
}
|
||||
|
||||
String get revokeSlug {
|
||||
switch (this) {
|
||||
case AccountInteractionTypes.block:
|
||||
return "unblock";
|
||||
case AccountInteractionTypes.follow:
|
||||
return "unfollow";
|
||||
case AccountInteractionTypes.mute:
|
||||
return "unmute";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum AccountTextInteractionTypes {
|
||||
note,
|
||||
report,
|
||||
}
|
||||
|
||||
Future<MapEntry<int, RelationshipModel?>> performInteraction(
|
||||
String identityName,
|
||||
String accountId,
|
||||
AccountInteractionTypes type,
|
||||
bool revoke,
|
||||
) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
var headers = identity.getAuthHeaders();
|
||||
|
||||
headers.addAll(global.defaultHeaders);
|
||||
headers.remove("Content-Type");
|
||||
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path:
|
||||
"/api/v1/accounts/$accountId/${revoke ? type.revokeSlug : type.slug}");
|
||||
final response = await http.post(uri, headers: headers);
|
||||
if (response.statusCode != 200) {
|
||||
return MapEntry(response.statusCode, null);
|
||||
}
|
||||
return MapEntry(
|
||||
response.statusCode,
|
||||
RelationshipModel.fromJson(
|
||||
jsonDecode(response.body),
|
||||
identityName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
@ -38,6 +39,10 @@ String _authCode = "";
|
|||
String _url = "";
|
||||
App? _app;
|
||||
|
||||
App? getApp() {
|
||||
return _app;
|
||||
}
|
||||
|
||||
Response readAuthcode(Request request) {
|
||||
Map<String, String> params = request.url.queryParameters;
|
||||
if (params.containsKey("code") && params["code"] != null) {
|
||||
|
@ -72,20 +77,27 @@ Future<int> handleFullOauth(String url) async {
|
|||
return response.statusCode;
|
||||
}
|
||||
|
||||
_authCode = "";
|
||||
var handler = const Pipeline().addHandler(readAuthcode);
|
||||
var server = await shelf_io.serve(handler, 'localhost', 1312);
|
||||
await pollCode();
|
||||
server.close();
|
||||
String token =
|
||||
await getToken(_authCode, _app!.clientId, _app!.clientSecret, _url);
|
||||
await saveIdentity(
|
||||
token,
|
||||
url,
|
||||
_app!,
|
||||
_authCode,
|
||||
);
|
||||
return 200;
|
||||
if (!kIsWeb) {
|
||||
// if this is not a web app we can simply start a server
|
||||
// and listen for a code there
|
||||
_authCode = "";
|
||||
var handler = const Pipeline().addHandler(readAuthcode);
|
||||
var server = await shelf_io.serve(handler, 'localhost', 1312);
|
||||
await pollCode();
|
||||
server.close();
|
||||
String token =
|
||||
await getToken(_authCode, _app!.clientId, _app!.clientSecret, _url);
|
||||
await saveIdentity(
|
||||
token,
|
||||
url,
|
||||
_app!.clientId,
|
||||
_app!.clientSecret,
|
||||
_authCode,
|
||||
);
|
||||
return 200;
|
||||
} else {
|
||||
return 6969696969696969;
|
||||
}
|
||||
} catch (e) {
|
||||
return 400;
|
||||
}
|
||||
|
@ -94,7 +106,8 @@ Future<int> handleFullOauth(String url) async {
|
|||
Future<bool> saveIdentity(
|
||||
String token,
|
||||
String baseurl,
|
||||
App app,
|
||||
String clientId,
|
||||
String clientSecret,
|
||||
String authCode,
|
||||
) async {
|
||||
Map<String, String> headers = {"Authorization": "Bearer $token"};
|
||||
|
@ -108,10 +121,14 @@ Future<bool> saveIdentity(
|
|||
headers: headers,
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final account = AccountModel.fromJson(jsonDecode(response.body));
|
||||
final account = AccountModel.fromJson(
|
||||
jsonDecode(response.body),
|
||||
"${jsonDecode(response.body)["acct"]}@$baseurl",
|
||||
);
|
||||
await global.settings!.addNewIdentity("${account.acct}@$baseurl");
|
||||
await global.settings!.saveActiveIdentity("${account.acct}@$baseurl");
|
||||
await global.settings!.identities["${account.acct}@$baseurl"]!.saveApp(app);
|
||||
await global.settings!.identities["${account.acct}@$baseurl"]!
|
||||
.saveApp(clientId, clientSecret);
|
||||
await global.settings!.identities["${account.acct}@$baseurl"]!
|
||||
.saveAuthCode(authCode);
|
||||
await global.settings!.identities["${account.acct}@$baseurl"]!
|
||||
|
@ -141,7 +158,7 @@ Future<http.Response> doOauthFlow() async {
|
|||
String url = _url;
|
||||
try {
|
||||
http.Response response = await registerApp(url);
|
||||
openBrowserForAuthCode(url, App.fromJson(jsonDecode(response.body)));
|
||||
openBrowserForAuthCode(url, _app!);
|
||||
return response;
|
||||
} catch (e) {
|
||||
return http.Response(jsonEncode({}), 404);
|
||||
|
@ -151,19 +168,35 @@ Future<http.Response> doOauthFlow() async {
|
|||
Future<http.Response> registerApp(String baseurl) async {
|
||||
//String url = baseurl Uri."api/v1/apps";
|
||||
Uri url = Uri.https(baseurl, "/api/v1/apps");
|
||||
final Map<String, String> params = {
|
||||
'client_name': global.name,
|
||||
'redirect_uris': kIsWeb
|
||||
? "${Uri.base.origin}/login/redirect.html"
|
||||
: "http://localhost:1312",
|
||||
'scopes': "read write follow push",
|
||||
'website': global.website,
|
||||
};
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: global.defaultHeaders,
|
||||
body: jsonEncode({
|
||||
'client_name': global.name,
|
||||
'redirect_uris': "http://localhost:1312",
|
||||
'scopes': "read write follow push",
|
||||
'website': global.website
|
||||
}),
|
||||
body: jsonEncode(params),
|
||||
);
|
||||
_app = App.fromJson(jsonDecode(response.body));
|
||||
return response;
|
||||
}
|
||||
|
||||
Uri getAuthUrl(String baseurl, App app) {
|
||||
return Uri(
|
||||
scheme: "https",
|
||||
path: "$baseurl/oauth/authorize",
|
||||
// ignore: prefer_interpolation_to_compose_strings
|
||||
query: "client_id=" +
|
||||
app.clientId +
|
||||
"&scope=read+write+follow+push" +
|
||||
"&redirect_uri=${kIsWeb ? "${Uri.base.origin}/login/redirect.html" : "http://localhost:1312"}" +
|
||||
"&response_type=code");
|
||||
}
|
||||
|
||||
void openBrowserForAuthCode(String baseurl, App app) {
|
||||
Uri url = Uri(
|
||||
scheme: "https",
|
||||
|
@ -172,9 +205,14 @@ void openBrowserForAuthCode(String baseurl, App app) {
|
|||
query: "client_id=" +
|
||||
app.clientId +
|
||||
"&scope=read+write+follow+push" +
|
||||
"&redirect_uri=http://localhost:1312" +
|
||||
"&redirect_uri=${kIsWeb ? "${Uri.base.origin}/login/redirect.html" : "http://localhost:1312"}" +
|
||||
"&response_type=code");
|
||||
launchUrl(url);
|
||||
launchUrl(
|
||||
mode: LaunchMode.externalApplication,
|
||||
url,
|
||||
webOnlyWindowName: "loris",
|
||||
webViewConfiguration: const WebViewConfiguration(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> getToken(
|
||||
|
@ -184,21 +222,25 @@ Future<String> getToken(
|
|||
String baseurl,
|
||||
) async {
|
||||
Uri url = Uri.https(baseurl, "/oauth/token");
|
||||
final args = jsonEncode({
|
||||
'grant_type': "authorization_code",
|
||||
'client_id': appId,
|
||||
'client_secret': clientSecret,
|
||||
'redirect_uri': kIsWeb
|
||||
? "${Uri.base.origin}/login/redirect.html"
|
||||
: "http://localhost:1312",
|
||||
'scope': "read write follow push",
|
||||
'code': authCode,
|
||||
});
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: global.defaultHeaders,
|
||||
body: jsonEncode({
|
||||
'grant_type': "authorization_code",
|
||||
'client_id': appId,
|
||||
'client_secret': clientSecret,
|
||||
'redirect_uri': "http://localhost:1312",
|
||||
'scope': "read write follow push",
|
||||
'code': authCode,
|
||||
}),
|
||||
body: args,
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final dec = jsonDecode(response.body);
|
||||
return dec["access_token"]!;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class ConversationModel implements Comparable {
|
||||
final String id;
|
||||
final List<AccountModel> accounts;
|
||||
final bool unread;
|
||||
final PostModel? lastStatus;
|
||||
final String identity;
|
||||
|
||||
ConversationModel(
|
||||
{required this.id,
|
||||
required this.accounts,
|
||||
required this.unread,
|
||||
this.lastStatus,
|
||||
required this.identity});
|
||||
|
||||
factory ConversationModel.fromJson(
|
||||
Map<String, dynamic> json, String identity) {
|
||||
final List accountsJson = json["accounts"];
|
||||
final List<AccountModel> accounts = accountsJson
|
||||
.map(
|
||||
(e) => AccountModel.fromJson(e, identity),
|
||||
)
|
||||
.toList();
|
||||
|
||||
return ConversationModel(
|
||||
accounts: accounts,
|
||||
id: json["id"],
|
||||
identity: identity,
|
||||
unread: json["unread"],
|
||||
lastStatus: PostModel.fromJson(json["last_status"], identity));
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTo(other) {
|
||||
if (lastStatus == null && other.lastStatus == null) return 0;
|
||||
|
||||
if (lastStatus == null) return -1;
|
||||
return lastStatus!.createdAt.compareTo(other.lastStatus!.createdAt);
|
||||
}
|
||||
|
||||
String getAccountsString() {
|
||||
String ret = "";
|
||||
for (var acc in accounts) {
|
||||
ret = "$ret${acc.acct}";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
class ConversationModelResult {
|
||||
// list of models
|
||||
final List<ConversationModel> models;
|
||||
|
||||
final Map<String, String?> maxIds;
|
||||
|
||||
ConversationModelResult(this.models, {this.maxIds = const {}});
|
||||
}
|
||||
|
||||
/*
|
||||
loads conversation models from timeline
|
||||
*/
|
||||
Future<ConversationModelResult> _getConversationModels(
|
||||
String identityName,
|
||||
String? maxId,
|
||||
) async {
|
||||
final settings = global.settings!;
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
final headers = {
|
||||
...identity.getAuthHeaders(),
|
||||
...global.defaultHeaders,
|
||||
};
|
||||
final Map<String, String> queries = {
|
||||
"limit": settings.batchSize.toString(),
|
||||
if (maxId != null) "max_id": maxId,
|
||||
};
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
queryParameters: queries,
|
||||
path: "/api/v1/conversations",
|
||||
);
|
||||
|
||||
final result = await http.get(uri, headers: headers);
|
||||
if (result.statusCode != 200) {
|
||||
return ConversationModelResult([]);
|
||||
}
|
||||
|
||||
String? newMaxId = result.headers["link"];
|
||||
final firstOpen = newMaxId?.indexOf("<");
|
||||
final firstClose = newMaxId?.indexOf(">");
|
||||
newMaxId = newMaxId?.substring(firstOpen! + 1, firstClose);
|
||||
if (newMaxId != null) {
|
||||
final maxIdUri = Uri.parse(newMaxId);
|
||||
newMaxId = maxIdUri.queryParameters["max_id"];
|
||||
}
|
||||
|
||||
return ConversationModelResult(
|
||||
jsonDecode(result.body)
|
||||
.map<ConversationModel>(
|
||||
(e) => ConversationModel.fromJson(e, identityName),
|
||||
)
|
||||
.toList(),
|
||||
maxIds: {identityName: newMaxId},
|
||||
);
|
||||
}
|
||||
|
||||
Future<ConversationModelResult> getAllConversationModels(
|
||||
Map<String, String?> maxIds) async {
|
||||
List<Future> futureResults = [];
|
||||
global.settings!.identities.forEach((key, value) {
|
||||
futureResults.add(_getConversationModels(key, maxIds[key]));
|
||||
});
|
||||
List<ConversationModelResult> results = [];
|
||||
List<ConversationModel> models = [];
|
||||
for (var element in futureResults) {
|
||||
final r = await element;
|
||||
results.add(r);
|
||||
models.addAll(r.models);
|
||||
}
|
||||
models.sort();
|
||||
models = models.reversed.toList();
|
||||
if (models.length > global.settings!.batchSize) {
|
||||
models = models.sublist(0, global.settings!.batchSize);
|
||||
}
|
||||
Map<String, String?> newMaxIds = {};
|
||||
for (var element in results) {
|
||||
newMaxIds.addAll(element.maxIds);
|
||||
}
|
||||
|
||||
Set<String> appearingIdentities = {};
|
||||
for (var i in models) {
|
||||
appearingIdentities.add(i.identity);
|
||||
}
|
||||
|
||||
newMaxIds.removeWhere((key, value) => (appearingIdentities.contains(value)));
|
||||
return ConversationModelResult(models, maxIds: newMaxIds);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
class Emoji {
|
||||
final String shortcode;
|
||||
final String url;
|
||||
Emoji({required this.shortcode, required this.url});
|
||||
|
||||
factory Emoji.fromJson(Map<String, dynamic> json) {
|
||||
return Emoji(
|
||||
shortcode: json["shortcode"],
|
||||
url: json["url"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String insertEmojiInMd(String input, Emoji emoji) {
|
||||
return input.replaceAll(
|
||||
":${emoji.shortcode}:", "![${emoji.shortcode}](${emoji.url})");
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class FileUpload {
|
||||
String description;
|
||||
final String path;
|
||||
|
||||
// media id for identity,
|
||||
// gets set after first sucessfully uploading
|
||||
Map<String, String> ids = {};
|
||||
|
||||
FileUpload({
|
||||
required this.description,
|
||||
required this.path,
|
||||
this.ids = const {},
|
||||
});
|
||||
|
||||
static Future<FileUpload> fromPath(String path, String description) async {
|
||||
return FileUpload(
|
||||
description: description,
|
||||
path: path,
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
sends a media attachments and returns the http status code
|
||||
if the status code is 200, the String is the media attachments id,
|
||||
otherwise it's the error response
|
||||
*/
|
||||
Future<MapEntry<int, String>> upload(String identityName) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
final headers = {
|
||||
...global.defaultHeaders,
|
||||
...identity.getAuthHeaders(),
|
||||
};
|
||||
final uri =
|
||||
Uri(scheme: "https", host: identity.instanceUrl, path: "/api/v1/media");
|
||||
final request = MultipartRequest(
|
||||
"POST",
|
||||
uri,
|
||||
);
|
||||
request.headers.addAll(headers);
|
||||
request.files.add(await MultipartFile.fromPath(
|
||||
"file",
|
||||
path,
|
||||
));
|
||||
request.fields.addAll({"description": description});
|
||||
final response = await http.Response.fromStream(await request.send());
|
||||
if (response.statusCode != 200 && response.statusCode != 202) {
|
||||
return MapEntry(response.statusCode, jsonDecode(response.body)["error"]);
|
||||
}
|
||||
return MapEntry(response.statusCode, jsonDecode(response.body)["id"]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
Future<List<AccountModel>> _getFollowRequest(String identityName) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
final headers = {...identity.getAuthHeaders(), ...global.defaultHeaders};
|
||||
final Uri uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/follow_requests",
|
||||
);
|
||||
final result = await http.get(uri, headers: headers);
|
||||
if (result.statusCode != 200) return [];
|
||||
|
||||
List<AccountModel> models = [];
|
||||
for (var m in jsonDecode(result.body)) {
|
||||
models.add(AccountModel.fromJson(m, identityName));
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
Future<List<AccountModel>> getFollowRequests() async {
|
||||
List<Future<List<AccountModel>>> pending = [];
|
||||
global.settings!.identities.forEach((key, value) {
|
||||
pending.add(_getFollowRequest(key));
|
||||
});
|
||||
|
||||
List<AccountModel> finished = [];
|
||||
for (var m in pending) {
|
||||
finished.addAll(await m);
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
|
||||
// accept follow request or deny
|
||||
// request is accepted unless deny is true
|
||||
Future<RelationshipModel?> handleFollowRequest(AccountModel account,
|
||||
{deny = false}) async {
|
||||
final identity = global.settings!.identities[account.identity]!;
|
||||
final headers = {...identity.getAuthHeaders(), ...global.defaultHeaders};
|
||||
final Uri uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path:
|
||||
"/api/v1/follow_requests/${account.id}/${deny ? "reject" : "authorize"}",
|
||||
);
|
||||
|
||||
final result = await http.post(uri, headers: headers);
|
||||
if (result.statusCode != 200) {
|
||||
return null;
|
||||
}
|
||||
return RelationshipModel.fromJson(jsonDecode(result.body), account.identity);
|
||||
}
|
|
@ -29,11 +29,13 @@ class InstanceConfiguration {
|
|||
|
||||
class StatusConfiguration {
|
||||
final int maxChars;
|
||||
final int maxMediaAttachments;
|
||||
|
||||
StatusConfiguration(this.maxChars);
|
||||
StatusConfiguration(this.maxChars, this.maxMediaAttachments);
|
||||
static StatusConfiguration fromJson(Map<String, dynamic> json) {
|
||||
return StatusConfiguration(
|
||||
json["max_characters"],
|
||||
json["max_media_attachments"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,3 +103,21 @@ Future<int> makeFullInteraction(
|
|||
}
|
||||
return await makeInteractionFromUrl(id, posturl, type);
|
||||
}
|
||||
|
||||
Future<int> deletePost(PostModel model) async {
|
||||
final identity = global.settings!.identities[model.identity]!;
|
||||
final headers = {
|
||||
...identity.getAuthHeaders(),
|
||||
...global.defaultHeaders,
|
||||
};
|
||||
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/statuses/${model.id}",
|
||||
);
|
||||
|
||||
final response = await http.delete(uri, headers: headers);
|
||||
|
||||
return response.statusCode;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ class NotificationModel implements Comparable {
|
|||
post = null;
|
||||
time = json["created_at"];
|
||||
id = json["id"];
|
||||
account = AccountModel.fromJson(json["account"]);
|
||||
type = NotificationType.values.firstWhere(
|
||||
(element) => element.name == "NotificationType.${json["type"]}");
|
||||
account = AccountModel.fromJson(json["account"], identity);
|
||||
type = NotificationType.values
|
||||
.firstWhere((element) => element.param == json["type"]);
|
||||
if (json["status"] != null) {
|
||||
post = PostModel.fromJson(json["status"], identity);
|
||||
}
|
||||
|
@ -122,6 +122,25 @@ extension NotificationTypeExtension on NotificationType {
|
|||
}
|
||||
}
|
||||
|
||||
String get param {
|
||||
switch (this) {
|
||||
case NotificationType.favourite:
|
||||
return "favourite";
|
||||
case NotificationType.followRequest:
|
||||
return "follow_request";
|
||||
case NotificationType.mention:
|
||||
return "mention";
|
||||
case NotificationType.reblog:
|
||||
return "reblog";
|
||||
case NotificationType.poll:
|
||||
return "poll";
|
||||
case NotificationType.status:
|
||||
return "status";
|
||||
case NotificationType.follow:
|
||||
return "follow";
|
||||
}
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
case NotificationType.follow:
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class MentionModel {
|
||||
final String id;
|
||||
final String username;
|
||||
final String url;
|
||||
final String acct;
|
||||
|
||||
MentionModel(this.id, this.username, this.url, this.acct);
|
||||
|
||||
static MentionModel fromJson(Map<String, dynamic> json) {
|
||||
return MentionModel(
|
||||
json["id"]!, json["username"]!, json["url"]!, json["acct"]!);
|
||||
}
|
||||
}
|
|
@ -7,21 +7,23 @@ import 'package:loris/global.dart' as global;
|
|||
class MakePostModel {
|
||||
final String identity;
|
||||
final String status;
|
||||
final String? spoilerText;
|
||||
final String spoilerText;
|
||||
final Visibility visibility;
|
||||
final String? scheduledAt;
|
||||
final String? inReplyToId;
|
||||
List<String> mediaIds;
|
||||
|
||||
MakePostModel({
|
||||
required this.identity,
|
||||
required this.status,
|
||||
this.spoilerText,
|
||||
required this.spoilerText,
|
||||
required this.visibility,
|
||||
required this.mediaIds,
|
||||
this.scheduledAt,
|
||||
this.inReplyToId,
|
||||
});
|
||||
|
||||
Future<int> sendPost() async {
|
||||
Future<http.Response> sendPost() async {
|
||||
final headers = global.settings!.identities[identity]!.getAuthHeaders();
|
||||
headers.addAll(global.defaultHeaders);
|
||||
|
||||
|
@ -29,6 +31,7 @@ class MakePostModel {
|
|||
"status": status,
|
||||
"sensitive": false,
|
||||
"visibility": visibility.queryParam,
|
||||
"media_ids": mediaIds,
|
||||
};
|
||||
|
||||
if (inReplyToId != null) {
|
||||
|
@ -37,13 +40,11 @@ class MakePostModel {
|
|||
});
|
||||
}
|
||||
|
||||
if (spoilerText != null) {
|
||||
if (spoilerText!.isNotEmpty) {
|
||||
params.addAll({
|
||||
"spoiler_text": spoilerText!,
|
||||
"sensitive": true,
|
||||
});
|
||||
}
|
||||
if (spoilerText.isNotEmpty) {
|
||||
params.addAll({
|
||||
"spoiler_text": spoilerText,
|
||||
"sensitive": true,
|
||||
});
|
||||
}
|
||||
|
||||
final url = Uri(
|
||||
|
@ -57,6 +58,6 @@ class MakePostModel {
|
|||
headers: headers,
|
||||
body: jsonEncode(params),
|
||||
);
|
||||
return response.statusCode;
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class PostContext {
|
||||
final List<PostModel> ancestors;
|
||||
final List<PostModel> descendants;
|
||||
|
||||
PostContext({required this.ancestors, required this.descendants});
|
||||
}
|
||||
|
||||
// first returns ancestors, then decendants
|
||||
Future<MapEntry<int, PostContext?>> getContextForPost(PostModel model) async {
|
||||
final identity = global.settings!.identities[model.identity]!;
|
||||
var headers = identity.getAuthHeaders();
|
||||
headers.addAll(global.defaultHeaders);
|
||||
String id = model.reblogId ?? model.id;
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v1/statuses/$id/context");
|
||||
|
||||
final r = await http.get(uri, headers: headers);
|
||||
if (r.statusCode != 200) {
|
||||
return MapEntry(r.statusCode, null);
|
||||
}
|
||||
|
||||
final json = jsonDecode(r.body);
|
||||
List<dynamic> ancestors = json["ancestors"]!;
|
||||
List<dynamic> descendants = json["descendants"]!;
|
||||
|
||||
return MapEntry(
|
||||
r.statusCode,
|
||||
PostContext(
|
||||
ancestors: ancestors
|
||||
.map((e) => PostModel.fromJson(e, model.identity))
|
||||
.toList(),
|
||||
descendants: descendants
|
||||
.map((e) => PostModel.fromJson(e, model.identity))
|
||||
.toList(),
|
||||
));
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class SearchResult {
|
||||
final String identitiy;
|
||||
final List<AccountModel> accountModels;
|
||||
final List<PostModel> postModels;
|
||||
final String query;
|
||||
|
||||
SearchResult(
|
||||
this.identitiy,
|
||||
this.query, {
|
||||
this.postModels = const [],
|
||||
this.accountModels = const [],
|
||||
});
|
||||
}
|
||||
|
||||
Future<MapEntry<int, SearchResult?>> searchForEntry(
|
||||
String q, String identityName) async {
|
||||
final identity = global.settings!.identities[identityName]!;
|
||||
final headers = {
|
||||
...identity.getAuthHeaders(),
|
||||
...global.defaultHeaders,
|
||||
};
|
||||
|
||||
final uri = Uri(
|
||||
scheme: "https",
|
||||
host: identity.instanceUrl,
|
||||
path: "/api/v2/search",
|
||||
queryParameters: {"q": q},
|
||||
);
|
||||
|
||||
var response = await http.get(uri, headers: headers);
|
||||
if (response.statusCode != 200) {
|
||||
response = await http.get(
|
||||
Uri(
|
||||
scheme: uri.scheme,
|
||||
host: uri.host,
|
||||
path: "/api/v1/search",
|
||||
queryParameters: uri.queryParameters,
|
||||
),
|
||||
headers: headers);
|
||||
}
|
||||
if (response.statusCode != 200) {
|
||||
return MapEntry(response.statusCode, null);
|
||||
}
|
||||
|
||||
final json = jsonDecode(response.body);
|
||||
|
||||
List<AccountModel> accounts = [];
|
||||
for (var account in json["accounts"]) {
|
||||
accounts.add(AccountModel.fromJson(
|
||||
account,
|
||||
identityName,
|
||||
));
|
||||
}
|
||||
|
||||
List<PostModel> posts = [];
|
||||
for (var post in json["statuses"]) {
|
||||
posts.add(PostModel.fromJson(post, identityName));
|
||||
}
|
||||
|
||||
return MapEntry(
|
||||
200,
|
||||
SearchResult(
|
||||
identityName,
|
||||
q,
|
||||
postModels: posts,
|
||||
accountModels: accounts,
|
||||
),
|
||||
);
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:flutter/painting.dart';
|
||||
import 'package:loris/themes/themes.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../business_logic/auth/oauth.dart' as oauth;
|
||||
import './websocket.dart' as websocket;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class AccountSettings {
|
||||
final String identity;
|
||||
|
@ -70,11 +71,11 @@ class AccountSettings {
|
|||
return await prefs.setString("$identity.$authCodeKey", code);
|
||||
}
|
||||
|
||||
Future<void> saveApp(oauth.App app) async {
|
||||
clientId = app.clientId;
|
||||
clientSecret = app.clientSecret;
|
||||
await prefs.setString("$identity.$clientSecretKey", app.clientSecret);
|
||||
await prefs.setString("$identity.$clientIdKey", app.clientId);
|
||||
Future<void> saveApp(String clientSecret, String clientId) async {
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
await prefs.setString("$identity.$clientSecretKey", clientSecret);
|
||||
await prefs.setString("$identity.$clientIdKey", clientId);
|
||||
}
|
||||
|
||||
Future<bool> saveToken(String token) async {
|
||||
|
@ -97,6 +98,8 @@ class Settings {
|
|||
late String activeIdentity = "";
|
||||
static const activeIdentityKey = "active-identity";
|
||||
late SharedPreferences prefs;
|
||||
static const themeKey = "theme";
|
||||
late CustomColors theme;
|
||||
|
||||
Settings._create();
|
||||
|
||||
|
@ -124,12 +127,25 @@ class Settings {
|
|||
settings.activeIdentity = settings.identities.keys.first;
|
||||
}
|
||||
|
||||
settings.postWidth = settings.prefs.getDouble(postWidthKey) ?? 0.8;
|
||||
settings.postWidth = settings.prefs.getDouble(postWidthKey) ?? 1.0;
|
||||
settings.maxPostWidth = settings.prefs.getDouble(maxPostWidthKey) ?? 1000;
|
||||
|
||||
final themename = settings.prefs.getString(themeKey);
|
||||
settings.theme = themes.available.firstWhere(
|
||||
(element) => element.name == themename,
|
||||
orElse: () => themes.available[0],
|
||||
);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
Future<bool> saveTheme(String name) async {
|
||||
theme = themes.available.firstWhere(
|
||||
(element) => element.name == name,
|
||||
);
|
||||
return prefs.setString(themeKey, name);
|
||||
}
|
||||
|
||||
Future<bool> saveMaxPostWidth(double width) {
|
||||
maxPostWidth = width;
|
||||
return prefs.setDouble(maxPostWidthKey, width);
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||
import 'package:loris/business_logic/posting/mentions.dart';
|
||||
import 'package:loris/business_logic/timeline/media.dart';
|
||||
import '../../global.dart' as global;
|
||||
|
||||
|
@ -82,9 +84,13 @@ class PostModel implements Comparable {
|
|||
late bool reblogged;
|
||||
late AccountModel account;
|
||||
late AccountModel? rebloggedBy;
|
||||
late PostModel? reblog;
|
||||
late String? inReplyTo;
|
||||
late List<MediaAttachmentModel> attachments;
|
||||
late List<MentionModel> mentions = [];
|
||||
// exists if post is a reblog
|
||||
late String originalId;
|
||||
late List<Emoji> emojis = [];
|
||||
|
||||
PostModel.fromJson(Map<String, dynamic> json, this.identity) {
|
||||
id = json["id"] as String;
|
||||
|
@ -92,11 +98,13 @@ class PostModel implements Comparable {
|
|||
createdAt = json["created_at"];
|
||||
// in case of reblog
|
||||
if (json["reblog"] != null) {
|
||||
rebloggedBy = AccountModel.fromJson(json["account"]);
|
||||
rebloggedBy = AccountModel.fromJson(json["account"], identity);
|
||||
json = json["reblog"];
|
||||
reblogId = json["id"];
|
||||
reblog = PostModel.fromJson(json, identity);
|
||||
} else {
|
||||
rebloggedBy = null;
|
||||
reblog = null;
|
||||
}
|
||||
originalId = json["id"];
|
||||
uri = json["uri"] as String;
|
||||
|
@ -108,12 +116,27 @@ class PostModel implements Comparable {
|
|||
spoilerText = json["spoiler_text"] as String;
|
||||
favourited = json["favourited"] as bool;
|
||||
reblogged = json["reblogged"] as bool;
|
||||
account = AccountModel.fromJson(json["account"]);
|
||||
inReplyTo = json["in_reply_to_id"];
|
||||
account = AccountModel.fromJson(json["account"], identity);
|
||||
attachments = [];
|
||||
List<dynamic> jsonAttachmentList = json["media_attachments"];
|
||||
for (int i = 0; i < jsonAttachmentList.length; i++) {
|
||||
attachments.add(MediaAttachmentModel.fromJson(jsonAttachmentList[i]));
|
||||
}
|
||||
List<dynamic> jsonMentionList = json["mentions"];
|
||||
for (var element in jsonMentionList) {
|
||||
mentions.add(MentionModel.fromJson(element));
|
||||
}
|
||||
List<dynamic>? jsonEmojiList = json["emojis"];
|
||||
if (jsonEmojiList != null) {}
|
||||
for (var element in jsonEmojiList!) {
|
||||
emojis.add(Emoji.fromJson(element));
|
||||
}
|
||||
}
|
||||
|
||||
// get instance of account that received this post
|
||||
String getReceiverInstance() {
|
||||
return identity.substring(identity.indexOf("@"));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:loris/business_logic/settings.dart';
|
||||
import 'package:web_socket_channel/io.dart';
|
||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
import '../global.dart' as global;
|
||||
|
||||
IOWebSocketChannel? channel;
|
||||
bool connected = false;
|
||||
|
||||
Map<String, Map<String, StreamController>> map = {};
|
||||
|
@ -57,7 +55,7 @@ StreamController getStreamController(AccountSettings id, StreamType type) {
|
|||
final uri =
|
||||
Uri(scheme: scheme, host: host, path: path, queryParameters: query);
|
||||
final controller = StreamController.broadcast();
|
||||
final socket = IOWebSocketChannel.connect(uri);
|
||||
final socket = WebSocketChannel.connect(uri);
|
||||
controller.addStream(socket.stream);
|
||||
return controller;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/chat/chat.dart';
|
||||
import 'package:loris/dialogues/full_post_view.dart';
|
||||
import 'package:loris/dialogues/profile_view.dart';
|
||||
import 'package:loris/partials/loadingbox.dart';
|
||||
import 'package:loris/partials/post.dart';
|
||||
import 'package:loris/partials/post_text_renderer.dart';
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
import 'package:loris/global.dart' as global;
|
||||
|
||||
class Chat extends StatefulWidget {
|
||||
const Chat({super.key});
|
||||
|
||||
@override
|
||||
State<Chat> createState() => _ChatState();
|
||||
}
|
||||
|
||||
class _ChatState extends State<Chat> {
|
||||
List<ConversationModel> conversations = [];
|
||||
// map that stores max ids for each identity
|
||||
Map<String, String?> maxIds = {};
|
||||
final scrollController = ScrollController();
|
||||
bool loading = false;
|
||||
|
||||
// loads more conversations and properly stores all ids
|
||||
Future<void> updateConversations() async {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
final models = await getAllConversationModels(maxIds);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
conversations.addAll(models.models);
|
||||
maxIds = models.maxIds;
|
||||
});
|
||||
loading = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
updateConversations();
|
||||
scrollController.addListener(() {
|
||||
if (scrollController.position.maxScrollExtent - scrollController.offset <
|
||||
MediaQuery.of(context).size.height) {
|
||||
updateConversations();
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleDialog(
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
children: [
|
||||
Container(
|
||||
constraints: global.getConstraints(context),
|
||||
width: global.getWidth(context),
|
||||
height: MediaQuery.of(context).size.height * 2 / 3,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
controller: scrollController,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: ((context, index) {
|
||||
if (index >= conversations.length) {
|
||||
return const LoadingBox();
|
||||
}
|
||||
return ConversationButton(
|
||||
model: conversations[index],
|
||||
onTap: () {
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final con = conversations[index];
|
||||
if (con.lastStatus != null) {
|
||||
return FullPostView(
|
||||
originPostModel: con.lastStatus!);
|
||||
}
|
||||
return ProfileView(model: con.accounts.first);
|
||||
});
|
||||
},
|
||||
);
|
||||
}),
|
||||
separatorBuilder: (context, index) => const Divider(
|
||||
height: themes.defaultSeperatorHeight,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
itemCount: conversations.length + 1),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2))),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ConversationButton extends StatelessWidget {
|
||||
const ConversationButton({
|
||||
super.key,
|
||||
required this.model,
|
||||
required this.onTap,
|
||||
});
|
||||
final ConversationModel model;
|
||||
final void Function() onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> people = [];
|
||||
for (var p in model.accounts) {
|
||||
people.add(DisplayName(account: p));
|
||||
}
|
||||
return Align(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
margin: const EdgeInsets.fromLTRB(themes.defaultSeperatorHeight * 2, 0,
|
||||
themes.defaultSeperatorHeight * 2, 0),
|
||||
width: global.getWidth(context),
|
||||
constraints: global.getConstraints(context),
|
||||
child: Material(
|
||||
borderOnForeground: true,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).colorScheme.secondary, width: 2),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: themes.defaultInsideMargins,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: people +
|
||||
[
|
||||
Divider(
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
onPressed: onTap,
|
||||
icon: const Icon(Icons.open_in_full),
|
||||
label: Text("show".i18n())),
|
||||
if (model.unread) const UnreadIndicator(),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
children: [
|
||||
SelectableText(model.getAccountsString()),
|
||||
SelectableText(
|
||||
"${"you-are".i18n()} ${model.identity}"),
|
||||
],
|
||||
),
|
||||
if (model.lastStatus != null)
|
||||
PostTextRenderer(
|
||||
input: model.lastStatus!.content,
|
||||
identityName: model.identity,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UnreadIndicator extends StatefulWidget {
|
||||
const UnreadIndicator({super.key});
|
||||
|
||||
@override
|
||||
State<UnreadIndicator> createState() => _UnreadIndicatorState();
|
||||
}
|
||||
|
||||
class _UnreadIndicatorState extends State<UnreadIndicator> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(Icons.mark_unread_chat_alt),
|
||||
SelectableText("unread".i18n())
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/follow_request/followrequest.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:loris/partials/post.dart';
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class FollowReqScreen extends StatefulWidget {
|
||||
const FollowReqScreen({super.key});
|
||||
|
||||
@override
|
||||
State<FollowReqScreen> createState() => _FollowReqScreenState();
|
||||
}
|
||||
|
||||
class _FollowReqScreenState extends State<FollowReqScreen> {
|
||||
List<AccountModel> requests = [];
|
||||
bool loading = true;
|
||||
|
||||
Future<void> fetchRequests() async {
|
||||
final results = await getFollowRequests();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
requests = results;
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
fetchRequests();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void handleFailure(RelationshipModel? model) {}
|
||||
|
||||
void updateList(AccountModel model) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
requests.remove(model);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BackdropFilter(
|
||||
filter:
|
||||
ImageFilter.blur(sigmaX: 10, sigmaY: 10, tileMode: TileMode.mirror),
|
||||
child: SimpleDialog(
|
||||
titlePadding: EdgeInsets.fromLTRB(0, themes.defaultRadius.x, 0, 0),
|
||||
title: loading ? const LinearProgressIndicator() : null,
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
children: [
|
||||
Container(
|
||||
width: global.getWidth(context),
|
||||
height: MediaQuery.of(context).size.height * 2 / 3,
|
||||
constraints: global.getConstraints(context),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
final account = requests[index];
|
||||
return FollowRequestDisplay(
|
||||
account: account,
|
||||
accept: () async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
final result = await handleFollowRequest(account);
|
||||
handleFailure(result);
|
||||
if (result != null) {
|
||||
updateList(account);
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
deny: (() async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
final result =
|
||||
await handleFollowRequest(account, deny: true);
|
||||
handleFailure(result);
|
||||
if (result != null) {
|
||||
updateList(account);
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
Divider(color: Theme.of(context).hintColor),
|
||||
itemCount: requests.length),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FollowRequestDisplay extends StatelessWidget {
|
||||
const FollowRequestDisplay(
|
||||
{super.key,
|
||||
required this.deny,
|
||||
required this.accept,
|
||||
required this.account});
|
||||
final void Function()? deny;
|
||||
final void Function()? accept;
|
||||
final AccountModel account;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
DisplayName(account: account),
|
||||
SelectableText("${"requested-to-follow".i18n()} ${account.identity}"),
|
||||
Wrap(alignment: WrapAlignment.spaceBetween, children: [
|
||||
TextButton.icon(
|
||||
onPressed: deny,
|
||||
icon: const Icon(Icons.do_not_disturb_alt_outlined),
|
||||
label: Text("deny".i18n())),
|
||||
TextButton.icon(
|
||||
onPressed: accept,
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text("accept".i18n()))
|
||||
]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/network_tools/get_post_from_url.dart';
|
||||
import 'package:loris/business_logic/posts/posts.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
import '../partials/post.dart';
|
||||
|
||||
class FullPostView extends StatefulWidget {
|
||||
const FullPostView({
|
||||
super.key,
|
||||
required this.originPostModel,
|
||||
this.identities,
|
||||
this.hidden = true,
|
||||
this.ancestors,
|
||||
this.descendants,
|
||||
this.forceSensitive = false,
|
||||
});
|
||||
final PostModel originPostModel;
|
||||
final Map<String, PostModel>? identities;
|
||||
final bool hidden;
|
||||
final List<PostModel>? ancestors;
|
||||
final List<PostModel>? descendants;
|
||||
final bool forceSensitive;
|
||||
|
||||
@override
|
||||
State<FullPostView> createState() => _FullPostViewState();
|
||||
}
|
||||
|
||||
class _FullPostViewState extends State<FullPostView> {
|
||||
List<PostModel> ancestors = [];
|
||||
List<PostModel> descendants = [];
|
||||
Map<String, PostModel> identities = {};
|
||||
String activeIdentity = "";
|
||||
int idsChecked = 1;
|
||||
bool sensitive = false;
|
||||
|
||||
void loadIdentities() async {
|
||||
global.settings!.identities.forEach((key, value) async {
|
||||
if (!identities.containsKey(key)) {
|
||||
final r = await getPostFromUrl(key, widget.originPostModel.uri);
|
||||
if (r.values.first != null && mounted) {
|
||||
setState(() {
|
||||
identities.addAll({key: r.values.first!});
|
||||
});
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
idsChecked++;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void loadPosts() async {
|
||||
if (widget.ancestors == null || widget.descendants == null) {
|
||||
final r = await getContextForPost(widget.originPostModel);
|
||||
if (r.value != null && mounted) {
|
||||
setState(() {
|
||||
ancestors = r.value!.ancestors;
|
||||
descendants = r.value!.descendants;
|
||||
});
|
||||
}
|
||||
for (var a in ancestors) {
|
||||
if (a.sensitive) {
|
||||
sensitive = true;
|
||||
}
|
||||
}
|
||||
for (var d in descendants) {
|
||||
if (d.sensitive) {
|
||||
sensitive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.ancestors != null) {
|
||||
ancestors = widget.ancestors!;
|
||||
}
|
||||
if (widget.descendants != null) {
|
||||
descendants = widget.descendants!;
|
||||
}
|
||||
|
||||
sensitive = widget.originPostModel.sensitive;
|
||||
if (widget.identities != null) {
|
||||
idsChecked = global.settings!.identities.length;
|
||||
}
|
||||
identities = widget.identities ?? {};
|
||||
identities.addAll({
|
||||
widget.originPostModel.identity: widget.originPostModel,
|
||||
});
|
||||
activeIdentity = widget.originPostModel.identity;
|
||||
loadPosts();
|
||||
loadIdentities();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<DropdownMenuItem<String>> dropdownButtons = [];
|
||||
identities.forEach((key, value) {
|
||||
dropdownButtons.add(
|
||||
DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: key,
|
||||
child: Text(key, style: Theme.of(context).textTheme.bodyMedium),
|
||||
),
|
||||
);
|
||||
});
|
||||
return BackdropFilter(
|
||||
filter:
|
||||
ImageFilter.blur(sigmaX: 10, sigmaY: 10, tileMode: TileMode.mirror),
|
||||
child: SimpleDialog(
|
||||
contentPadding: const EdgeInsets.fromLTRB(0, 24, 0, 0),
|
||||
children: [
|
||||
global.settings!.identities.length > idsChecked
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SelectableText(
|
||||
"${"post-found-on".i18n()} $idsChecked ${idsChecked == 1 ? "instance".i18n() : "instances".i18n()}",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const LinearProgressIndicator(),
|
||||
],
|
||||
)
|
||||
: Padding(
|
||||
padding: themes.defaultInsideMargins,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceAround,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
alignment: Alignment.center,
|
||||
value: activeIdentity,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
iconEnabledColor:
|
||||
Theme.of(context).colorScheme.onSurface,
|
||||
items: dropdownButtons,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
Navigator.of(context).pop();
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => FullPostView(
|
||||
originPostModel: identities[value]!,
|
||||
identities: identities,
|
||||
),
|
||||
);
|
||||
});
|
||||
loadPosts();
|
||||
},
|
||||
),
|
||||
),
|
||||
if (sensitive || widget.forceSensitive)
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
Navigator.of(context).pop();
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => FullPostView(
|
||||
originPostModel: widget.originPostModel,
|
||||
hidden: !widget.hidden,
|
||||
identities: identities,
|
||||
ancestors: ancestors,
|
||||
descendants: descendants,
|
||||
forceSensitive: true,
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
icon: Icon(widget.hidden
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
label: Text(
|
||||
widget.hidden ? "show".i18n() : "hide".i18n(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 2 / 3,
|
||||
maxWidth: global.getConstraints(context).maxWidth),
|
||||
width: global.getWidth(context),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: themes.defaultMargins,
|
||||
child: SingleFullPostDisplay(
|
||||
ancestors: ancestors,
|
||||
descendants: descendants,
|
||||
hidden: widget.hidden,
|
||||
level: 0,
|
||||
model: identities[activeIdentity]!.reblog ??
|
||||
identities[activeIdentity]!,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SingleFullPostDisplay extends StatelessWidget {
|
||||
const SingleFullPostDisplay({
|
||||
super.key,
|
||||
required this.level,
|
||||
required this.model,
|
||||
required this.ancestors,
|
||||
required this.descendants,
|
||||
this.hidden = true,
|
||||
});
|
||||
final int level;
|
||||
final PostModel model;
|
||||
final List<PostModel> ancestors;
|
||||
final List<PostModel> descendants;
|
||||
final bool hidden;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Post> ancestorWidgets = ancestors
|
||||
.map(
|
||||
(e) => Post(model: e, hideSensitive: hidden),
|
||||
)
|
||||
.toList();
|
||||
|
||||
List<Widget> descendantsWidgets = [];
|
||||
|
||||
// seems most efficient
|
||||
// considering that lists aren't v long
|
||||
for (var element in descendants) {
|
||||
if (element.inReplyTo == model.id) {
|
||||
descendantsWidgets.add(SingleFullPostDisplay(
|
||||
level: level + 1,
|
||||
model: element,
|
||||
ancestors: const [],
|
||||
descendants: descendants,
|
||||
hidden: hidden,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
List<Widget> c = [];
|
||||
c.addAll(ancestorWidgets);
|
||||
c.add(Post(
|
||||
model: model,
|
||||
hideSensitive: hidden,
|
||||
));
|
||||
c.addAll(descendantsWidgets);
|
||||
return Container(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
level == 0 ? 0 : 4,
|
||||
themes.defaultSeperatorHeight,
|
||||
level == 0 ? 0 : 4,
|
||||
themes.defaultSeperatorHeight),
|
||||
decoration: BoxDecoration(
|
||||
border: level == 0
|
||||
? const Border()
|
||||
: Border(
|
||||
left: BorderSide(
|
||||
width: 4,
|
||||
color: level.isEven
|
||||
? Theme.of(context).colorScheme.secondary
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(children: c));
|
||||
}
|
||||
}
|
|
@ -1,11 +1,19 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/fileupload/fileupload.dart';
|
||||
import 'package:loris/business_logic/instance/instance.dart';
|
||||
import 'package:loris/business_logic/network_tools/get_post_from_url.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart' as tl;
|
||||
import '../business_logic/posting/posting.dart';
|
||||
import '../partials/post.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
import 'package:universal_io/io.dart' as io;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class MakePost extends StatefulWidget {
|
||||
const MakePost({Key? key, this.inReplyTo}) : super(key: key);
|
||||
|
@ -16,27 +24,61 @@ class MakePost extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MakePostState extends State<MakePost> {
|
||||
String replyAts = "";
|
||||
String accountid = global.settings!.activeIdentity;
|
||||
int? maxLength;
|
||||
InstanceInformation? instanceInfo;
|
||||
String text = "";
|
||||
String spoilerText = "";
|
||||
String? status;
|
||||
bool sending = false;
|
||||
// tracks fileuploads and their ids on servers
|
||||
// if the id is null the file has not been uploaded yet
|
||||
List<FileUpload> files = [];
|
||||
// stores all identities and if available the post id you are replying to
|
||||
Map<String, String?> identitiesAvailable = {};
|
||||
tl.Visibility visibility = tl.Visibility.public;
|
||||
|
||||
void switchAccount(String acct) {
|
||||
setState(() {
|
||||
maxLength = null;
|
||||
instanceInfo = null;
|
||||
accountid = acct;
|
||||
});
|
||||
updateMaxChars();
|
||||
}
|
||||
|
||||
// check if there are more attachments than the instance ur posting to allowss
|
||||
bool tooManyAttachments() {
|
||||
if (instanceInfo == null) {
|
||||
return true;
|
||||
}
|
||||
if (instanceInfo!.configuration.statusconfig.maxMediaAttachments <
|
||||
files.length) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// moves file in list up or down,
|
||||
// has to be called with file from items list
|
||||
void moveFile(FileUpload file, {up = true}) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
final index = files.indexOf(file);
|
||||
final newIndex = (index + (up ? -1 : 1)) % files.length;
|
||||
|
||||
files.remove(file);
|
||||
setState(() {
|
||||
files.insert(newIndex, file);
|
||||
});
|
||||
}
|
||||
|
||||
void updateMaxChars() async {
|
||||
final info = await instanceInformationForIdentity(accountid);
|
||||
if (info.keys.first == 200) {
|
||||
if (info.keys.first == 200 && mounted) {
|
||||
setState(() {
|
||||
maxLength = info.values.first!.configuration.statusconfig.maxChars;
|
||||
instanceInfo = info.values.first!;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -45,18 +87,36 @@ class _MakePostState extends State<MakePost> {
|
|||
if (widget.inReplyTo != null) {
|
||||
global.settings!.identities.forEach((key, value) async {
|
||||
final post = await getPostFromUrl(key, widget.inReplyTo!.uri);
|
||||
if (post.keys.first == 200) {
|
||||
setState(() {
|
||||
identitiesAvailable.addAll({key: post.values.first!.id});
|
||||
});
|
||||
if (mounted) {
|
||||
if (post.keys.first == 200) {
|
||||
setState(() {
|
||||
identitiesAvailable.addAll({key: post.values.first!.id});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void addAt(String at) {
|
||||
if (!at.contains("@")) {
|
||||
at = "$at${widget.inReplyTo!.getReceiverInstance()}";
|
||||
}
|
||||
if (global.settings!.identities.keys.contains(at)) {
|
||||
return;
|
||||
}
|
||||
replyAts = "$replyAts@$at ";
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.inReplyTo != null) {
|
||||
visibility = widget.inReplyTo!.visibility;
|
||||
addAt(widget.inReplyTo!.account.acct);
|
||||
for (var element in widget.inReplyTo!.mentions) {
|
||||
addAt(element.acct);
|
||||
}
|
||||
|
||||
accountid = widget.inReplyTo!.identity;
|
||||
identitiesAvailable.addAll({
|
||||
widget.inReplyTo!.identity: widget.inReplyTo!.id,
|
||||
|
@ -71,6 +131,9 @@ class _MakePostState extends State<MakePost> {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (widget.inReplyTo != null) {
|
||||
spoilerText = widget.inReplyTo!.spoilerText;
|
||||
}
|
||||
super.initState();
|
||||
updateMaxChars();
|
||||
updateAvailableIds();
|
||||
|
@ -78,6 +141,7 @@ class _MakePostState extends State<MakePost> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// make list of all different widgets to be displayed
|
||||
List<Widget> c = [];
|
||||
if (widget.inReplyTo != null) {
|
||||
c.add(
|
||||
|
@ -93,7 +157,12 @@ class _MakePostState extends State<MakePost> {
|
|||
identitiesAvailable.forEach((key, value) {
|
||||
idDropdownItems.add(DropdownMenuItem(
|
||||
value: key,
|
||||
child: Text(key),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
key,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
));
|
||||
});
|
||||
|
||||
|
@ -105,16 +174,17 @@ class _MakePostState extends State<MakePost> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(value.icon),
|
||||
Text(value.name),
|
||||
Text(
|
||||
value.name,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
)));
|
||||
}
|
||||
List<Widget> actionButtons = [
|
||||
maxLength == null
|
||||
? const CircularProgressIndicator()
|
||||
: SelectableText((maxLength! - text.length).toString()),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton<tl.Visibility>(
|
||||
alignment: Alignment.center,
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
items: visibilityDropdowns,
|
||||
value: visibility,
|
||||
|
@ -125,8 +195,34 @@ class _MakePostState extends State<MakePost> {
|
|||
},
|
||||
),
|
||||
),
|
||||
// media attachment button
|
||||
TextButton.icon(
|
||||
onPressed: () async {
|
||||
// open filepicker
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
||||
withData: false,
|
||||
allowMultiple: true,
|
||||
);
|
||||
if (result != null) {
|
||||
// if there are any files
|
||||
// then parse them
|
||||
for (var path in result.paths) {
|
||||
if (path != null && mounted) {
|
||||
if (await io.Directory(path).exists()) break;
|
||||
final FileUpload f = await FileUpload.fromPath(path, "");
|
||||
setState(() {
|
||||
files.add(f);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.attachment),
|
||||
label: Text(
|
||||
"${"add-files".i18n()}${instanceInfo == null ? "(${"loading...".i18n()})" : " (${instanceInfo!.configuration.statusconfig.maxMediaAttachments - files.length} ${"remaining".i18n()})"}")),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
alignment: Alignment.center,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
items: idDropdownItems,
|
||||
|
@ -136,30 +232,79 @@ class _MakePostState extends State<MakePost> {
|
|||
},
|
||||
),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
ElevatedButton.icon(
|
||||
label: Text(
|
||||
"send-post".i18n(),
|
||||
),
|
||||
// send the post!!!
|
||||
onPressed: () async {
|
||||
final model = MakePostModel(
|
||||
identity: accountid,
|
||||
status: text,
|
||||
visibility: visibility,
|
||||
inReplyToId: widget.inReplyTo == null
|
||||
? null
|
||||
: identitiesAvailable[accountid]!,
|
||||
);
|
||||
model.sendPost();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onPressed: ((spoilerText.isEmpty && text.isEmpty && files.isEmpty) ||
|
||||
tooManyAttachments())
|
||||
? null
|
||||
: () async {
|
||||
setState(() {
|
||||
sending = true;
|
||||
status = "sending...".i18n();
|
||||
});
|
||||
|
||||
// upload the media attachments
|
||||
List<String> mediaIds = [];
|
||||
for (var file in files) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
status =
|
||||
"${"sending-file".i18n()} ${mediaIds.length + 1}/${files.length}";
|
||||
});
|
||||
}
|
||||
final response = await file.upload(accountid);
|
||||
if (response.key == 200 || response.key == 202) {
|
||||
mediaIds.add(response.value);
|
||||
} else if (mounted) {
|
||||
setState(() {
|
||||
status = response.value;
|
||||
sending = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// send the final post
|
||||
final model = MakePostModel(
|
||||
mediaIds: mediaIds,
|
||||
spoilerText: spoilerText.trim(),
|
||||
identity: accountid,
|
||||
status: text,
|
||||
visibility: visibility,
|
||||
inReplyToId: widget.inReplyTo == null
|
||||
? null
|
||||
: identitiesAvailable[accountid]!,
|
||||
);
|
||||
final result = await model.sendPost();
|
||||
if (mounted) {
|
||||
if (result.statusCode == 200) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
setState(() {
|
||||
sending = false;
|
||||
status =
|
||||
"${"failed-to-send".i18n()}: ${jsonDecode(result.body)["error"].toString()}";
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.send),
|
||||
),
|
||||
];
|
||||
c.addAll([
|
||||
// content warnings
|
||||
TextFormField(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
initialValue: spoilerText,
|
||||
decoration: InputDecoration(
|
||||
counterText: instanceInfo == null
|
||||
? "loading...".i18n()
|
||||
: (instanceInfo!.configuration.statusconfig.maxChars -
|
||||
text.length -
|
||||
spoilerText.length)
|
||||
.toString(),
|
||||
prefixIcon: Icon(
|
||||
Icons.warning,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
|
@ -170,9 +315,12 @@ class _MakePostState extends State<MakePost> {
|
|||
spoilerText = value;
|
||||
})),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
Container(
|
||||
constraints:
|
||||
BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.6),
|
||||
child: TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: replyAts,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
|
@ -186,6 +334,10 @@ class _MakePostState extends State<MakePost> {
|
|||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
]);
|
||||
|
||||
// these are the action buttons
|
||||
c.add(
|
||||
Wrap(
|
||||
runSpacing: 8,
|
||||
spacing: 24,
|
||||
|
@ -194,32 +346,113 @@ class _MakePostState extends State<MakePost> {
|
|||
alignment: WrapAlignment.spaceAround,
|
||||
children: actionButtons,
|
||||
),
|
||||
]);
|
||||
);
|
||||
|
||||
return SimpleDialog(
|
||||
alignment: Alignment.center,
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
title: SelectableText(
|
||||
textAlign: TextAlign.center,
|
||||
widget.inReplyTo == null ? "make-post".i18n() : "make-reply".i18n(),
|
||||
style: Theme.of(context).textTheme.displayMedium),
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Container(
|
||||
width: (MediaQuery.of(context).size.width *
|
||||
global.settings!.postWidth) -
|
||||
56,
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: global.settings!.maxPostWidth,
|
||||
minWidth: 375,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: c,
|
||||
// display media attachments
|
||||
for (var file in files) {
|
||||
c.add(Column(
|
||||
children: [
|
||||
FileUploadDisplay(file: file),
|
||||
TextField(
|
||||
onChanged: (value) => file.description = value,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
minLines: 1,
|
||||
maxLines: null,
|
||||
decoration: InputDecoration(
|
||||
hintText: "file-description".i18n(),
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
moveFile(file, up: false);
|
||||
},
|
||||
icon: const Icon(Icons.move_down),
|
||||
label: Text("move-down".i18n()),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () => setState(() {
|
||||
files.remove(file);
|
||||
}),
|
||||
icon: const Icon(Icons.delete),
|
||||
label: Text(
|
||||
"remove-attached-file".i18n(),
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
moveFile(file);
|
||||
},
|
||||
icon: const Icon(Icons.move_up),
|
||||
label: Text("move-up".i18n()),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
return BackdropFilter(
|
||||
filter:
|
||||
ImageFilter.blur(sigmaX: 10, sigmaY: 10, tileMode: TileMode.mirror),
|
||||
child: SimpleDialog(
|
||||
titlePadding: const EdgeInsets.all(0),
|
||||
alignment: Alignment.center,
|
||||
contentPadding: themes.defaultMargins,
|
||||
title: Column(
|
||||
children: [
|
||||
if (status != null) SelectableText(status!),
|
||||
if (sending) const LinearProgressIndicator(),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Container(
|
||||
width: (MediaQuery.of(context).size.width *
|
||||
global.settings!.postWidth) -
|
||||
56,
|
||||
constraints: global.getConstraints(context),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: c,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileUploadDisplay extends StatelessWidget {
|
||||
const FileUploadDisplay({super.key, required this.file});
|
||||
final FileUpload file;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Divider(
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.attachment, size: 32),
|
||||
Expanded(
|
||||
child: SelectableText(file.path,
|
||||
style: Theme.of(context).textTheme.displaySmall),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (lookupMimeType(file.path)?.startsWith("image/") ?? false)
|
||||
Image.asset(
|
||||
file.path,
|
||||
fit: BoxFit.fitWidth,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,453 @@
|
|||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/settings.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/partials/loadingbox.dart';
|
||||
import 'package:loris/partials/post.dart';
|
||||
import 'package:loris/partials/post_text_renderer.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:loris/partials/thread.dart';
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class ProfileView extends StatefulWidget {
|
||||
const ProfileView({
|
||||
super.key,
|
||||
required this.model,
|
||||
});
|
||||
final AccountModel model;
|
||||
@override
|
||||
State<ProfileView> createState() => _ProfileViewState();
|
||||
}
|
||||
|
||||
class _ProfileViewState extends State<ProfileView> {
|
||||
final StreamController<MapEntry<String, RelationshipModel>>
|
||||
_relationshipStream = StreamController();
|
||||
Map<String, AccountModel> identities = {};
|
||||
Map<String, RelationshipModel?> relationships = {};
|
||||
String activeIdentity = "";
|
||||
bool loading = true;
|
||||
List<ThreadModel> threads = [];
|
||||
String? maxid;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
bool loadingPosts = false;
|
||||
|
||||
Future<void> addRelationship(AccountModel m) async {
|
||||
final r = await getRelationship(m.identity, m.id);
|
||||
if (r.keys.first != 200) {
|
||||
return;
|
||||
} else if (mounted) {
|
||||
setState(() {
|
||||
relationships.addAll({
|
||||
m.identity: r.values.first,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addIdentity(String identityName, int i) async {
|
||||
final m = await searchModel(identityName, widget.model.url);
|
||||
if (m.values.first != null) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
identities.addAll({identityName: m.values.first!});
|
||||
});
|
||||
}
|
||||
await addRelationship(m.values.first!);
|
||||
}
|
||||
if (i >= global.settings!.identities.length - 2) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadPosts() async {
|
||||
if (!loadingPosts) {
|
||||
loadingPosts = true;
|
||||
if (threads.isNotEmpty) {
|
||||
maxid = threads.last.posts.last.id;
|
||||
}
|
||||
|
||||
final t = await getPostsForAccount(identities[activeIdentity]!, maxid);
|
||||
if (t.value == null) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
threads.addAll(t.value!);
|
||||
});
|
||||
}
|
||||
loadingPosts = false;
|
||||
}
|
||||
}
|
||||
|
||||
void reloadPosts() {
|
||||
_scrollController.animateTo(0,
|
||||
duration: const Duration(seconds: 1), curve: Curves.ease);
|
||||
setState(() {
|
||||
maxid = null;
|
||||
threads = [];
|
||||
});
|
||||
loadPosts();
|
||||
}
|
||||
|
||||
void update() async {
|
||||
int i = 0;
|
||||
await Future.forEach<MapEntry<String, AccountSettings>>(
|
||||
global.settings!.identities.entries,
|
||||
(element) async {
|
||||
if (element.key == widget.model.identity) {
|
||||
return;
|
||||
}
|
||||
await addIdentity(element.key, i);
|
||||
i++;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
_relationshipStream.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (global.settings!.identities.length == 1) {
|
||||
loading = false;
|
||||
}
|
||||
activeIdentity = widget.model.identity;
|
||||
identities.addAll({widget.model.identity: widget.model});
|
||||
addRelationship(widget.model);
|
||||
update();
|
||||
loadPosts();
|
||||
_scrollController.addListener(() {
|
||||
if (_scrollController.offset >=
|
||||
_scrollController.position.maxScrollExtent -
|
||||
MediaQuery.of(context).size.height &&
|
||||
!_scrollController.position.outOfRange) {
|
||||
loadPosts();
|
||||
}
|
||||
});
|
||||
_relationshipStream.stream.listen((event) {
|
||||
setState(() {
|
||||
relationships.addEntries([event]);
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<DropdownMenuItem<String>> dmenuItems = [];
|
||||
identities.forEach((key, value) {
|
||||
dmenuItems.add(
|
||||
DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: key,
|
||||
child: Text(
|
||||
key,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
final profileViewDisplay = Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: ProfileViewDisplay(
|
||||
accountModel: identities[activeIdentity]!,
|
||||
relationshipModel: relationships[activeIdentity],
|
||||
relationshipStream: _relationshipStream,
|
||||
),
|
||||
);
|
||||
|
||||
return BackdropFilter(
|
||||
filter:
|
||||
ImageFilter.blur(sigmaX: 10, sigmaY: 10, tileMode: TileMode.mirror),
|
||||
child: SimpleDialog(
|
||||
alignment: Alignment.center,
|
||||
title: DisplayName(
|
||||
account: identities[activeIdentity]!,
|
||||
openInBrowser: true,
|
||||
),
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
children: [
|
||||
Container(
|
||||
constraints: global.getConstraints(context),
|
||||
child: Column(children: [
|
||||
loading
|
||||
? Column(
|
||||
children: [
|
||||
SelectableText(
|
||||
"${"found-account-on".i18n()} ${identities.length} ${identities.length <= 1 ? "instance" : "instances".i18n()}"),
|
||||
const LinearProgressIndicator(),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
isExpanded: false,
|
||||
alignment: Alignment.center,
|
||||
iconEnabledColor:
|
||||
Theme.of(context).colorScheme.onSurface,
|
||||
value: activeIdentity,
|
||||
items: dmenuItems,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
activeIdentity = value.toString();
|
||||
});
|
||||
reloadPosts();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
// constraints: global.getConstraints(context),
|
||||
width: global.getWidth(context),
|
||||
height: MediaQuery.of(context).size.height * 2 / 3,
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context, index) => const Divider(
|
||||
color: Colors.transparent,
|
||||
height: themes.defaultSeperatorHeight,
|
||||
),
|
||||
controller: _scrollController,
|
||||
itemCount: threads.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return profileViewDisplay;
|
||||
} else if (index > 0 && index <= threads.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: themes.defaultSeperatorHeight * 2),
|
||||
child: Thread(
|
||||
model: threads[index - 1],
|
||||
constrained: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return const LoadingBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AccountInteractionButtons extends StatelessWidget {
|
||||
const AccountInteractionButtons({
|
||||
super.key,
|
||||
required this.account,
|
||||
required this.relationship,
|
||||
required this.stream,
|
||||
});
|
||||
final AccountModel account;
|
||||
final RelationshipModel relationship;
|
||||
final StreamController stream;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
children: [
|
||||
AccountInteractionButton(
|
||||
accountModel: account,
|
||||
relationshipModel: relationship,
|
||||
type: AccountInteractionTypes.follow,
|
||||
stream: stream,
|
||||
),
|
||||
AccountInteractionButton(
|
||||
accountModel: account,
|
||||
relationshipModel: relationship,
|
||||
type: AccountInteractionTypes.block,
|
||||
stream: stream,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatusIndicators extends StatelessWidget {
|
||||
const StatusIndicators({
|
||||
super.key,
|
||||
required this.model,
|
||||
this.relationship,
|
||||
});
|
||||
final AccountModel model;
|
||||
final RelationshipModel? relationship;
|
||||
|
||||
List<InlineSpan> getTextWithIcon(IconData icon, String t) {
|
||||
return [
|
||||
WidgetSpan(
|
||||
child: Icon(icon),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
TextSpan(
|
||||
text: t,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<InlineSpan> c = [];
|
||||
|
||||
if (relationship == null) {
|
||||
c.add(const WidgetSpan(child: LinearProgressIndicator()));
|
||||
} else {
|
||||
// follow relationship
|
||||
if (relationship!.followedBy && relationship!.following) {
|
||||
c.addAll(getTextWithIcon(Icons.group, "you-are-mufos".i18n()));
|
||||
} else if (relationship!.followedBy) {
|
||||
c.addAll(getTextWithIcon(Icons.group, "they-follow-you".i18n()));
|
||||
} else if (relationship!.following) {
|
||||
c.addAll(getTextWithIcon(Icons.group, "you-follow-them".i18n()));
|
||||
} else {
|
||||
c.addAll(getTextWithIcon(
|
||||
Icons.group, "you-do-not-follow-each-other".i18n()));
|
||||
}
|
||||
|
||||
if (relationship!.requested) {
|
||||
c.addAll(
|
||||
getTextWithIcon(Icons.group_add, "pending-follow-request".i18n()));
|
||||
}
|
||||
}
|
||||
|
||||
// account is a bot
|
||||
if (model.bot != null) {
|
||||
if (model.bot!) {
|
||||
c.addAll(getTextWithIcon(Icons.smart_toy, "user-is-bot".i18n()));
|
||||
}
|
||||
}
|
||||
|
||||
return SelectableText.rich(
|
||||
TextSpan(children: c),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileViewDisplay extends StatelessWidget {
|
||||
const ProfileViewDisplay({
|
||||
super.key,
|
||||
required this.accountModel,
|
||||
this.relationshipModel,
|
||||
required this.relationshipStream,
|
||||
});
|
||||
final AccountModel accountModel;
|
||||
final RelationshipModel? relationshipModel;
|
||||
final StreamController relationshipStream;
|
||||
static const d = SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> c = [
|
||||
if (!(accountModel.header.endsWith("/headers/original/missing.png") ||
|
||||
(accountModel.header.endsWith("default_header.png"))))
|
||||
Image.network(
|
||||
fit: BoxFit.fitWidth,
|
||||
accountModel.header,
|
||||
errorBuilder: (context, error, stackTrace) => const SizedBox.shrink(),
|
||||
),
|
||||
Padding(
|
||||
padding: themes.defaultMargins,
|
||||
child: StatusIndicators(
|
||||
model: accountModel,
|
||||
relationship: relationshipModel,
|
||||
),
|
||||
),
|
||||
d,
|
||||
Padding(
|
||||
padding: themes.defaultMargins,
|
||||
child: PostTextRenderer(
|
||||
input: accountModel.note,
|
||||
identityName: accountModel.identity,
|
||||
emoji: accountModel.emojis,
|
||||
),
|
||||
),
|
||||
if (relationshipModel != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(themes.defaultSeperatorHeight),
|
||||
child: AccountInteractionButtons(
|
||||
account: accountModel,
|
||||
relationship: relationshipModel!,
|
||||
stream: relationshipStream,
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: c,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AccountInteractionButton extends StatefulWidget {
|
||||
const AccountInteractionButton({
|
||||
super.key,
|
||||
required this.type,
|
||||
required this.relationshipModel,
|
||||
required this.accountModel,
|
||||
required this.stream,
|
||||
});
|
||||
final AccountInteractionTypes type;
|
||||
final RelationshipModel relationshipModel;
|
||||
final AccountModel accountModel;
|
||||
final StreamController stream;
|
||||
|
||||
@override
|
||||
State<AccountInteractionButton> createState() =>
|
||||
AccountInteractionButtonState();
|
||||
}
|
||||
|
||||
class AccountInteractionButtonState extends State<AccountInteractionButton> {
|
||||
bool active() {
|
||||
switch (widget.type) {
|
||||
case AccountInteractionTypes.follow:
|
||||
return widget.relationshipModel.following;
|
||||
case AccountInteractionTypes.block:
|
||||
return widget.relationshipModel.blocking;
|
||||
case AccountInteractionTypes.mute:
|
||||
return widget.relationshipModel.muting;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton.icon(
|
||||
onPressed: () async {
|
||||
final r = await performInteraction(
|
||||
widget.relationshipModel.identity,
|
||||
widget.accountModel.id,
|
||||
widget.type,
|
||||
active(),
|
||||
);
|
||||
if (r.value == null) {
|
||||
return;
|
||||
}
|
||||
widget.stream
|
||||
.add(MapEntry(widget.relationshipModel.identity, r.value!));
|
||||
},
|
||||
icon: Icon(widget.type.icon),
|
||||
label: Text(
|
||||
active() ? widget.type.revokeSlug.i18n() : widget.type.slug.i18n(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:loris/business_logic/settings.dart';
|
||||
import 'themes/themes.dart' as themes;
|
||||
|
||||
const String name = "loris";
|
||||
const String version = "v0.1 'is this thing on'";
|
||||
const String version = "v0.5 'the halloween update'";
|
||||
const String useragent = "$name/$version";
|
||||
const String website = "https://git.kittycat.homes/zoe/loris";
|
||||
|
||||
const Map<String, String> defaultHeaders = {
|
||||
"User-Agent": useragent,
|
||||
final Map<String, String> defaultHeaders = {
|
||||
if (!kIsWeb) "User-Agent": useragent,
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
|
@ -19,12 +21,23 @@ const List<String> bad = [
|
|||
"poa.st",
|
||||
"gleasonator.com",
|
||||
"shitposter.club",
|
||||
"freespeechextremist.com"
|
||||
"freespeechextremist.com",
|
||||
];
|
||||
|
||||
double getWidth(context) {
|
||||
return (MediaQuery.of(context).size.width * settings!.postWidth) -
|
||||
(themes.defaultSeperatorHeight * 2);
|
||||
}
|
||||
|
||||
BoxConstraints getConstraints(context) {
|
||||
return BoxConstraints(
|
||||
maxWidth: settings!.maxPostWidth,
|
||||
);
|
||||
}
|
||||
|
||||
const List<Locale> availableLocales = [Locale("en", "US"), Locale("de")];
|
||||
|
||||
Settings? settings;
|
||||
|
||||
const String legalese =
|
||||
"loris is licensed under the GNU Affero General Public License v3. to find out more visist www.gnu.org/licenses/agpl-3.0.html";
|
||||
"loris is licensed under the CNPLv7+ to find out more go to https://thufie.lain.haus/NPL.html";
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"media-not-supported": "media type not supported",
|
||||
"show-about-page": "show about page",
|
||||
"about": "about",
|
||||
"load-more": "load more",
|
||||
"account-settings": "account settings",
|
||||
"logout": "log out",
|
||||
"show-in-browser": "show in browser",
|
||||
|
@ -50,6 +51,47 @@
|
|||
"direct-visibility": "dm",
|
||||
"make-reply": "make reply",
|
||||
"make-post": "make post",
|
||||
"content-warning": "content warning"
|
||||
"content-warning": "content warning",
|
||||
"theme-title": "theme",
|
||||
"send-post": "computer, send post",
|
||||
"jacking-in": "jacking in...",
|
||||
"jack-in": "jack in",
|
||||
"add-account": "add account",
|
||||
"day-1": "monday",
|
||||
"day-2": "tuesday",
|
||||
"day-3": "wednesday",
|
||||
"day-4": "thursday",
|
||||
"day-5": "friday",
|
||||
"day-6": "saturday",
|
||||
"day-7": "sunday",
|
||||
"user-is-bot": "this account is a bot",
|
||||
"you-are-mufos": "you are mutuals",
|
||||
"they-follow-you": "they follow you",
|
||||
"you-follow-them": "you follow them",
|
||||
"you-do-not-follow-each-other": "you don't follow each other",
|
||||
"found-account-on": "found account on",
|
||||
"instances": "instances",
|
||||
"instance": "instace",
|
||||
"post-found-on": "found post on",
|
||||
"show-in-full": "show in full",
|
||||
"block": "banish",
|
||||
"unblock": "unbanish",
|
||||
"add-files": "add files",
|
||||
"remaining": "remaining",
|
||||
"move-down": "move down",
|
||||
"move-up": "move up",
|
||||
"remove-attached-file": "remove attachment",
|
||||
"file-description": "file description",
|
||||
"loading...": "loading",
|
||||
"failed-to-send": "failed to send!",
|
||||
"sending-file": "sending file",
|
||||
"open-media-in-browser": "open media in browser",
|
||||
"unread": "unread",
|
||||
"expand": "expand",
|
||||
"requested-to-follow": "has requested to follow:",
|
||||
"follow-requests": "follow requests",
|
||||
"post-deleted": "post deleted",
|
||||
"delete-this": "delete this",
|
||||
"deletion-failed": "deletion failed"
|
||||
}
|
||||
|
|
@ -1,17 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/pages/settings/app.dart';
|
||||
import 'package:loris/partials/main_scaffold.dart';
|
||||
import 'pages/login.dart';
|
||||
import 'pages/login/login.dart';
|
||||
import 'business_logic/settings.dart' as settings;
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'themes/themes.dart' as themes;
|
||||
import 'global.dart' as global;
|
||||
import 'package:url_strategy/url_strategy.dart';
|
||||
|
||||
ThemeData theme = themes.getTheme(themes.available[0]);
|
||||
ThemeData theme = themes.getTheme(themes.available[1]);
|
||||
Locale activeLocale = const Locale("en_US");
|
||||
|
||||
void main() async {
|
||||
setPathUrlStrategy();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
Intl.defaultLocale = "en_US";
|
||||
global.settings = await settings.Settings.create();
|
||||
activeLocale = global.settings!.locale;
|
||||
|
@ -31,11 +35,23 @@ class Loris extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _LorisState extends State<Loris> {
|
||||
var theme = global.settings!.theme;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
themeStream.stream.listen((event) {
|
||||
setState(() {
|
||||
theme = event;
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LocalJsonLocalization.delegate.directories = ['lib/i18n'];
|
||||
return MaterialApp(
|
||||
theme: theme,
|
||||
theme: themes.getTheme(theme),
|
||||
locale: activeLocale,
|
||||
supportedLocales: global.availableLocales,
|
||||
localizationsDelegates: [
|
||||
|
@ -45,10 +61,29 @@ class _LorisState extends State<Loris> {
|
|||
LocalJsonLocalization.delegate,
|
||||
],
|
||||
initialRoute: global.settings!.identities.isEmpty ? "/login" : "/",
|
||||
routes: {
|
||||
'/': (context) => const MainScaffold(),
|
||||
'/login': (context) => const Login(),
|
||||
},
|
||||
onGenerateRoute: (s) => RouterGenerator.generateRoute(s),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RouterGenerator {
|
||||
static Route<dynamic> generateRoute(RouteSettings s) {
|
||||
var routingData = s.name;
|
||||
switch (routingData) {
|
||||
case "/login":
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const Login();
|
||||
},
|
||||
settings: s,
|
||||
);
|
||||
default:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const MainScaffold();
|
||||
},
|
||||
settings: s,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
|
||||
Widget chat(context) {
|
||||
return const Center(child: Text("Chat"));
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import '../business_logic/auth/oauth.dart' as oauth;
|
||||
import 'package:loris/pages/login/weblogin.dart';
|
||||
import '../../business_logic/auth/oauth.dart' as oauth;
|
||||
|
||||
class Login extends StatefulWidget {
|
||||
const Login({Key? key}) : super(key: key);
|
||||
|
@ -67,11 +69,20 @@ class _LoginFormState extends State<LoginForm> {
|
|||
);
|
||||
} else {
|
||||
formKey.currentState?.save();
|
||||
Navigator.push(
|
||||
if (kIsWeb) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Weblogin(url: instanceUrl),
|
||||
));
|
||||
} else {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AuthPage(url: instanceUrl),
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.login),
|
|
@ -0,0 +1,103 @@
|
|||
// oauth page for web only
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:loris/business_logic/auth/oauth.dart' as oauth;
|
||||
|
||||
class Weblogin extends StatefulWidget {
|
||||
const Weblogin({Key? key, required this.url}) : super(key: key);
|
||||
final String url;
|
||||
|
||||
@override
|
||||
State<Weblogin> createState() => _WebloginState();
|
||||
}
|
||||
|
||||
class _WebloginState extends State<Weblogin> {
|
||||
bool doneLoading = false;
|
||||
void doAuth() async {
|
||||
final appresponse = await oauth.registerApp(widget.url);
|
||||
if (appresponse.statusCode != 200) {
|
||||
informAboutFailure(appresponse.statusCode);
|
||||
return;
|
||||
}
|
||||
final app = oauth.App.fromJson(jsonDecode(appresponse.body));
|
||||
|
||||
html.window.open(
|
||||
oauth.getAuthUrl(widget.url, app).toString(),
|
||||
"_blank",
|
||||
);
|
||||
|
||||
html.window.onMessage.listen((event) async {
|
||||
final uri = Uri.parse(event.data);
|
||||
if (uri.queryParameters.containsKey("code")) {
|
||||
//ignore: ivalid_null_aware_operator
|
||||
//popupWin.close();
|
||||
final token = await oauth.getToken(
|
||||
uri.queryParameters["code"]!,
|
||||
app.clientId,
|
||||
app.clientSecret,
|
||||
widget.url,
|
||||
);
|
||||
await oauth.saveIdentity(token, widget.url, app.clientId,
|
||||
app.clientSecret, uri.queryParameters["code"]!);
|
||||
setState(() {
|
||||
doneLoading = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void informAboutFailure(int i) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: Text("error: $i")));
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
doAuth();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
SelectableText(widget.url),
|
||||
doneLoading
|
||||
? TextButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushReplacementNamed("/");
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.navigate_next,
|
||||
),
|
||||
label: Text(
|
||||
"jack-in".i18n(),
|
||||
),
|
||||
)
|
||||
: const LoadingIndicator(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingIndicator extends StatelessWidget {
|
||||
const LoadingIndicator({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 24,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
SelectableText("jacking-in".i18n()),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import 'package:loris/business_logic/notifications/notifs.dart';
|
|||
import 'package:loris/pages/notifications/single_notif.dart';
|
||||
import 'package:loris/partials/loadingbox.dart';
|
||||
import '../../business_logic/websocket.dart' as websocket;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
final notifStream = StreamController<int>.broadcast();
|
||||
|
||||
|
@ -111,30 +112,41 @@ class _NotificationsState extends State<Notifications> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
reload();
|
||||
},
|
||||
icon: const Icon(Icons.refresh))
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
controller: _controller,
|
||||
addSemanticIndexes: true,
|
||||
itemBuilder: ((context, index) => notifs[index]),
|
||||
separatorBuilder: (context, index) => const SizedBox(
|
||||
height: 8,
|
||||
separatorBuilder: (context, index) => const Divider(
|
||||
height: themes.defaultSeperatorHeight,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
itemCount: notifs.length),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
width: 2,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
))),
|
||||
child: Material(
|
||||
child: Wrap(
|
||||
spacing: 24,
|
||||
alignment: WrapAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
reload();
|
||||
},
|
||||
icon: const Icon(Icons.refresh))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:loris/business_logic/notifications/notifs.dart';
|
||||
import 'package:loris/dialogues/profile_view.dart';
|
||||
import 'package:loris/partials/name.dart';
|
||||
import 'package:loris/partials/post.dart';
|
||||
import '../../global.dart' as global;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class SingleNotif extends StatelessWidget {
|
||||
const SingleNotif({
|
||||
|
@ -12,60 +15,67 @@ class SingleNotif extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Align(
|
||||
child: Container(
|
||||
width:
|
||||
(MediaQuery.of(context).size.width * global.settings!.postWidth) -
|
||||
56,
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: global.settings!.maxPostWidth,
|
||||
minWidth: 375,
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
return Align(
|
||||
child: Container(
|
||||
width: global.getWidth(context),
|
||||
constraints: global.getConstraints(context),
|
||||
padding: themes.defaultInsideMargins,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
),
|
||||
child: Material(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ProfilePic(url: model.account.avatar),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Expanded(
|
||||
flex: 20,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SelectableText(
|
||||
model.account.displayName,
|
||||
style: Theme.of(context).textTheme.displaySmall,
|
||||
),
|
||||
SelectableText.rich(
|
||||
TextSpan(
|
||||
text: "${model.account.acct} ",
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: model.type.actionName,
|
||||
style: Theme.of(context).textTheme.bodyMedium)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
InkWell(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
onTap: () => showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => ProfileView(model: model.account),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ProfilePic(url: model.account.avatar),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
model.type.icon,
|
||||
size: 64,
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
flex: 20,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
NameDisplay(
|
||||
emoji: model.account.emojis,
|
||||
content: model.account.displayName,
|
||||
style: Theme.of(context).textTheme.displaySmall!,
|
||||
),
|
||||
SelectableText.rich(
|
||||
TextSpan(
|
||||
text: "${model.account.acct} ",
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: model.type.actionName,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
model.type.icon,
|
||||
size: 64,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:loris/business_logic/search/search.dart' as logic;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
import '../../partials/post.dart';
|
||||
|
||||
class SearchPage extends StatefulWidget {
|
||||
const SearchPage({super.key});
|
||||
|
||||
@override
|
||||
State<SearchPage> createState() => _SearchPageState();
|
||||
}
|
||||
|
||||
class _SearchPageState extends State<SearchPage> {
|
||||
String searchText = "";
|
||||
String searchTextControl = "";
|
||||
Map<String, logic.SearchResult> results = {};
|
||||
int searched = 0;
|
||||
|
||||
void searchSingle(String id) async {
|
||||
final result = await logic.searchForEntry(searchText, id);
|
||||
if (result.key == 200 && mounted) {
|
||||
setState(() {
|
||||
results.addAll({id: result.value!});
|
||||
searched++;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void search() {
|
||||
searched = 0;
|
||||
searchTextControl = searchText;
|
||||
for (var id in global.settings!.identities.keys.toList()) {
|
||||
searchSingle(id);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<AccountModel> accountModels = [];
|
||||
List<PostModel> postModels = [];
|
||||
results.forEach(
|
||||
(key, value) {
|
||||
for (var m in value.accountModels) {
|
||||
accountModels.add(m);
|
||||
}
|
||||
for (var m in value.postModels) {
|
||||
postModels.add(m);
|
||||
}
|
||||
},
|
||||
);
|
||||
return Material(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: accountModels.length + postModels.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index < accountModels.length) {
|
||||
final model = accountModels[index];
|
||||
return Container(
|
||||
width: global.getWidth(context),
|
||||
constraints: global.getConstraints(context),
|
||||
child: Padding(
|
||||
padding: themes.defaultMargins,
|
||||
child: Column(
|
||||
children: [
|
||||
SelectableText(model.identity),
|
||||
DisplayName(account: model)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final model = postModels[index - accountModels.length];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SelectableText(model.identity),
|
||||
Post(
|
||||
model: model,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2))),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.url,
|
||||
onEditingComplete: () {
|
||||
if (searchText.isNotEmpty) {
|
||||
search();
|
||||
}
|
||||
},
|
||||
onChanged: ((value) => setState(() {
|
||||
searchText = value;
|
||||
})),
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
Icons.search,
|
||||
))),
|
||||
if (searched < global.settings!.identities.length &&
|
||||
searchTextControl.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
SelectableText(
|
||||
"${"searched".i18n()} $searched ${searched == 1 ? "instance".i18n() : "instances".i18n()}"),
|
||||
const LinearProgressIndicator(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/dialogues/conversations.dart';
|
||||
import 'package:loris/dialogues/followreqs.dart';
|
||||
import '../../global.dart' as global;
|
||||
|
||||
class AccountSettings extends StatelessWidget {
|
||||
|
@ -13,6 +15,8 @@ class AccountSettings extends StatelessWidget {
|
|||
LogoutButton(identity: global.settings!.identities.keys.toList()[i]));
|
||||
}
|
||||
children.add(const NewAccountButton());
|
||||
children.add(const FollowreqButton());
|
||||
children.add(const ConversationButton());
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: children,
|
||||
|
@ -29,7 +33,7 @@ class LogoutButton extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
return Wrap(
|
||||
children: [
|
||||
SelectableText(identity),
|
||||
TextButton.icon(
|
||||
|
@ -73,3 +77,37 @@ Future<void> logout(context, String identity) async {
|
|||
(Navigator.of(context).pushReplacementNamed("/"));
|
||||
}
|
||||
}
|
||||
|
||||
class FollowreqButton extends StatelessWidget {
|
||||
const FollowreqButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton.icon(
|
||||
onPressed: (() => showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => const FollowReqScreen(),
|
||||
)),
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(
|
||||
"follow-requests".i18n(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ConversationButton extends StatelessWidget {
|
||||
const ConversationButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton.icon(
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => const Chat(),
|
||||
),
|
||||
icon: const Icon(Icons.chat),
|
||||
label: Text("chat".i18n()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/themes/themes.dart';
|
||||
import '../../business_logic/settings.dart' as settings;
|
||||
import '../../global.dart' as global;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
final themeStream = StreamController<CustomColors>.broadcast();
|
||||
|
||||
class AppSettings extends StatelessWidget {
|
||||
const AppSettings({Key? key}) : super(key: key);
|
||||
|
@ -17,6 +23,7 @@ class AppSettings extends StatelessWidget {
|
|||
initialSize: global.settings!.batchSize,
|
||||
),
|
||||
const ContentWidthSlider(),
|
||||
const ThemePicker(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -121,6 +128,7 @@ class _ContentWidthSliderState extends State<ContentWidthSlider> {
|
|||
if (_formKey.currentState!.validate()) {}
|
||||
},
|
||||
child: TextFormField(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textAlign: TextAlign.right,
|
||||
initialValue: maxValue,
|
||||
keyboardType: TextInputType.number,
|
||||
|
@ -150,3 +158,55 @@ class _ContentWidthSliderState extends State<ContentWidthSlider> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ThemePicker extends StatefulWidget {
|
||||
const ThemePicker({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ThemePicker> createState() => _ThemePickerState();
|
||||
}
|
||||
|
||||
class _ThemePickerState extends State<ThemePicker> {
|
||||
CustomColors v = global.settings!.theme;
|
||||
|
||||
void saveTheme(CustomColors c) {
|
||||
themeStream.add(c);
|
||||
setState(() {
|
||||
v = c;
|
||||
});
|
||||
global.settings!.saveTheme(c.name);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<DropdownMenuItem<CustomColors>> themeButtons = [];
|
||||
for (var element in themes.available) {
|
||||
themeButtons.add(DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: element,
|
||||
child: Text(
|
||||
textAlign: TextAlign.center,
|
||||
element.name,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
));
|
||||
}
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SelectableText("theme-title".i18n()),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton<themes.CustomColors>(
|
||||
alignment: Alignment.center,
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
items: themeButtons,
|
||||
onChanged: (value) {
|
||||
saveTheme(value!);
|
||||
},
|
||||
value: v,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'package:localization/localization.dart';
|
|||
import './account.dart' as account;
|
||||
import './about.dart' as about;
|
||||
import './app.dart' as app;
|
||||
import 'package:loris/global.dart' as global;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
Widget settings(context) {
|
||||
final List<Widget> categories = [
|
||||
|
@ -16,17 +18,40 @@ Widget settings(context) {
|
|||
content: const about.AboutSettings(),
|
||||
)
|
||||
];
|
||||
return ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return categories[index];
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
color: Colors.transparent,
|
||||
);
|
||||
},
|
||||
itemCount: categories.length);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
return categories[index];
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
color: Colors.transparent,
|
||||
);
|
||||
},
|
||||
itemCount: categories.length),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
children: const [],
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class SettingsPanel extends StatelessWidget {
|
||||
|
@ -42,20 +67,26 @@ class SettingsPanel extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: themes.defaultSeperatorHeight * 2,
|
||||
vertical: themes.defaultSeperatorHeight),
|
||||
child: Container(
|
||||
constraints: global.getConstraints(context),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
SelectableText(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
style: Theme.of(context).textTheme.displayMedium,
|
||||
),
|
||||
content,
|
||||
],
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/dialogues/makepost.dart';
|
||||
import 'package:loris/partials/thread.dart';
|
||||
import '../../business_logic/timeline/timeline.dart' as tl;
|
||||
import '../../global.dart' as global;
|
||||
import 'package:loris/partials/loadingbox.dart';
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class Timeline extends StatefulWidget {
|
||||
const Timeline({Key? key}) : super(key: key);
|
||||
|
@ -92,97 +94,18 @@ class TimelineState extends State<Timeline> {
|
|||
// add identities to dropdown menu
|
||||
for (int i = 0; i < global.settings!.identities.keys.length; i++) {
|
||||
identities.add(DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: global.settings!.identities.keys.toList()[i],
|
||||
child: Text(global.settings!.identities.keys.toList()[i]),
|
||||
child: Text(
|
||||
global.settings!.identities.keys.toList()[i],
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
));
|
||||
}
|
||||
selectedId = global.settings!.activeIdentity;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
reload();
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
value: selectedId,
|
||||
items: identities,
|
||||
onChanged: (dynamic value) async {
|
||||
setState(() {
|
||||
selectedId = value ?? global.settings!.activeIdentity;
|
||||
global.settings!.saveActiveIdentity(selectedId);
|
||||
reload();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
value: selectedTimelineType,
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: tl.TimelineType.home,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "${"home-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.home),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: tl.TimelineType.local,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "${"local-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.people),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: tl.TimelineType.public,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "${"public-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.public),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (tl.TimelineType? value) {
|
||||
setState(() {
|
||||
selectedTimelineType = value ?? tl.TimelineType.home;
|
||||
reload();
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
|
@ -193,13 +116,123 @@ class TimelineState extends State<Timeline> {
|
|||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
color: Colors.transparent,
|
||||
height: themes.defaultSeperatorHeight,
|
||||
);
|
||||
},
|
||||
itemCount: children.length,
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 64),
|
||||
addAutomaticKeepAlives: false,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2,
|
||||
),
|
||||
)),
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Wrap(
|
||||
spacing: 18,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
alignment: WrapAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
reload();
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
alignment: Alignment.center,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
value: selectedId,
|
||||
items: identities,
|
||||
onChanged: (dynamic value) async {
|
||||
setState(() {
|
||||
selectedId = value ?? global.settings!.activeIdentity;
|
||||
global.settings!.saveActiveIdentity(selectedId);
|
||||
reload();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
alignment: Alignment.center,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
||||
value: selectedTimelineType,
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: tl.TimelineType.home,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
text: "${"home-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.home),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: tl.TimelineType.local,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
text: "${"local-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.people),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
alignment: Alignment.center,
|
||||
value: tl.TimelineType.public,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
text: "${"public-timeline".i18n()} ",
|
||||
children: const [
|
||||
WidgetSpan(
|
||||
child: Icon(Icons.public),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (tl.TimelineType? value) {
|
||||
setState(() {
|
||||
selectedTimelineType = value ?? tl.TimelineType.home;
|
||||
reload();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: (() => showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => const MakePost(),
|
||||
)),
|
||||
icon: const Icon(Icons.create),
|
||||
label: Text("write".i18n())),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ class _InteractionButtonState extends State<InteractionButton> {
|
|||
Widget build(BuildContext context) {
|
||||
if (!widget.model.visibility.boostable &&
|
||||
widget.type == interactions.InteractionType.reblog) {
|
||||
return const Icon(Icons.lock);
|
||||
return Icon(widget.model.visibility.icon);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/dialogues/makepost.dart';
|
||||
import 'package:loris/pages/chat/chat.dart';
|
||||
import 'package:loris/pages/notifications/notifications.dart';
|
||||
import 'package:loris/pages/search/search.dart';
|
||||
import 'package:loris/pages/timeline/timeline.dart';
|
||||
import 'package:loris/pages/settings/settings.dart';
|
||||
import '../business_logic/websocket.dart' as websocket;
|
||||
|
@ -29,6 +28,7 @@ class _MainScaffoldState extends State<MainScaffold> {
|
|||
}
|
||||
}
|
||||
});
|
||||
websocket.reloadWebsockets();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -39,58 +39,47 @@ class _MainScaffoldState extends State<MainScaffold> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
websocket.reloadWebsockets();
|
||||
final screens = [
|
||||
const Timeline(),
|
||||
chat(context),
|
||||
const SearchPage(),
|
||||
const Notifications(),
|
||||
settings(context),
|
||||
];
|
||||
final buttons = [
|
||||
FloatingActionButton(
|
||||
child: const Icon(Icons.create),
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => const MakePost(),
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
extendBody: false,
|
||||
body: IndexedStack(
|
||||
index: index,
|
||||
children: screens,
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
bottomNavigationBar: SizedBox(
|
||||
height: 52,
|
||||
child: BottomAppBar(
|
||||
child: NavigationBar(
|
||||
onDestinationSelected: (index) => setState(() {
|
||||
this.index = index;
|
||||
if (index == 2) {
|
||||
unreadNotifs = 0;
|
||||
}
|
||||
}),
|
||||
selectedIndex: index,
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.forum), label: "timeline".i18n()),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.search), label: "search".i18n()),
|
||||
NavigationDestination(
|
||||
icon: Icon((unreadNotifs >= 1)
|
||||
? Icons.notifications_active
|
||||
: Icons.notifications),
|
||||
label: "notifications".i18n()),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.settings),
|
||||
label: "settings".i18n()),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
FloatingActionButton(
|
||||
onPressed: () {},
|
||||
child: const Icon(Icons.person_add),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
];
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
body: IndexedStack(
|
||||
index: index,
|
||||
children: screens,
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: buttons[index],
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: NavigationBar(
|
||||
onDestinationSelected: (index) => setState(() {
|
||||
this.index = index;
|
||||
if (index == 2) {
|
||||
unreadNotifs = 0;
|
||||
}
|
||||
}),
|
||||
selectedIndex: index,
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.forum), label: "timeline".i18n()),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.chat), label: "chat".i18n()),
|
||||
NavigationDestination(
|
||||
icon: Icon((unreadNotifs >= 1)
|
||||
? Icons.notifications_active
|
||||
: Icons.notifications),
|
||||
label: "notifications".i18n()),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.settings), label: "settings".i18n()),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,14 @@ class ImageAttachmentDisplay extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Image.network(
|
||||
model.url,
|
||||
errorBuilder: ((context, error, stackTrace) => const Icon(Icons.error)),
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fitWidth,
|
||||
),
|
||||
if (!model.url.endsWith("original"))
|
||||
Image.network(
|
||||
model.url,
|
||||
errorBuilder: ((context, error, stackTrace) =>
|
||||
const Icon(Icons.error)),
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fitWidth,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||
|
||||
class NameDisplay extends StatelessWidget {
|
||||
const NameDisplay({
|
||||
super.key,
|
||||
required this.emoji,
|
||||
required this.content,
|
||||
required this.style,
|
||||
});
|
||||
final List<Emoji> emoji;
|
||||
final String content;
|
||||
final TextStyle style;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String newtext = content;
|
||||
newtext = newtext
|
||||
.replaceAll("~", r"\~")
|
||||
.replaceAll("*", r"\*")
|
||||
.replaceAll("[", r"\[")
|
||||
.replaceAll("]", r"\]")
|
||||
.replaceAll("(", r"\(")
|
||||
.replaceAll(")", r"\)");
|
||||
for (var e in emoji) {
|
||||
newtext = insertEmojiInMd(newtext, e);
|
||||
}
|
||||
|
||||
return MarkdownBody(
|
||||
data: newtext,
|
||||
styleSheet: MarkdownStyleSheet(p: style),
|
||||
imageBuilder: (uri, title, alt) {
|
||||
try {
|
||||
return Image.network(
|
||||
uri.toString(),
|
||||
height: style.fontSize,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
SelectableText(alt ?? error.toString()),
|
||||
);
|
||||
} catch (e) {
|
||||
return SelectableText(alt ?? "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,14 +1,20 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/account/account.dart';
|
||||
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||
import 'package:loris/business_logic/timeline/media.dart';
|
||||
import 'package:loris/dialogues/full_post_view.dart';
|
||||
import 'package:loris/dialogues/makepost.dart';
|
||||
import 'package:loris/dialogues/profile_view.dart';
|
||||
import 'package:loris/partials/interaction_button.dart';
|
||||
import 'package:loris/partials/media_attachment.dart';
|
||||
import 'package:loris/partials/name.dart';
|
||||
import 'package:loris/partials/post_options.dart';
|
||||
import 'package:loris/partials/post_text_renderer.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as tl;
|
||||
import '../business_logic/interactions/interactions.dart' as interactions;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class Post extends StatefulWidget {
|
||||
const Post({
|
||||
|
@ -33,12 +39,17 @@ class _PostState extends State<Post> {
|
|||
List<Widget> c = [];
|
||||
c.addAll([
|
||||
DisplayName(account: widget.model.account),
|
||||
PostBody(
|
||||
sensitive: widget.model.sensitive,
|
||||
content: widget.model.content,
|
||||
spoilerText: widget.model.spoilerText,
|
||||
media: widget.model.attachments,
|
||||
forceShow: !widget.hideSensitive,
|
||||
const SizedBox(height: 2),
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: PostBody(
|
||||
model: widget.model,
|
||||
sensitive: widget.model.sensitive,
|
||||
content: widget.model.content,
|
||||
spoilerText: widget.model.spoilerText,
|
||||
media: widget.model.attachments,
|
||||
forceShow: !widget.hideSensitive,
|
||||
),
|
||||
),
|
||||
]);
|
||||
if (!widget.hideActionBar) {
|
||||
|
@ -54,7 +65,7 @@ class _PostState extends State<Post> {
|
|||
);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: c,
|
||||
);
|
||||
}
|
||||
|
@ -64,10 +75,12 @@ class DisplayName extends StatelessWidget {
|
|||
const DisplayName({
|
||||
required this.account,
|
||||
this.isReblog = false,
|
||||
this.openInBrowser = false,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
final AccountModel account;
|
||||
final bool isReblog;
|
||||
final bool openInBrowser;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -77,29 +90,47 @@ class DisplayName extends StatelessWidget {
|
|||
} else {
|
||||
usernameStyle = Theme.of(context).textTheme.displaySmall;
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
ProfilePic(url: account.avatar),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
account.displayName,
|
||||
style: usernameStyle,
|
||||
),
|
||||
Text(
|
||||
account.acct,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
String dname = account.displayName;
|
||||
for (var emoji in account.emojis) {
|
||||
dname = insertEmojiInMd(dname, emoji);
|
||||
}
|
||||
|
||||
return InkWell(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
onTap: !openInBrowser
|
||||
? () {
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => ProfileView(model: account),
|
||||
);
|
||||
}
|
||||
: (() => launchUrlString(account.url)),
|
||||
child: Row(
|
||||
children: [
|
||||
ProfilePic(url: account.avatar),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
],
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
NameDisplay(
|
||||
emoji: account.emojis,
|
||||
content: account.displayName,
|
||||
style: usernameStyle!,
|
||||
),
|
||||
SelectableText(
|
||||
account.acct,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +181,7 @@ class ProfilePic extends StatelessWidget {
|
|||
const double width = 64;
|
||||
if (url.isNotEmpty) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
child: Image.network(
|
||||
fit: BoxFit.cover,
|
||||
url,
|
||||
|
@ -178,13 +209,17 @@ class PostBody extends StatefulWidget {
|
|||
required this.content,
|
||||
required this.media,
|
||||
required this.forceShow,
|
||||
this.openInBrowser = false,
|
||||
Key? key,
|
||||
required this.model,
|
||||
}) : super(key: key);
|
||||
final String content;
|
||||
final String spoilerText;
|
||||
final bool sensitive;
|
||||
final bool forceShow;
|
||||
final List<MediaAttachmentModel> media;
|
||||
final bool openInBrowser;
|
||||
final tl.PostModel model;
|
||||
|
||||
@override
|
||||
State<PostBody> createState() => _PostBodyState();
|
||||
|
@ -203,62 +238,77 @@ class _PostBodyState extends State<PostBody> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(0, 6, 0, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: widget.forceShow ? false : widget.sensitive,
|
||||
child: Column(
|
||||
children: [
|
||||
SelectableText.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
visible = !visible;
|
||||
if (visible) {
|
||||
cwButtonIcon = const Icon(Icons.visibility_off);
|
||||
cwButtonText = "hide".i18n();
|
||||
} else {
|
||||
cwButtonText = "show".i18n();
|
||||
cwButtonIcon = const Icon(Icons.visibility);
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: cwButtonIcon,
|
||||
label: Text(cwButtonText),
|
||||
),
|
||||
return InkWell(
|
||||
borderRadius: const BorderRadius.all(themes.defaultRadius),
|
||||
onTap: () => showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => FullPostView(originPostModel: widget.model),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: widget.forceShow ? false : widget.sensitive,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: SelectableText.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
visible = !visible;
|
||||
if (visible) {
|
||||
cwButtonIcon =
|
||||
const Icon(Icons.visibility_off);
|
||||
cwButtonText = "hide".i18n();
|
||||
} else {
|
||||
cwButtonText = "show".i18n();
|
||||
cwButtonIcon = const Icon(Icons.visibility);
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: cwButtonIcon,
|
||||
label: Text(cwButtonText),
|
||||
),
|
||||
),
|
||||
const WidgetSpan(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
)),
|
||||
TextSpan(text: widget.spoilerText),
|
||||
],
|
||||
),
|
||||
const WidgetSpan(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
)),
|
||||
TextSpan(text: widget.spoilerText),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
)
|
||||
],
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: visible || widget.forceShow,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PostTextRenderer(input: widget.content),
|
||||
MediaAttachments(models: widget.media),
|
||||
],
|
||||
Visibility(
|
||||
visible: visible || widget.forceShow,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PostTextRenderer(
|
||||
input: widget.content,
|
||||
identityName: widget.model.identity,
|
||||
emoji: widget.model.emojis,
|
||||
),
|
||||
MediaAttachments(models: widget.media),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -275,14 +325,19 @@ class PostActionBar extends StatefulWidget {
|
|||
class _PostActionBarState extends State<PostActionBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
return Wrap(
|
||||
spacing: 24,
|
||||
runSpacing: 24,
|
||||
runAlignment: WrapAlignment.center,
|
||||
alignment: WrapAlignment.spaceAround,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 20,
|
||||
SizedBox(
|
||||
width: 64,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: ((context) => MakePost(
|
||||
inReplyTo: widget.model,
|
||||
|
@ -292,30 +347,42 @@ class _PostActionBarState extends State<PostActionBar> {
|
|||
tooltip: "reply".i18n(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 20,
|
||||
SizedBox(
|
||||
width: 64,
|
||||
child: InteractionButton(
|
||||
model: widget.model,
|
||||
type: interactions.InteractionType.reblog,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 20,
|
||||
SizedBox(
|
||||
width: 64,
|
||||
child: InteractionButton(
|
||||
model: widget.model,
|
||||
type: interactions.InteractionType.favorite,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 20,
|
||||
SizedBox(
|
||||
width: 64,
|
||||
child: IconButton(
|
||||
tooltip: "post-options".i18n(),
|
||||
onPressed: () {
|
||||
popupPostOptions(context, widget.model);
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
),
|
||||
)
|
||||
tooltip: "show-in-full".i18n(),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => FullPostView(
|
||||
originPostModel: widget.model,
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.open_in_full)),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: "post-options".i18n(),
|
||||
onPressed: () {
|
||||
popupPostOptions(context, widget.model);
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:localization/localization.dart';
|
||||
import 'package:loris/business_logic/interactions/interactions.dart';
|
||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||
import 'package:loris/dialogues/full_post_view.dart';
|
||||
import 'package:loris/partials/interaction_button.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:clipboard/clipboard.dart';
|
||||
import 'package:loris/global.dart' as global;
|
||||
|
||||
void popupPostOptions(context, PostModel model) {
|
||||
showModalBottomSheet(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) => PostOptions(model: model),
|
||||
);
|
||||
|
@ -26,17 +29,17 @@ class _PostOptionsState extends State<PostOptions> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final time = DateTime.parse(widget.model.createdAt).toLocal();
|
||||
List<Widget?> c = [
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
// title
|
||||
SelectableText("post-options".i18n(),
|
||||
style: Theme.of(context).textTheme.displayMedium),
|
||||
// time
|
||||
SelectableText(
|
||||
widget.model.createdAt
|
||||
.replaceAll("T", " ")
|
||||
.replaceAll("-", ".")
|
||||
.substring(0, 19),
|
||||
"${"day-${time.weekday}".i18n()} ${time.day}.${time.month}.${time.year} ${time.hour}:${time.minute} ${time.timeZoneName.toLowerCase()}",
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
Row(
|
||||
|
@ -49,6 +52,17 @@ class _PostOptionsState extends State<PostOptions> {
|
|||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () => showDialog(
|
||||
barrierColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
FullPostView(originPostModel: widget.model),
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.open_in_full,
|
||||
),
|
||||
label: Text("show-in-full".i18n())),
|
||||
TextButton.icon(
|
||||
onPressed: () async {
|
||||
FlutterClipboard.copy(widget.model.uri);
|
||||
|
@ -80,6 +94,7 @@ class _PostOptionsState extends State<PostOptions> {
|
|||
"show-in-browser".i18n(),
|
||||
),
|
||||
),
|
||||
|
||||
widget.model.visibility.boostable
|
||||
? InteractionButton(
|
||||
model: widget.model,
|
||||
|
@ -92,6 +107,24 @@ class _PostOptionsState extends State<PostOptions> {
|
|||
type: InteractionType.favorite,
|
||||
extended: true,
|
||||
),
|
||||
if ("${widget.model.account.acct}@${global.settings!.identities[widget.model.identity]!.instanceUrl}" ==
|
||||
widget.model.identity)
|
||||
TextButton.icon(
|
||||
onPressed: () async {
|
||||
final result = await deletePost(widget.model);
|
||||
if (result == 200) {
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.of(context).pop();
|
||||
// ignore: use_build_context_synchronously
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("post-deleted".i18n())));
|
||||
}
|
||||
// ignore: use_build_context_synchronously
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("deletion-failed".i18n())));
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
label: Text("delete-this".i18n())),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
|
|
|
@ -1,31 +1,76 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:html2md/html2md.dart' as html2md;
|
||||
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||
import 'package:loris/dialogues/profile_view.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../business_logic/account/account.dart' as account;
|
||||
|
||||
class PostTextRenderer extends StatelessWidget {
|
||||
const PostTextRenderer({
|
||||
required this.identityName,
|
||||
required this.input,
|
||||
this.emoji = const [],
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
final String input;
|
||||
final String identityName;
|
||||
final List<Emoji> emoji;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MarkdownStyleSheet mdStyle = MarkdownStyleSheet(
|
||||
codeblockDecoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
),
|
||||
code: TextStyle(
|
||||
decorationColor: Theme.of(context).backgroundColor,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
a: TextStyle(color: Theme.of(context).colorScheme.secondary),
|
||||
blockquote: TextStyle(color: Theme.of(context).colorScheme.onBackground),
|
||||
blockquoteDecoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
style: BorderStyle.solid,
|
||||
)),
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
String s = html2md.convert(input);
|
||||
for (var e in emoji) {
|
||||
s = insertEmojiInMd(s, e);
|
||||
}
|
||||
return MarkdownBody(
|
||||
onTapLink: ((text, href, title) {
|
||||
imageBuilder: (uri, title, alt) {
|
||||
return Image.network(
|
||||
"${uri.scheme}://${uri.host}${uri.path}",
|
||||
height: Theme.of(context).textTheme.bodyMedium?.fontSize,
|
||||
);
|
||||
},
|
||||
onTapLink: ((text, href, title) async {
|
||||
if (href != null) {
|
||||
// see if this is an account and in that case search for it
|
||||
if (text.startsWith("@")) {
|
||||
final result = await account.searchModel(identityName, href);
|
||||
if (result.keys.first == 200) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ProfileView(model: result.values.first!),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if this is not an account or the account couldn't be found
|
||||
// then just open it in the default browser
|
||||
launchUrl(Uri.parse(href));
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -3,10 +3,16 @@ import 'package:localization/localization.dart';
|
|||
import 'package:loris/partials/post.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as logic;
|
||||
import '../global.dart' as global;
|
||||
import 'package:loris/themes/themes.dart' as themes;
|
||||
|
||||
class Thread extends StatefulWidget {
|
||||
const Thread({required this.model, Key? key}) : super(key: key);
|
||||
const Thread({
|
||||
required this.model,
|
||||
Key? key,
|
||||
this.constrained = true,
|
||||
}) : super(key: key);
|
||||
final logic.ThreadModel model;
|
||||
final bool constrained;
|
||||
|
||||
@override
|
||||
State<Thread> createState() => _ThreadState();
|
||||
|
@ -16,14 +22,30 @@ class _ThreadState extends State<Thread> {
|
|||
Set<String> contentWarnings = {};
|
||||
int sensitivePosts = 0;
|
||||
bool showSensitive = false;
|
||||
bool collapsed = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> c = [];
|
||||
List<Widget> c = [
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
collapsed = !collapsed;
|
||||
});
|
||||
},
|
||||
icon: Icon(collapsed ? Icons.fullscreen : Icons.fullscreen_exit),
|
||||
label: Text(collapsed ? "expand".i18n() : "collapse".i18n())),
|
||||
)
|
||||
];
|
||||
for (var element in widget.model.posts) {
|
||||
c.add(Post(
|
||||
model: element,
|
||||
hideSensitive: !showSensitive,
|
||||
c.add(Visibility(
|
||||
visible: !collapsed,
|
||||
child: Post(
|
||||
model: element,
|
||||
hideSensitive: !showSensitive,
|
||||
),
|
||||
));
|
||||
if (element.sensitive) {
|
||||
sensitivePosts += 1;
|
||||
|
@ -31,11 +53,16 @@ class _ThreadState extends State<Thread> {
|
|||
}
|
||||
}
|
||||
|
||||
contentWarnings.map(
|
||||
(e) => e.trim(),
|
||||
);
|
||||
contentWarnings.removeWhere((element) => element == "");
|
||||
|
||||
if (sensitivePosts > 1 && c.length > 1) {
|
||||
String s = "";
|
||||
int i = 0;
|
||||
for (var element in contentWarnings) {
|
||||
if (i == 0) {
|
||||
if (i == 0 && i < contentWarnings.length - 1) {
|
||||
s = "$element;";
|
||||
} else if (i < contentWarnings.length - 1) {
|
||||
s = "$s $element;";
|
||||
|
@ -44,25 +71,44 @@ class _ThreadState extends State<Thread> {
|
|||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
c.insert(
|
||||
0,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SelectableText(s),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showSensitive = !showSensitive;
|
||||
});
|
||||
},
|
||||
icon:
|
||||
Icon(showSensitive ? Icons.visibility_off : Icons.visibility),
|
||||
label: Text(showSensitive ? "hide".i18n() : "show".i18n()),
|
||||
),
|
||||
],
|
||||
Visibility(
|
||||
visible: !collapsed,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(child: SelectableText(s)),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showSensitive = !showSensitive;
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
showSensitive ? Icons.visibility_off : Icons.visibility),
|
||||
label: Text(showSensitive ? "hide".i18n() : "show".i18n()),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (!widget.constrained) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: c,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -70,25 +116,25 @@ class _ThreadState extends State<Thread> {
|
|||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
width: (MediaQuery.of(context).size.width *
|
||||
global.settings!.postWidth) -
|
||||
56,
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: global.settings!.maxPostWidth,
|
||||
minWidth: 375,
|
||||
Container(
|
||||
clipBehavior: Clip.none,
|
||||
foregroundDecoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border:
|
||||
Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: c,
|
||||
),
|
||||
width: global.getWidth(context),
|
||||
constraints: global.getConstraints(context),
|
||||
child: Material(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Padding(
|
||||
padding: themes.defaultInsideMargins,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: c,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors themeDark = themes.CustomColors(
|
||||
"adwaita dark",
|
||||
const Color.fromARGB(255, 26, 95, 180),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color.fromARGB(255, 255, 190, 111),
|
||||
onPrimary: Color.fromARGB(255, 61, 56, 70),
|
||||
secondary: Color.fromARGB(255, 143, 240, 164),
|
||||
onSecondary: Color.fromARGB(255, 61, 56, 70),
|
||||
error: Color.fromARGB(255, 255, 85, 85),
|
||||
onError: Color.fromARGB(255, 61, 56, 70),
|
||||
background: Color.fromARGB(255, 36, 31, 49),
|
||||
onBackground: Color.fromARGB(255, 246, 245, 244),
|
||||
surface: Color.fromARGB(255, 61, 56, 70),
|
||||
onSurface: Color.fromARGB(255, 246, 245, 244),
|
||||
),
|
||||
const Color.fromARGB(255, 36, 31, 49),
|
||||
);
|
||||
|
||||
themes.CustomColors themeLight = themes.CustomColors(
|
||||
"adwaita light",
|
||||
const Color.fromARGB(255, 153, 193, 241),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color.fromARGB(255, 198, 70, 0),
|
||||
onPrimary: Color.fromARGB(255, 246, 245, 244),
|
||||
secondary: Color.fromARGB(255, 38, 162, 105),
|
||||
onSecondary: Color.fromARGB(255, 246, 245, 244),
|
||||
error: Color.fromARGB(255, 165, 29, 45),
|
||||
onError: Color.fromARGB(255, 246, 245, 244),
|
||||
background: Color.fromARGB(255, 222, 221, 218),
|
||||
onBackground: Color.fromARGB(255, 36, 31, 49),
|
||||
surface: Color.fromARGB(255, 246, 245, 244),
|
||||
onSurface: Color.fromARGB(255, 36, 31, 49),
|
||||
),
|
||||
const Color.fromARGB(255, 222, 221, 218),
|
||||
);
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors theme = themes.CustomColors(
|
||||
"Dracula",
|
||||
"dracula",
|
||||
const Color.fromARGB(
|
||||
255,
|
||||
98,
|
||||
|
@ -21,4 +21,5 @@ themes.CustomColors theme = themes.CustomColors(
|
|||
onBackground: Color.fromARGB(255, 248, 248, 242),
|
||||
surface: Color.fromARGB(255, 40, 42, 54),
|
||||
onSurface: Color.fromARGB(255, 248, 248, 242),
|
||||
));
|
||||
),
|
||||
const Color.fromARGB(255, 68, 71, 90));
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors theme = themes.CustomColors(
|
||||
"website #1",
|
||||
const Color.fromARGB(255, 89, 89, 89),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color.fromARGB(255, 0, 25, 53),
|
||||
onPrimary: Color.fromARGB(255, 255, 255, 255),
|
||||
secondary: Color.fromARGB(255, 0, 184, 255),
|
||||
onSecondary: Color.fromARGB(255, 255, 255, 255),
|
||||
error: Color.fromARGB(255, 245, 248, 250),
|
||||
onError: Color.fromARGB(255, 20, 23, 26),
|
||||
background: Color.fromARGB(255, 0, 25, 53),
|
||||
onBackground: Color.fromARGB(255, 255, 255, 255),
|
||||
surface: Color.fromARGB(255, 255, 255, 255),
|
||||
onSurface: Color.fromARGB(255, 0, 0, 0),
|
||||
),
|
||||
const Color.fromARGB(255, 188, 195, 202),
|
||||
);
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors theme = themes.CustomColors(
|
||||
"website #4",
|
||||
const Color.fromARGB(
|
||||
255,
|
||||
255,
|
||||
170,
|
||||
90,
|
||||
),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color.fromARGB(255, 131, 37, 79),
|
||||
onPrimary: Color.fromARGB(255, 255, 249, 242),
|
||||
secondary: Color.fromARGB(255, 81, 17, 46),
|
||||
onSecondary: Color.fromARGB(255, 255, 249, 242),
|
||||
error: Color.fromARGB(255, 255, 85, 85),
|
||||
onError: Color.fromARGB(255, 255, 249, 242),
|
||||
background: Color.fromARGB(255, 255, 241, 223),
|
||||
onBackground: Color.fromARGB(255, 25, 25, 25),
|
||||
surface: Color.fromARGB(255, 255, 249, 242),
|
||||
onSurface: Color.fromARGB(255, 25, 25, 25),
|
||||
),
|
||||
const Color.fromARGB(255, 255, 241, 223),
|
||||
);
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors themeDark = themes.CustomColors(
|
||||
"gruvbox dark",
|
||||
const Color.fromARGB(255, 175, 58, 3),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color.fromARGB(255, 211, 134, 155),
|
||||
onPrimary: Color.fromARGB(255, 29, 32, 33),
|
||||
secondary: Color.fromARGB(255, 184, 187, 38),
|
||||
onSecondary: Color.fromARGB(255, 29, 32, 33),
|
||||
error: Color.fromARGB(255, 251, 73, 52),
|
||||
onError: Color.fromARGB(255, 29, 32, 33),
|
||||
background: Color.fromARGB(255, 29, 32, 33),
|
||||
onBackground: Color.fromARGB(255, 249, 245, 215),
|
||||
surface: Color.fromARGB(255, 50, 48, 47),
|
||||
onSurface: Color.fromARGB(255, 249, 245, 215),
|
||||
),
|
||||
const Color.fromARGB(255, 29, 32, 33),
|
||||
);
|
||||
|
||||
themes.CustomColors themeLight = themes.CustomColors(
|
||||
"gruvbox light",
|
||||
const Color.fromARGB(255, 255, 190, 111),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color.fromARGB(255, 175, 58, 3),
|
||||
onPrimary: Color.fromARGB(255, 249, 245, 215),
|
||||
secondary: Color.fromARGB(255, 121, 116, 14),
|
||||
onSecondary: Color.fromARGB(255, 249, 245, 215),
|
||||
error: Color.fromARGB(255, 255, 85, 85),
|
||||
onError: Color.fromARGB(255, 249, 245, 215),
|
||||
background: Color.fromARGB(255, 242, 229, 188),
|
||||
onBackground: Color.fromARGB(255, 29, 32, 33),
|
||||
surface: Color.fromARGB(255, 249, 245, 215),
|
||||
onSurface: Color.fromARGB(255, 29, 32, 33),
|
||||
),
|
||||
const Color.fromARGB(255, 242, 229, 188),
|
||||
);
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors theme = themes.CustomColors(
|
||||
"website #2",
|
||||
const Color.fromARGB(255, 170, 184, 194),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color.fromARGB(255, 29, 161, 242),
|
||||
onPrimary: Color.fromARGB(255, 245, 248, 250),
|
||||
secondary: Color.fromARGB(255, 29, 161, 242),
|
||||
onSecondary: Color.fromARGB(255, 245, 248, 250),
|
||||
error: Color.fromARGB(255, 245, 248, 250),
|
||||
onError: Color.fromARGB(255, 20, 23, 26),
|
||||
background: Color.fromARGB(255, 245, 248, 250),
|
||||
onBackground: Color.fromARGB(255, 20, 23, 26),
|
||||
surface: Color.fromARGB(255, 245, 248, 250),
|
||||
onSurface: Color.fromARGB(255, 20, 23, 26),
|
||||
),
|
||||
const Color.fromARGB(255, 225, 232, 237),
|
||||
);
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'themes.dart' as themes;
|
||||
|
||||
themes.CustomColors theme = themes.CustomColors(
|
||||
"tess 🐯",
|
||||
const Color.fromARGB(
|
||||
255,
|
||||
6,
|
||||
34,
|
||||
42,
|
||||
),
|
||||
const ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color.fromARGB(255, 230, 62, 98),
|
||||
onPrimary: Color.fromARGB(255, 3, 16, 20),
|
||||
secondary: Color.fromARGB(255, 230, 62, 98),
|
||||
onSecondary: Color.fromARGB(255, 3, 16, 20),
|
||||
error: Color.fromARGB(255, 241, 108, 86),
|
||||
onError: Color.fromARGB(255, 3, 16, 20),
|
||||
background: Color.fromARGB(255, 3, 16, 20),
|
||||
onBackground: Color.fromARGB(255, 238, 141, 239),
|
||||
surface: Color.fromARGB(255, 3, 16, 20),
|
||||
onSurface: Color.fromARGB(255, 238, 141, 239),
|
||||
),
|
||||
const Color.fromARGB(255, 3, 16, 20),
|
||||
);
|
|
@ -1,15 +1,47 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dracula.dart' as color_dracula;
|
||||
import 'tess.dart' as color_tess;
|
||||
import 'adwaita.dart' as color_adwaita;
|
||||
import 'gruvbox.dart' as color_gruvbox;
|
||||
import 'fourth_website.dart' as color_fourth;
|
||||
import 'second.dart' as color_second;
|
||||
import 'first.dart' as color_first;
|
||||
|
||||
bool checkActive(Set<MaterialState> states) {
|
||||
return states.intersection({
|
||||
MaterialState.focused,
|
||||
MaterialState.hovered,
|
||||
MaterialState.pressed
|
||||
}).isNotEmpty;
|
||||
}
|
||||
|
||||
const defaultRadius = Radius.circular(8);
|
||||
const defaultSeperatorHeight = 4.0;
|
||||
const defaultInsideMargins = EdgeInsets.all(18);
|
||||
const defaultMargins = EdgeInsets.fromLTRB(18, 8, 18, 8);
|
||||
|
||||
// color schemes to pick from can be added here
|
||||
// there is a class to create these
|
||||
final available = [color_dracula.theme];
|
||||
final available = [
|
||||
color_dracula.theme,
|
||||
color_adwaita.themeDark,
|
||||
color_adwaita.themeLight,
|
||||
color_tess.theme,
|
||||
color_gruvbox.themeDark,
|
||||
color_gruvbox.themeLight,
|
||||
color_first.theme,
|
||||
color_second.theme,
|
||||
color_fourth.theme,
|
||||
];
|
||||
|
||||
ThemeData getTheme(CustomColors colors) {
|
||||
return ThemeData(
|
||||
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||
applyElevationOverlayColor: false,
|
||||
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||
hoverColor: colors.colorScheme.onSurface,
|
||||
elevation: 0,
|
||||
enableFeedback: false,
|
||||
hoverElevation: 24,
|
||||
hoverElevation: 0,
|
||||
),
|
||||
fontFamily: 'Atkinson',
|
||||
textTheme: TextTheme(
|
||||
|
@ -57,6 +89,41 @@ ThemeData getTheme(CustomColors colors) {
|
|||
size: 24,
|
||||
color: colors.colorScheme.onSurface,
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
shadowColor: MaterialStateProperty.all(Colors.transparent),
|
||||
shape: MaterialStateProperty.resolveWith((states) {
|
||||
if (checkActive(states)) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(defaultRadius),
|
||||
side: BorderSide(color: colors.colorScheme.primary, width: 2),
|
||||
);
|
||||
}
|
||||
return const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(defaultRadius));
|
||||
}),
|
||||
elevation: MaterialStateProperty.all(0),
|
||||
foregroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return colors.colorScheme.surface;
|
||||
}
|
||||
if (checkActive(states)) return colors.colorScheme.primary;
|
||||
|
||||
return null;
|
||||
}),
|
||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) return colors.hintColor;
|
||||
if (checkActive(states)) return colors.colorScheme.onPrimary;
|
||||
return null;
|
||||
}),
|
||||
overlayColor: MaterialStateProperty.all(Colors.transparent),
|
||||
textStyle: MaterialStateProperty.resolveWith((states) =>
|
||||
const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: "atkinson",
|
||||
fontWeight: FontWeight.w700)),
|
||||
),
|
||||
),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all(
|
||||
|
@ -75,6 +142,18 @@ ThemeData getTheme(CustomColors colors) {
|
|||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
elevation: MaterialStateProperty.all(0),
|
||||
shape: MaterialStateProperty.all(const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(defaultRadius))),
|
||||
shadowColor: MaterialStateProperty.all(Colors.transparent),
|
||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (checkActive(states)) return colors.colorScheme.primary;
|
||||
return null;
|
||||
}),
|
||||
foregroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (checkActive(states)) return colors.colorScheme.onPrimary;
|
||||
return null;
|
||||
}),
|
||||
textStyle: MaterialStateProperty.all(
|
||||
const TextStyle(fontSize: 18),
|
||||
),
|
||||
|
@ -92,11 +171,13 @@ ThemeData getTheme(CustomColors colors) {
|
|||
colorScheme: colors.colorScheme,
|
||||
errorColor: colors.colorScheme.error,
|
||||
bottomAppBarTheme: BottomAppBarTheme(
|
||||
color: colors.colorScheme.surface,
|
||||
shape: const CircularNotchedRectangle(),
|
||||
elevation: 0,
|
||||
color: colors.colorScheme.surface,
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(defaultRadius),
|
||||
),
|
||||
labelTextStyle: MaterialStateProperty.all(
|
||||
TextStyle(
|
||||
color: colors.colorScheme.onSurface,
|
||||
|
@ -104,10 +185,10 @@ ThemeData getTheme(CustomColors colors) {
|
|||
),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
indicatorColor: Colors.transparent,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
|
||||
indicatorColor: colors.hoverColor,
|
||||
elevation: 0,
|
||||
height: 64,
|
||||
height: 52,
|
||||
),
|
||||
scrollbarTheme: ScrollbarThemeData(
|
||||
thumbColor: MaterialStateProperty.all(colors.hintColor),
|
||||
|
@ -127,26 +208,41 @@ ThemeData getTheme(CustomColors colors) {
|
|||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderRadius: const BorderRadius.all(defaultRadius),
|
||||
color: colors.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
canvasColor: colors.colorScheme.surface,
|
||||
dialogBackgroundColor: colors.colorScheme.surface,
|
||||
dialogTheme: DialogTheme(
|
||||
elevation: 0,
|
||||
backgroundColor: colors.colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
width: 2,
|
||||
color: colors.colorScheme.secondary,
|
||||
style: BorderStyle.solid),
|
||||
borderRadius: const BorderRadius.all(defaultRadius))),
|
||||
selectedRowColor: colors.colorScheme.background,
|
||||
textSelectionTheme:
|
||||
TextSelectionThemeData(selectionColor: colors.hintColor),
|
||||
primaryIconTheme: const IconThemeData(size: 24),
|
||||
hoverColor: colors.colorScheme.background,
|
||||
shadowColor: colors.colorScheme.surface,
|
||||
focusColor: colors.hintColor,
|
||||
hoverColor: colors.hoverColor,
|
||||
shadowColor: Colors.transparent,
|
||||
focusColor: colors.hoverColor,
|
||||
indicatorColor: colors.hintColor,
|
||||
disabledColor: colors.hintColor,
|
||||
unselectedWidgetColor: colors.hintColor,
|
||||
toggleableActiveColor: colors.colorScheme.primary,
|
||||
splashColor: colors.colorScheme.onSurface,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
highlightColor: colors.hintColor,
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
helperStyle: TextStyle(
|
||||
color: colors.hintColor,
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
color: colors.hintColor,
|
||||
),
|
||||
fillColor: colors.colorScheme.background,
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
|
@ -155,12 +251,20 @@ ThemeData getTheme(CustomColors colors) {
|
|||
),
|
||||
),
|
||||
),
|
||||
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||
color: colors.colorScheme.primary,
|
||||
refreshBackgroundColor: colors.hintColor,
|
||||
linearTrackColor: colors.hintColor,
|
||||
circularTrackColor: colors.hintColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class CustomColors {
|
||||
late String name;
|
||||
late Color hintColor;
|
||||
// must be set for twilight themes
|
||||
late Color hoverColor;
|
||||
late ColorScheme colorScheme;
|
||||
CustomColors(this.name, this.hintColor, this.colorScheme);
|
||||
CustomColors(this.name, this.hintColor, this.colorScheme, this.hoverColor);
|
||||
}
|
||||
|
|
82
pubspec.lock
82
pubspec.lock
|
@ -14,7 +14,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -28,7 +28,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:
|
||||
|
@ -84,7 +84,7 @@ packages:
|
|||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.3.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -99,6 +99,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
file_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -122,7 +129,14 @@ packages:
|
|||
name: flutter_markdown
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.10+5"
|
||||
version: "0.6.10+6"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.7"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
@ -202,28 +216,35 @@ 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"
|
||||
mime:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mime
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.2"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -244,7 +265,7 @@ packages:
|
|||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.3"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -258,7 +279,7 @@ packages:
|
|||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.3"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -279,7 +300,7 @@ packages:
|
|||
name: shared_preferences_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.12"
|
||||
version: "2.0.13"
|
||||
shared_preferences_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -307,7 +328,7 @@ packages:
|
|||
name: shared_preferences_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -328,7 +349,7 @@ packages:
|
|||
name: shelf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
version: "1.4.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -340,7 +361,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:
|
||||
|
@ -361,21 +382,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:
|
||||
|
@ -383,6 +404,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
universal_html:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: universal_html
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
universal_io:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: universal_io
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -396,7 +431,7 @@ packages:
|
|||
name: url_launcher_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.17"
|
||||
version: "6.0.19"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -439,6 +474,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
url_strategy:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_strategy
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -459,7 +501,7 @@ packages:
|
|||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
version: "3.0.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 0.1.0+1
|
||||
version: 0.5.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.3 <3.0.0"
|
||||
|
@ -48,6 +48,11 @@ dependencies:
|
|||
flutter_markdown: ^0.6.10+5
|
||||
markdown: ^5.0.0
|
||||
html2md: ^1.2.6
|
||||
url_strategy: ^0.2.0
|
||||
universal_html: ^2.0.8
|
||||
universal_io: ^2.0.4
|
||||
file_picker: ^5.2.0
|
||||
mime: ^1.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Connexion Succeeded</title>
|
||||
<meta name="description"
|
||||
content="Simple, quick, standalone responsive placeholder without any additional resources">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
window.opener.postMessage(window.location.href, '*');
|
||||
</script>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue