Compare commits
59 Commits
8779628c81
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 842d4b8390 | |||
| 21ef9c4ab5 | |||
| 9d0cb7668d | |||
| 383de6a33b | |||
| 9e950a1767 | |||
| 20a7c88d2f | |||
| e8057a8cc6 | |||
| a71cc454eb | |||
| f1c1578620 | |||
| 5ef22c7b50 | |||
| 81222de7fe | |||
| 6dc7161b41 | |||
| f1756b30d1 | |||
| 77a524f3ec | |||
| 392ec22dcd | |||
| 064c014f8b | |||
| 410a7eb843 | |||
| 20b017b066 | |||
| a3258b84fe | |||
| f088b84c54 | |||
| 5a39148577 | |||
| 2b718b5bd8 | |||
| 023610804d | |||
| cee5af0f84 | |||
| 999023e48a | |||
| 82a74a66b5 | |||
| e645081204 | |||
| 8be30974dd | |||
| ea19802972 | |||
| 91eccc50ef | |||
| d4d191d5d2 | |||
| f9642b0230 | |||
| c5fafc2053 | |||
| a4e8dc0541 | |||
| 10ae8df737 | |||
| db8bc0b904 | |||
| 7b9188e2e8 | |||
| 18ce2d9ccf | |||
| ff3d4f61a7 | |||
| 32e44010fb | |||
| 12329d20e8 | |||
| f7c0d1050f | |||
| 5130d27529 | |||
| a422edaa38 | |||
| f6043ce474 | |||
| ec4efff01a | |||
| e1fc7c1a90 | |||
| 4eab7e2743 | |||
| 6e6b9280c0 | |||
| 019f75e1b8 | |||
| 453e106cd5 | |||
| b5f6370fdf | |||
| 1bb9fdbb18 | |||
| 35f26112af | |||
| f1dc9b5289 | |||
| 11aa6f8812 | |||
| 5fae2dcf4f | |||
| d44070a8e9 | |||
| 05b9d3e920 |
@@ -0,0 +1,68 @@
|
|||||||
|
name: Flutter APK Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
actions: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_apk:
|
||||||
|
name: Build Flutter APK
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Java (Temurin 17)
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '17'
|
||||||
|
|
||||||
|
- name: Setup Android SDK
|
||||||
|
uses: android-actions/setup-android@v3
|
||||||
|
with:
|
||||||
|
packages: "platform-tools platforms;android-36 build-tools;36.0.0"
|
||||||
|
|
||||||
|
- name: Setup Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: stable
|
||||||
|
- run: flutter --version
|
||||||
|
- run: flutter doctor
|
||||||
|
|
||||||
|
- name: Get dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Build APK
|
||||||
|
run: flutter build apk --release
|
||||||
|
|
||||||
|
- name: Upload APK artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: flutter-apk
|
||||||
|
path: build/app/outputs/flutter-apk/app-release.apk
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
uses: akkuman/gitea-release-action@v1
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.RUNNER_CREATE_RELEASE }}
|
||||||
|
with:
|
||||||
|
tag_name: "v0.1.${{ github.run_number }}"
|
||||||
|
name: "Flutter Android v0.1.${{ github.run_number }}"
|
||||||
|
body: "Automated build from CI"
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
files: |
|
||||||
|
build/app/outputs/flutter-apk/app-release.apk
|
||||||
|
gitea_url: "https://git.skup.in"
|
||||||
|
owner: "marco"
|
||||||
|
repo: "tasks"
|
||||||
@@ -43,3 +43,4 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
devtools_options.yaml
|
||||||
|
|||||||
@@ -0,0 +1,675 @@
|
|||||||
|
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>.
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppTheme {
|
||||||
|
AppTheme._();
|
||||||
|
|
||||||
|
static const double formColumnSpacing = 12.0;
|
||||||
|
|
||||||
|
static ThemeData get lightTheme => _baseTheme(
|
||||||
|
colorScheme: ColorScheme.fromSeed(
|
||||||
|
seedColor: Colors.indigo,
|
||||||
|
brightness: Brightness.light,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
static ThemeData get darkTheme => _baseTheme(
|
||||||
|
colorScheme: ColorScheme.fromSeed(
|
||||||
|
seedColor: Colors.indigo,
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
static ThemeData _baseTheme({required ColorScheme colorScheme}) {
|
||||||
|
final theme = ThemeData(useMaterial3: true, colorScheme: colorScheme);
|
||||||
|
final universalBorderRadius = BorderRadius.circular(12);
|
||||||
|
|
||||||
|
return theme.copyWith(
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
border: OutlineInputBorder(borderRadius: universalBorderRadius),
|
||||||
|
),
|
||||||
|
|
||||||
|
listTileTheme: ListTileThemeData(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: universalBorderRadius,
|
||||||
|
side: BorderSide(color: colorScheme.secondaryContainer, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import 'model/task.dart';
|
|
||||||
import 'service/tools.dart' show generateId;
|
|
||||||
|
|
||||||
List<Task> tasks = [
|
|
||||||
Task(id: generateId(), title: 'Hund föhnen', position: 0),
|
|
||||||
Task(id: '${generateId()}1', title: 'Fuchs streicheln', position: 1),
|
|
||||||
Task(id: '${generateId()}2', title: 'Katze füttern', position: 2),
|
|
||||||
Task(id: '${generateId()}3', title: 'Bär kraulen', position: 3),
|
|
||||||
];
|
|
||||||
+27
-2
@@ -1,10 +1,32 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_theme.dart';
|
||||||
|
import 'model/repositories/local_repository.dart';
|
||||||
|
import 'pages/locations_overview_page.dart';
|
||||||
import 'pages/task_edit_page.dart';
|
import 'pages/task_edit_page.dart';
|
||||||
import 'pages/task_overview_page.dart';
|
import 'pages/task_overview_page.dart';
|
||||||
|
import 'service/controller_scope.dart';
|
||||||
|
import 'service/controllers/alarm_controller.dart';
|
||||||
|
import 'service/controllers/location_controller.dart';
|
||||||
|
import 'service/controllers/task_controller.dart';
|
||||||
|
|
||||||
void main() {
|
void main() async {
|
||||||
runApp(const MainApp());
|
final repository = LocalRepository();
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await repository.initialize();
|
||||||
|
|
||||||
|
runApp(
|
||||||
|
ControllerScope(
|
||||||
|
controller: LocationController(repository),
|
||||||
|
child: ControllerScope(
|
||||||
|
controller: AlarmController(repository),
|
||||||
|
child: ControllerScope(
|
||||||
|
controller: TaskController(repository),
|
||||||
|
child: const MainApp(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainApp extends StatelessWidget {
|
class MainApp extends StatelessWidget {
|
||||||
@@ -13,9 +35,12 @@ class MainApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
theme: AppTheme.lightTheme,
|
||||||
|
darkTheme: AppTheme.darkTheme,
|
||||||
routes: {
|
routes: {
|
||||||
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
||||||
TaskEditPage.routeName: (context) => TaskEditPage(),
|
TaskEditPage.routeName: (context) => TaskEditPage(),
|
||||||
|
LocationsOverviewPage.routeName: (context) => LocationsOverviewPage(),
|
||||||
},
|
},
|
||||||
initialRoute: TaskOverviewPage.routeName,
|
initialRoute: TaskOverviewPage.routeName,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import 'location_alarm.dart';
|
||||||
|
import 'time_alarm.dart';
|
||||||
|
|
||||||
|
abstract class Alarm {
|
||||||
|
String get id;
|
||||||
|
String get taskId;
|
||||||
|
Map<String, dynamic> toJson();
|
||||||
|
|
||||||
|
factory Alarm.fromJson(Map<String, dynamic> json) {
|
||||||
|
if (json.containsKey('triggerAt')) {
|
||||||
|
return TimeAlarm.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.containsKey('location')) {
|
||||||
|
return LocationAlarm.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ArgumentError('Unknown alarm type');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (other is! Alarm) return false;
|
||||||
|
|
||||||
|
return hashCode == other.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => taskId.hashCode;
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import '../location.dart';
|
|
||||||
import '../task.dart';
|
import '../task.dart';
|
||||||
|
|
||||||
class CreateTaskRequest {
|
class CreateTaskRequest {
|
||||||
@@ -9,8 +8,6 @@ class CreateTaskRequest {
|
|||||||
final bool isCompleted;
|
final bool isCompleted;
|
||||||
final String category;
|
final String category;
|
||||||
final List<Task> subtasks;
|
final List<Task> subtasks;
|
||||||
final List<DateTime> alarms;
|
|
||||||
final Location? location;
|
|
||||||
final String url;
|
final String url;
|
||||||
|
|
||||||
CreateTaskRequest({
|
CreateTaskRequest({
|
||||||
@@ -21,8 +18,6 @@ class CreateTaskRequest {
|
|||||||
required this.isCompleted,
|
required this.isCompleted,
|
||||||
required this.category,
|
required this.category,
|
||||||
required this.subtasks,
|
required this.subtasks,
|
||||||
required this.alarms,
|
|
||||||
required this.location,
|
|
||||||
required this.url,
|
required this.url,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -34,11 +29,9 @@ class CreateTaskRequest {
|
|||||||
isCompleted = task.isCompleted,
|
isCompleted = task.isCompleted,
|
||||||
category = task.category,
|
category = task.category,
|
||||||
subtasks = task.subtasks,
|
subtasks = task.subtasks,
|
||||||
alarms = task.alarms,
|
|
||||||
location = task.location,
|
|
||||||
url = task.url;
|
url = task.url;
|
||||||
|
|
||||||
Task toTask({required String id, required int position}) {
|
Task toTask({required String id}) {
|
||||||
return Task(
|
return Task(
|
||||||
id: id,
|
id: id,
|
||||||
title: title,
|
title: title,
|
||||||
@@ -48,10 +41,7 @@ class CreateTaskRequest {
|
|||||||
isCompleted: isCompleted,
|
isCompleted: isCompleted,
|
||||||
category: category,
|
category: category,
|
||||||
subtasks: subtasks,
|
subtasks: subtasks,
|
||||||
alarms: alarms,
|
|
||||||
location: location,
|
|
||||||
url: url,
|
url: url,
|
||||||
position: position,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../service/controller_scope.dart';
|
||||||
|
|
||||||
|
extension ControllerContext on BuildContext {
|
||||||
|
T controller<T extends ChangeNotifier>() {
|
||||||
|
return ControllerScope.of<T>(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,4 +4,35 @@ class LatLng {
|
|||||||
|
|
||||||
LatLng(this.lat, this.lng);
|
LatLng(this.lat, this.lng);
|
||||||
LatLng.empty() : lat = 0, lng = 0;
|
LatLng.empty() : lat = 0, lng = 0;
|
||||||
|
|
||||||
|
/// must be formatted 'double, double'. For example 35.35217, 89.19659
|
||||||
|
factory LatLng.fromString(String latLng) {
|
||||||
|
final splitString = latLng.split(',');
|
||||||
|
final lat = double.parse(splitString[0].trim());
|
||||||
|
final lng = double.parse(splitString[1].trim());
|
||||||
|
|
||||||
|
return LatLng(lat, lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory LatLng.fromJson(Map<String, dynamic> json) {
|
||||||
|
return LatLng(json['lat'] as double, json['lng'] as double);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, double> toJson() {
|
||||||
|
return {'lat': lat, 'lng': lng};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (other is! LatLng) return false;
|
||||||
|
return hashCode == other.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(lat, lng);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return '${lat.toString()}, ${lng.toString()}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-7
@@ -1,14 +1,34 @@
|
|||||||
import 'latlng.dart';
|
import 'latlng.dart';
|
||||||
|
|
||||||
class Location {
|
class Location {
|
||||||
final String? _address;
|
final String name;
|
||||||
final LatLng? _coordinates;
|
final LatLng coordinates;
|
||||||
|
final String address;
|
||||||
|
|
||||||
Location({this._address, this._coordinates});
|
Location({required this.name, required this.coordinates, this.address = ''});
|
||||||
|
|
||||||
Location.fromAddress({required this._address}) : _coordinates = null;
|
factory Location.fromJson(Map<String, dynamic> json) {
|
||||||
Location.fromCoordinates({required this._coordinates}) : _address = null;
|
return Location(
|
||||||
|
name: json['name'] as String,
|
||||||
|
address: json['address'] as String,
|
||||||
|
coordinates: LatLng.fromJson(json['coordinates']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String get address => _address ?? '';
|
Map<String, dynamic> toJson() {
|
||||||
LatLng get coordinates => _coordinates ?? LatLng.empty();
|
return {
|
||||||
|
'name': name,
|
||||||
|
'address': address,
|
||||||
|
'coordinates': coordinates.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (other is! Location) return false;
|
||||||
|
return hashCode == other.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => coordinates.hashCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import 'alarm.dart';
|
||||||
|
import 'location.dart';
|
||||||
|
|
||||||
|
class LocationAlarm implements Alarm {
|
||||||
|
@override
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String taskId;
|
||||||
|
|
||||||
|
final Location location;
|
||||||
|
|
||||||
|
final int radiusMeters;
|
||||||
|
|
||||||
|
const LocationAlarm({
|
||||||
|
required this.id,
|
||||||
|
required this.taskId,
|
||||||
|
required this.location,
|
||||||
|
required this.radiusMeters,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory LocationAlarm.fromJson(Map<String, dynamic> json) {
|
||||||
|
return LocationAlarm(
|
||||||
|
id: json['id'] as String,
|
||||||
|
taskId: json['taskId'] as String,
|
||||||
|
location: Location.fromJson(json['location'] as Map<String, dynamic>),
|
||||||
|
radiusMeters: json['radiusMeters'] as int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'taskId': taskId,
|
||||||
|
'location': location.toJson(),
|
||||||
|
'radiusMeters': radiusMeters,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import '../../alarm.dart';
|
||||||
|
|
||||||
|
abstract class AlarmRepository {
|
||||||
|
// Create
|
||||||
|
|
||||||
|
Future<void> createAlarm(Alarm alarm);
|
||||||
|
|
||||||
|
// Read
|
||||||
|
|
||||||
|
Future<List<Alarm>> loadAlarms();
|
||||||
|
|
||||||
|
// Update
|
||||||
|
|
||||||
|
Future<void> updateAlarm(Alarm alarm);
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
|
||||||
|
Future<void> deleteAlarm(Alarm alarm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import '../../location.dart';
|
||||||
|
|
||||||
|
abstract class LocationRepository {
|
||||||
|
// Create
|
||||||
|
|
||||||
|
Future<void> createLocation(Location location);
|
||||||
|
|
||||||
|
// Read
|
||||||
|
|
||||||
|
Future<List<Location>> loadLocations();
|
||||||
|
|
||||||
|
// Update
|
||||||
|
|
||||||
|
Future<void> updateLocation(Location location);
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
|
||||||
|
Future<void> deleteLocation(Location location);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import '../../task.dart';
|
||||||
|
|
||||||
|
abstract class TaskRepository {
|
||||||
|
// Create
|
||||||
|
|
||||||
|
Future<void> createTask(Task task);
|
||||||
|
|
||||||
|
Future<void> createTaskOrderEntry(String taskOrder);
|
||||||
|
|
||||||
|
// Read
|
||||||
|
|
||||||
|
Future<List<Task>> loadTasks();
|
||||||
|
|
||||||
|
Future<List<String>> loadTaskOrder();
|
||||||
|
|
||||||
|
// Update
|
||||||
|
|
||||||
|
Future<void> updateTask(Task task);
|
||||||
|
|
||||||
|
Future<void> updateTaskOrder(List<String> taskOrder);
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
|
||||||
|
Future<void> deleteTask(Task task);
|
||||||
|
|
||||||
|
Future<void> deleteTaskOrderEntry(String taskOrderEntry);
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../alarm.dart';
|
||||||
|
import '../location.dart';
|
||||||
|
import '../task.dart';
|
||||||
|
import 'interfaces/alarm_repository.dart';
|
||||||
|
import 'interfaces/location_repository.dart';
|
||||||
|
import 'interfaces/task_repository.dart';
|
||||||
|
|
||||||
|
class LocalRepository
|
||||||
|
implements TaskRepository, AlarmRepository, LocationRepository {
|
||||||
|
static const String _tasksKey = 'tasks';
|
||||||
|
static const String _taskOrderKey = 'taskOrder';
|
||||||
|
static const String _alarmsKey = 'alarms';
|
||||||
|
static const String _locationsKey = 'locations';
|
||||||
|
|
||||||
|
SharedPreferencesWithCache? _prefs;
|
||||||
|
|
||||||
|
Future<void> initialize() async {
|
||||||
|
if (_prefs == null) {
|
||||||
|
await SharedPreferencesWithCache.create(
|
||||||
|
cacheOptions: const SharedPreferencesWithCacheOptions(
|
||||||
|
allowList: <String>{
|
||||||
|
_tasksKey,
|
||||||
|
_taskOrderKey,
|
||||||
|
_alarmsKey,
|
||||||
|
_locationsKey,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
).then((value) => _prefs = value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveTasks(List<Task> tasks) async {
|
||||||
|
final jsonList = tasks.map<String>((e) => jsonEncode(e.toJson())).toList();
|
||||||
|
_prefs!.setStringList(_tasksKey, jsonList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveLocations(List<Location> locations) async {
|
||||||
|
final jsonList = locations
|
||||||
|
.map<String>((e) => jsonEncode(e.toJson()))
|
||||||
|
.toList();
|
||||||
|
_prefs!.setStringList(_locationsKey, jsonList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveTaskOrder(List<String> taskOrder) async {
|
||||||
|
final jsonList = taskOrder.map((e) => jsonEncode(e)).toList();
|
||||||
|
return _prefs!.setStringList(_taskOrderKey, jsonList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveAlarms(List<Alarm> alarms) async {
|
||||||
|
final jsonList = alarms.map<String>((e) => jsonEncode(e.toJson())).toList();
|
||||||
|
return _prefs!.setStringList(_alarmsKey, jsonList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createTask(Task task) async {
|
||||||
|
final tasks = await loadTasks();
|
||||||
|
tasks.add(task);
|
||||||
|
return _saveTasks(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createTaskOrderEntry(String taskOrderEntry) async {
|
||||||
|
final taskOrder = await loadTaskOrder();
|
||||||
|
taskOrder.add(taskOrderEntry);
|
||||||
|
return _saveTaskOrder(taskOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createAlarm(Alarm alarm) async {
|
||||||
|
final alarms = await loadAlarms();
|
||||||
|
alarms.add(alarm);
|
||||||
|
_saveAlarms(alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createLocation(Location location) async {
|
||||||
|
final locations = await loadLocations();
|
||||||
|
locations.add(location);
|
||||||
|
_saveLocations(locations);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Task>> loadTasks() async {
|
||||||
|
final Iterable<String> jsonList = _prefs!.getStringList(_tasksKey) ?? [];
|
||||||
|
return jsonList.map<Task>((e) => Task.fromJson(jsonDecode(e))).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<String>> loadTaskOrder() async {
|
||||||
|
final Iterable<String> jsonList =
|
||||||
|
_prefs!.getStringList(_taskOrderKey) ?? [];
|
||||||
|
return jsonList.map<String>((e) => jsonDecode(e)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Alarm>> loadAlarms() async {
|
||||||
|
final Iterable<String> jsonList = _prefs!.getStringList(_alarmsKey) ?? [];
|
||||||
|
return jsonList.map<Alarm>((e) => Alarm.fromJson(jsonDecode(e))).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Location>> loadLocations() async {
|
||||||
|
final Iterable<String> jsonList =
|
||||||
|
_prefs!.getStringList(_locationsKey) ?? [];
|
||||||
|
return jsonList
|
||||||
|
.map<Location>((e) => Location.fromJson(jsonDecode(e)))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateTask(Task task) async {
|
||||||
|
final tasks = await loadTasks();
|
||||||
|
tasks.remove(task);
|
||||||
|
tasks.add(task);
|
||||||
|
return _saveTasks(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateTaskOrder(List<String> taskOrder) async {
|
||||||
|
return _saveTaskOrder(taskOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateAlarm(Alarm alarm) async {
|
||||||
|
final alarms = await loadAlarms();
|
||||||
|
alarms.remove(alarm);
|
||||||
|
alarms.add(alarm);
|
||||||
|
_saveAlarms(alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateLocation(Location location) async {
|
||||||
|
final locations = await loadLocations();
|
||||||
|
locations.remove(location);
|
||||||
|
locations.add(location);
|
||||||
|
_saveLocations(locations);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteTask(Task task) async {
|
||||||
|
final tasks = await loadTasks();
|
||||||
|
tasks.remove(task);
|
||||||
|
return _saveTasks(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteTaskOrderEntry(String taskOrderEntry) async {
|
||||||
|
final taskOrder = await loadTaskOrder();
|
||||||
|
taskOrder.remove(taskOrderEntry);
|
||||||
|
return _saveTaskOrder(taskOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteAlarm(Alarm alarm) async {
|
||||||
|
final alarms = await loadAlarms();
|
||||||
|
alarms.remove(alarm);
|
||||||
|
_saveAlarms(alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteLocation(Location location) async {
|
||||||
|
final locations = await loadLocations();
|
||||||
|
locations.remove(location);
|
||||||
|
_saveLocations(locations);
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
-10
@@ -9,10 +9,7 @@ class Task {
|
|||||||
final bool isCompleted;
|
final bool isCompleted;
|
||||||
final String category;
|
final String category;
|
||||||
final List<Task> subtasks;
|
final List<Task> subtasks;
|
||||||
final List<DateTime> alarms;
|
|
||||||
final Location? location;
|
|
||||||
final String url;
|
final String url;
|
||||||
final int position;
|
|
||||||
|
|
||||||
Task({
|
Task({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -23,10 +20,7 @@ class Task {
|
|||||||
this.isCompleted = false,
|
this.isCompleted = false,
|
||||||
this.category = '',
|
this.category = '',
|
||||||
this.subtasks = const [],
|
this.subtasks = const [],
|
||||||
this.alarms = const [],
|
|
||||||
this.location,
|
|
||||||
this.url = '',
|
this.url = '',
|
||||||
required this.position,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Task copyWith({
|
Task copyWith({
|
||||||
@@ -41,7 +35,6 @@ class Task {
|
|||||||
List<DateTime>? alarms,
|
List<DateTime>? alarms,
|
||||||
Location? location,
|
Location? location,
|
||||||
String? url,
|
String? url,
|
||||||
int? position,
|
|
||||||
}) {
|
}) {
|
||||||
return Task(
|
return Task(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -52,10 +45,51 @@ class Task {
|
|||||||
isCompleted: isCompleted ?? this.isCompleted,
|
isCompleted: isCompleted ?? this.isCompleted,
|
||||||
category: category ?? this.category,
|
category: category ?? this.category,
|
||||||
subtasks: subtasks ?? this.subtasks,
|
subtasks: subtasks ?? this.subtasks,
|
||||||
alarms: alarms ?? this.alarms,
|
|
||||||
location: location ?? this.location,
|
|
||||||
url: url ?? this.url,
|
url: url ?? this.url,
|
||||||
position: position ?? this.position,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
factory Task.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Task(
|
||||||
|
id: json['id'] as String,
|
||||||
|
title: json['title'] as String,
|
||||||
|
description: json['description'] as String? ?? '',
|
||||||
|
start: json['start'] != null
|
||||||
|
? DateTime.parse(json['start'] as String)
|
||||||
|
: null,
|
||||||
|
due: json['due'] != null ? DateTime.parse(json['due'] as String) : null,
|
||||||
|
isCompleted: json['isCompleted'] as bool? ?? false,
|
||||||
|
category: json['category'] as String? ?? '',
|
||||||
|
subtasks:
|
||||||
|
(json['subtasks'] as List<dynamic>?)
|
||||||
|
?.map((e) => Task.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
url: json['url'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'start': start?.toIso8601String(),
|
||||||
|
'due': due?.toIso8601String(),
|
||||||
|
'isCompleted': isCompleted,
|
||||||
|
'category': category,
|
||||||
|
'subtasks': subtasks.map((e) => e.toJson()).toList(),
|
||||||
|
'url': url,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (other is! Task) return false;
|
||||||
|
|
||||||
|
return hashCode == other.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => id.hashCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import 'alarm.dart';
|
||||||
|
|
||||||
|
class TimeAlarm implements Alarm {
|
||||||
|
@override
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String taskId;
|
||||||
|
|
||||||
|
final DateTime triggerAt;
|
||||||
|
|
||||||
|
const TimeAlarm({
|
||||||
|
required this.id,
|
||||||
|
required this.taskId,
|
||||||
|
required this.triggerAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory TimeAlarm.fromJson(Map<String, dynamic> json) {
|
||||||
|
return TimeAlarm(
|
||||||
|
id: json['id'] as String,
|
||||||
|
taskId: json['taskId'] as String,
|
||||||
|
triggerAt: DateTime.parse(json['triggerAt'] as String),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'taskId': taskId,
|
||||||
|
'triggerAt': triggerAt.toIso8601String(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../model/extensions/controller_context.dart';
|
||||||
|
import '../model/location.dart';
|
||||||
|
import '../service/controllers/location_controller.dart';
|
||||||
|
import '../widgets/dialogs/create_location_dialog.dart';
|
||||||
|
|
||||||
|
class LocationsOverviewPage extends StatefulWidget {
|
||||||
|
static const routeName = '/locations';
|
||||||
|
const LocationsOverviewPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LocationsOverviewPage> createState() => _LocationsOverviewPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LocationsOverviewPageState extends State<LocationsOverviewPage> {
|
||||||
|
List<Location> locations = [];
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
locations = context.controller<LocationController>().locations;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: Text('Manage Locations')),
|
||||||
|
body: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
itemBuilder: listViewBuilder,
|
||||||
|
itemCount: context.controller<LocationController>().locations.length,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: onAddLocationButtonPressed,
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget listViewBuilder(BuildContext context, int index) {
|
||||||
|
final location = locations.elementAt(index);
|
||||||
|
final String subtitle = location.address.isEmpty
|
||||||
|
? location.coordinates.toString()
|
||||||
|
: location.address;
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
title: Text(location.name),
|
||||||
|
subtitle: Text(subtitle),
|
||||||
|
onTap: () => onEditLocationButtonPressed(location),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onAddLocationButtonPressed() async {
|
||||||
|
final result = await showDialog<Location?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => CreateLocationDialog(),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
if (mounted && result != null) {
|
||||||
|
context.controller<LocationController>().addLocation(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onEditLocationButtonPressed(Location location) async {
|
||||||
|
final result = await showDialog<Location?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => CreateLocationDialog(initialLocation: location),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
if (mounted && result != null) {
|
||||||
|
context.controller<LocationController>().updateLocation(location, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,177 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../app_theme.dart';
|
||||||
|
import '../model/callback_models/create_task_request.dart';
|
||||||
|
import '../model/extensions/controller_context.dart';
|
||||||
import '../model/task.dart';
|
import '../model/task.dart';
|
||||||
|
import '../service/controllers/task_controller.dart';
|
||||||
|
import '../service/tools.dart';
|
||||||
|
import '../widgets/time_selector.dart';
|
||||||
|
|
||||||
class TaskEditPage extends StatelessWidget {
|
class TaskEditPage extends StatefulWidget {
|
||||||
static const routeName = '/edit';
|
static const routeName = '/edit';
|
||||||
const TaskEditPage({super.key});
|
const TaskEditPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<TaskEditPage> createState() => _TaskEditPageState();
|
||||||
final task = ModalRoute.of(context)!.settings.arguments as Task?;
|
}
|
||||||
|
|
||||||
|
class _TaskEditPageState extends State<TaskEditPage> {
|
||||||
|
Task? task;
|
||||||
|
bool isInitialized = false;
|
||||||
|
final titleController = TextEditingController();
|
||||||
|
final descriptionController = TextEditingController();
|
||||||
|
final categoryController = TextEditingController();
|
||||||
|
final urlController = TextEditingController();
|
||||||
|
final dueDateController = TextEditingController();
|
||||||
|
final dueTimeController = TextEditingController();
|
||||||
|
String pageTitle = 'Create Task';
|
||||||
|
final dueDateFocusNode = FocusNode();
|
||||||
|
final dueTimeFocusNode = FocusNode();
|
||||||
|
final categoryFocusNode = FocusNode();
|
||||||
|
final formKey = GlobalKey<FormState>(debugLabel: 'taskEditFormKey');
|
||||||
|
bool didFormChange = false;
|
||||||
|
bool isDueTimeEnabled = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
task = ModalRoute.of(context)!.settings.arguments as Task?;
|
||||||
|
if (task != null && !isInitialized) {
|
||||||
|
titleController.text = task!.title;
|
||||||
|
descriptionController.text = task!.description;
|
||||||
|
categoryController.text = task!.category;
|
||||||
|
urlController.text = task!.url;
|
||||||
|
if (task!.due != null) {
|
||||||
|
dueDateController.text = getIsoDateString(task!.due!);
|
||||||
|
dueTimeController.text = TimeOfDay.fromDateTime(
|
||||||
|
task!.due!,
|
||||||
|
).format(context);
|
||||||
|
isDueTimeEnabled = true;
|
||||||
|
}
|
||||||
|
isInitialized = true;
|
||||||
|
pageTitle = task!.title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(task?.title ?? 'Create Task')),
|
appBar: AppBar(
|
||||||
body: Form(child: Column()),
|
title: Text(pageTitle),
|
||||||
|
actions: [
|
||||||
|
if (task != null)
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.controller<TaskController>().deleteTask(task!);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.delete),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
canPop: !didFormChange,
|
||||||
|
onChanged: () => didFormChange = true,
|
||||||
|
onPopInvokedWithResult: onPopInvoked,
|
||||||
|
autovalidateMode: AutovalidateMode.onUnfocus,
|
||||||
|
key: formKey,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
spacing: AppTheme.formColumnSpacing,
|
||||||
|
children: [
|
||||||
|
SizedBox(height: 6),
|
||||||
|
TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
controller: titleController,
|
||||||
|
decoration: InputDecoration(label: Text('Title')),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
controller: descriptionController,
|
||||||
|
decoration: InputDecoration(label: Text('Description')),
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
textInputAction: TextInputAction.newline,
|
||||||
|
minLines: 3,
|
||||||
|
maxLines: 10,
|
||||||
|
),
|
||||||
|
TimeSelector(
|
||||||
|
initialDueDateTime: task?.due,
|
||||||
|
nextFocusNode: categoryFocusNode,
|
||||||
|
dueDateController: dueDateController,
|
||||||
|
dueTimeController: dueTimeController,
|
||||||
|
formKey: formKey,
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
focusNode: categoryFocusNode,
|
||||||
|
controller: categoryController,
|
||||||
|
decoration: InputDecoration(label: Text('Category')),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
controller: urlController,
|
||||||
|
decoration: InputDecoration(label: Text('Url')),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: onSavePressed,
|
||||||
|
child: Icon(Icons.save),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSavePressed() {
|
||||||
|
Navigator.of(context).pop(
|
||||||
|
CreateTaskRequest(
|
||||||
|
title: titleController.text,
|
||||||
|
description: descriptionController.text,
|
||||||
|
start: null,
|
||||||
|
due: DateTime.tryParse(
|
||||||
|
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
||||||
|
),
|
||||||
|
isCompleted: false,
|
||||||
|
category: categoryController.text,
|
||||||
|
subtasks: [],
|
||||||
|
url: urlController.text,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onPopInvoked(bool didPop, Object? result) {
|
||||||
|
if (!didPop) {
|
||||||
|
showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: Text('Unsaved Changes'),
|
||||||
|
content: Text(
|
||||||
|
'Are you sure you want to cancel editing? Unsaved changes will be lost.',
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
|
child: Text('No'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
|
child: Text('Yes'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).then((result) {
|
||||||
|
if (result != null && result && mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../example_data.dart';
|
import '../model/callback_models/create_task_request.dart';
|
||||||
|
import '../model/extensions/controller_context.dart';
|
||||||
import '../model/task.dart';
|
import '../model/task.dart';
|
||||||
|
import '../service/controllers/task_controller.dart';
|
||||||
|
import '../service/tools.dart';
|
||||||
|
import '../widgets/task_dismissible.dart';
|
||||||
|
import 'locations_overview_page.dart';
|
||||||
import 'task_edit_page.dart';
|
import 'task_edit_page.dart';
|
||||||
|
|
||||||
class TaskOverviewPage extends StatefulWidget {
|
class TaskOverviewPage extends StatefulWidget {
|
||||||
@@ -13,16 +18,34 @@ class TaskOverviewPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||||
//TODO: Replace example data call
|
List<Task> get tasks => context.controller<TaskController>().orderedTasks;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(
|
||||||
body: ReorderableListView.builder(
|
title: Text('Hallo Yannick'),
|
||||||
itemBuilder: itemBuilder,
|
actions: [
|
||||||
itemCount: tasks.length,
|
PopupMenuButton(
|
||||||
onReorderItem: (oldIndex, newIndex) =>
|
itemBuilder: (_) => [
|
||||||
reorderList(tasks, oldIndex, newIndex),
|
PopupMenuItem(
|
||||||
|
onTap: onLocationsButtonTapped,
|
||||||
|
child: Text('Locations'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
icon: Icon(Icons.more_vert),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
|
),
|
||||||
|
child: ReorderableListView.builder(
|
||||||
|
itemBuilder: itemBuilder,
|
||||||
|
itemCount: tasks.length,
|
||||||
|
onReorderItem: context.controller<TaskController>().reorderTask,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: onCreateTaskTapped,
|
onPressed: onCreateTaskTapped,
|
||||||
@@ -34,41 +57,54 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
|||||||
Widget itemBuilder(BuildContext context, int index) {
|
Widget itemBuilder(BuildContext context, int index) {
|
||||||
final task = tasks.elementAt(index);
|
final task = tasks.elementAt(index);
|
||||||
|
|
||||||
return ListTile(
|
return Padding(
|
||||||
key: Key(task.id),
|
key: Key(task.id),
|
||||||
title: Text(task.title),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
subtitle: Text(task.description),
|
child: TaskDismissible(
|
||||||
onTap: () => onTaskTapped(task),
|
key: Key(task.id),
|
||||||
|
onDismissedRight: () =>
|
||||||
|
context.controller<TaskController>().deleteTask(task),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(task.title),
|
||||||
|
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
||||||
|
trailing: Checkbox(
|
||||||
|
value: task.isCompleted,
|
||||||
|
onChanged: (isCompleted) => context
|
||||||
|
.controller<TaskController>()
|
||||||
|
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
final result = await onTaskTapped(task);
|
||||||
|
if (result != null && context.mounted) {
|
||||||
|
context.controller<TaskController>().saveTask(
|
||||||
|
result.toTask(id: task.id),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Task?> onTaskTapped(Task task) async {
|
Future<CreateTaskRequest?> onTaskTapped(Task task) async {
|
||||||
final result = await Navigator.of(
|
final result = await Navigator.of(
|
||||||
context,
|
context,
|
||||||
).pushNamed(TaskEditPage.routeName, arguments: task);
|
).pushNamed(TaskEditPage.routeName, arguments: task);
|
||||||
return result as Task?;
|
return result as CreateTaskRequest?;
|
||||||
}
|
|
||||||
|
|
||||||
List<Task> reorderList(List<Task> tasks, oldIndex, newIndex) {
|
|
||||||
final item = tasks.removeAt(oldIndex);
|
|
||||||
tasks.insert(newIndex, item);
|
|
||||||
|
|
||||||
final List<Task> reordered = [];
|
|
||||||
|
|
||||||
for (int i = 0; i < tasks.length; i++) {
|
|
||||||
reordered.add(tasks.elementAt(i).copyWith(position: i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return reordered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCreateTaskTapped() async {
|
void onCreateTaskTapped() async {
|
||||||
//TODO: example data call
|
|
||||||
final result =
|
final result =
|
||||||
await Navigator.of(context).pushNamed(TaskEditPage.routeName) as Task?;
|
await Navigator.of(context).pushNamed(TaskEditPage.routeName)
|
||||||
|
as CreateTaskRequest?;
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null && mounted) {
|
||||||
tasks.add(result);
|
context.controller<TaskController>().saveTask(
|
||||||
|
result.toTask(id: generateId()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onLocationsButtonTapped() =>
|
||||||
|
Navigator.of(context).pushNamed(LocationsOverviewPage.routeName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
class ControllerScope<T extends ChangeNotifier> extends InheritedNotifier<T> {
|
||||||
|
const ControllerScope({
|
||||||
|
super.key,
|
||||||
|
required T controller,
|
||||||
|
required super.child,
|
||||||
|
}) : super(notifier: controller);
|
||||||
|
|
||||||
|
static T of<T extends ChangeNotifier>(BuildContext context) {
|
||||||
|
final scope = context
|
||||||
|
.dependOnInheritedWidgetOfExactType<ControllerScope<T>>();
|
||||||
|
|
||||||
|
assert(scope != null, 'No ControllerScope<$T> found in context');
|
||||||
|
|
||||||
|
return scope!.notifier!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../model/alarm.dart';
|
||||||
|
import '../../model/repositories/interfaces/alarm_repository.dart';
|
||||||
|
|
||||||
|
class AlarmController extends ChangeNotifier {
|
||||||
|
AlarmController(AlarmRepository repository) : _repository = repository {
|
||||||
|
_loadAlarms();
|
||||||
|
}
|
||||||
|
|
||||||
|
final AlarmRepository _repository;
|
||||||
|
|
||||||
|
final List<Alarm> _alarms = [];
|
||||||
|
|
||||||
|
Future<void> addAlarm(Alarm alarm) {
|
||||||
|
_alarms.add(alarm);
|
||||||
|
notifyListeners();
|
||||||
|
return _repository.createAlarm(alarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteAlarm(Alarm alarm) {
|
||||||
|
_alarms.remove(alarm);
|
||||||
|
notifyListeners();
|
||||||
|
return _repository.deleteAlarm(alarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadAlarms() {
|
||||||
|
_alarms.clear();
|
||||||
|
return _repository.loadAlarms().then((value) => _alarms.addAll(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../model/location.dart';
|
||||||
|
import '../../model/repositories/interfaces/location_repository.dart';
|
||||||
|
|
||||||
|
class LocationController extends ChangeNotifier {
|
||||||
|
LocationController(LocationRepository repository) : _repository = repository {
|
||||||
|
_loadLocations();
|
||||||
|
}
|
||||||
|
|
||||||
|
final LocationRepository _repository;
|
||||||
|
|
||||||
|
final List<Location> _locations = [];
|
||||||
|
|
||||||
|
List<Location> get locations => _locations;
|
||||||
|
|
||||||
|
Future<void> addLocation(Location location) {
|
||||||
|
_locations.add(location);
|
||||||
|
notifyListeners();
|
||||||
|
return _repository.createLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteLocation(Location location) {
|
||||||
|
_locations.remove(location);
|
||||||
|
notifyListeners();
|
||||||
|
return _repository.deleteLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateLocation(Location oldLocation, Location newLocation) {
|
||||||
|
final index = _locations.indexOf(oldLocation);
|
||||||
|
_locations.remove(oldLocation);
|
||||||
|
_locations.insert(index, newLocation);
|
||||||
|
notifyListeners();
|
||||||
|
return _repository
|
||||||
|
.deleteLocation(oldLocation)
|
||||||
|
.whenComplete(() => _repository.createLocation(newLocation));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadLocations() {
|
||||||
|
_locations.clear();
|
||||||
|
return _repository.loadLocations().then(
|
||||||
|
(value) => _locations.addAll(value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import 'package:flutter/material.dart' show ChangeNotifier;
|
||||||
|
|
||||||
|
import '../../model/repositories/interfaces/task_repository.dart';
|
||||||
|
import '../../model/task.dart';
|
||||||
|
|
||||||
|
class TaskController extends ChangeNotifier {
|
||||||
|
TaskController(TaskRepository repository) : _repository = repository {
|
||||||
|
Future.wait([
|
||||||
|
_loadTaskOrder(),
|
||||||
|
_loadTasks(),
|
||||||
|
]).whenComplete(() => notifyListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
final TaskRepository _repository;
|
||||||
|
|
||||||
|
final List<Task> _tasks = [];
|
||||||
|
final List<String> _taskOrder = [];
|
||||||
|
|
||||||
|
List<Task> get orderedTasks {
|
||||||
|
final lookup = {for (final task in _tasks) task.id: task};
|
||||||
|
|
||||||
|
return _taskOrder.map((id) => lookup[id]!).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> reorderTask(int oldIndex, int newIndex) async {
|
||||||
|
final taskId = _taskOrder.removeAt(oldIndex);
|
||||||
|
_taskOrder.insert(newIndex, taskId);
|
||||||
|
_repository.updateTaskOrder(_taskOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> saveTask(Task task) async {
|
||||||
|
if (_tasks.contains(task)) {
|
||||||
|
_tasks.remove(task);
|
||||||
|
_tasks.add(task);
|
||||||
|
_repository.updateTask(task);
|
||||||
|
} else {
|
||||||
|
_tasks.add(task);
|
||||||
|
_taskOrder.add(task.id);
|
||||||
|
_repository.createTask(task);
|
||||||
|
_repository.updateTaskOrder(_taskOrder);
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteTask(Task task) async {
|
||||||
|
_tasks.remove(task);
|
||||||
|
_taskOrder.remove(task.id);
|
||||||
|
notifyListeners();
|
||||||
|
_repository.deleteTask(task);
|
||||||
|
_repository.updateTaskOrder(_taskOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadTasks() async {
|
||||||
|
_tasks.clear();
|
||||||
|
return _repository.loadTasks().then((value) => _tasks.addAll(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadTaskOrder() async {
|
||||||
|
_taskOrder.clear();
|
||||||
|
return _repository.loadTaskOrder().then(
|
||||||
|
(value) => _taskOrder.addAll(value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,5 @@
|
|||||||
String generateId() => DateTime.now().millisecondsSinceEpoch.toString();
|
String generateId() => DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
|
|
||||||
|
String getIsoDateString(DateTime dateTime) {
|
||||||
|
return dateTime.toIso8601String().substring(0, 10);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
String? timeValidator(String? value) {
|
||||||
|
if (value == null || value.isEmpty) return null;
|
||||||
|
|
||||||
|
if (RegExp(r'^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$').hasMatch(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return 'Not a valid time format';
|
||||||
|
}
|
||||||
|
|
||||||
|
String? dateTimeValidator(String? value) {
|
||||||
|
if (value == null || value.isEmpty) return null;
|
||||||
|
|
||||||
|
return DateTime.tryParse(value) != null ? null : 'Not a date format';
|
||||||
|
}
|
||||||
|
|
||||||
|
String? coordinatesValidator(String? value) {
|
||||||
|
if (value == null || value.isEmpty) return null;
|
||||||
|
|
||||||
|
if (RegExp(r'^\d+\.?\d*, *\d+\.?\d*$').hasMatch(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return 'Not a valid coordinate format';
|
||||||
|
}
|
||||||
|
|
||||||
|
String? notEmptyValidator(String? value) {
|
||||||
|
if (value != null && value.isNotEmpty) return null;
|
||||||
|
return 'Can\'t be empty';
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../app_theme.dart';
|
||||||
|
import '../../model/latlng.dart';
|
||||||
|
import '../../model/location.dart';
|
||||||
|
import '../../service/validators.dart';
|
||||||
|
|
||||||
|
class CreateLocationDialog extends StatefulWidget {
|
||||||
|
const CreateLocationDialog({super.key, this.initialLocation});
|
||||||
|
final Location? initialLocation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateLocationDialog> createState() => _CreateLocationDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateLocationDialogState extends State<CreateLocationDialog> {
|
||||||
|
final nameController = TextEditingController();
|
||||||
|
final addressController = TextEditingController();
|
||||||
|
final coordinatesController = TextEditingController();
|
||||||
|
final formKey = GlobalKey<FormState>(debugLabel: 'Create Location Form');
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
if (widget.initialLocation != null) {
|
||||||
|
nameController.text = widget.initialLocation!.name;
|
||||||
|
addressController.text = widget.initialLocation!.address;
|
||||||
|
coordinatesController.text = widget.initialLocation!.coordinates
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: onCancelPressed, child: Text('Cancel')),
|
||||||
|
TextButton(onPressed: onSavePressed, child: Text('Save')),
|
||||||
|
],
|
||||||
|
title: Text('Create Location'),
|
||||||
|
content: Form(
|
||||||
|
key: formKey,
|
||||||
|
child: Column(
|
||||||
|
spacing: AppTheme.formColumnSpacing,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
controller: nameController,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
decoration: InputDecoration(labelText: 'Name'),
|
||||||
|
validator: notEmptyValidator,
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
controller: addressController,
|
||||||
|
keyboardType: TextInputType.streetAddress,
|
||||||
|
decoration: InputDecoration(labelText: 'Address (optional)'),
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
controller: coordinatesController,
|
||||||
|
onFieldSubmitted: (_) => onSavePressed(),
|
||||||
|
keyboardType: TextInputType.numberWithOptions(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Coordinates',
|
||||||
|
hint: Text('25.5892, 50.5051662'),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
return notEmptyValidator(value) ?? coordinatesValidator(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCancelPressed() => Navigator.of(context).pop();
|
||||||
|
|
||||||
|
void onSavePressed() {
|
||||||
|
if (formKey.currentState!.validate()) {
|
||||||
|
Navigator.of(context).pop(
|
||||||
|
Location(
|
||||||
|
name: nameController.text,
|
||||||
|
coordinates: LatLng.fromString(coordinatesController.text),
|
||||||
|
address: addressController.text,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class TaskDismissible extends StatelessWidget {
|
||||||
|
const TaskDismissible({
|
||||||
|
required super.key,
|
||||||
|
this.onDismissedRight,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
final VoidCallback? onDismissedRight;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dismissible(
|
||||||
|
key: key!,
|
||||||
|
direction: DismissDirection.startToEnd,
|
||||||
|
background: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentGeometry.centerLeft,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
child: Icon(
|
||||||
|
Icons.delete,
|
||||||
|
color: Theme.of(context).colorScheme.onError,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onDismissed: onDismissed,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onDismissed(DismissDirection direction) {
|
||||||
|
if (direction == DismissDirection.startToEnd && onDismissedRight != null) {
|
||||||
|
onDismissedRight!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../service/tools.dart' show getIsoDateString;
|
||||||
|
import '../service/validators.dart';
|
||||||
|
|
||||||
|
class TimeSelector extends StatefulWidget {
|
||||||
|
const TimeSelector({
|
||||||
|
super.key,
|
||||||
|
this.initialDueDateTime,
|
||||||
|
this.nextFocusNode,
|
||||||
|
required this.dueDateController,
|
||||||
|
required this.dueTimeController,
|
||||||
|
this.formKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
final DateTime? initialDueDateTime;
|
||||||
|
final GlobalKey<FormState>? formKey;
|
||||||
|
final FocusNode? nextFocusNode;
|
||||||
|
final TextEditingController dueDateController;
|
||||||
|
final TextEditingController dueTimeController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TimeSelector> createState() => _TimeSelectorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TimeSelectorState extends State<TimeSelector> {
|
||||||
|
final dueDateFocusNode = FocusNode();
|
||||||
|
|
||||||
|
final dueTimeFocusNode = FocusNode();
|
||||||
|
|
||||||
|
bool isDueTimeEnabled = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
isDueTimeEnabled = widget.initialDueDateTime != null;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Flex(
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
flex: 3,
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: dueDateFocusNode,
|
||||||
|
controller: widget.dueDateController,
|
||||||
|
onChanged: maybeEnableDueTime,
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
isDueTimeEnabled
|
||||||
|
? dueDateFocusNode.nextFocus()
|
||||||
|
: widget.nextFocusNode?.requestFocus();
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
label: Text('Due Date'),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final result = await onOpenCalendarPickerPressed();
|
||||||
|
if (result != null) {
|
||||||
|
final dateString = getIsoDateString(result);
|
||||||
|
widget.dueDateController.text = dateString;
|
||||||
|
maybeEnableDueTime(dateString);
|
||||||
|
widget.formKey?.currentState?.validate();
|
||||||
|
dueTimeFocusNode.requestFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.calendar_month),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
validator: dateTimeValidator,
|
||||||
|
keyboardType: TextInputType.datetime,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(padding: EdgeInsetsGeometry.only(left: 10)),
|
||||||
|
Flexible(
|
||||||
|
flex: 2,
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: dueTimeFocusNode,
|
||||||
|
onFieldSubmitted: (_) => dueTimeFocusNode.nextFocus(),
|
||||||
|
controller: widget.dueTimeController,
|
||||||
|
enabled: isDueTimeEnabled,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
label: Text('Due Time'),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final result = await onOpenTimePickerPressed();
|
||||||
|
if (result != null && context.mounted) {
|
||||||
|
widget.dueTimeController.text = result.format(context);
|
||||||
|
widget.nextFocusNode?.requestFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.schedule),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
validator: timeValidator,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DateTime?> onOpenCalendarPickerPressed() {
|
||||||
|
return showDialog<DateTime?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => DatePickerDialog(
|
||||||
|
firstDate: DateTime(DateTime.now().year - 100),
|
||||||
|
lastDate: DateTime(DateTime.now().year + 100),
|
||||||
|
initialDate:
|
||||||
|
DateTime.tryParse(widget.dueDateController.text) ?? DateTime.now(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<TimeOfDay?> onOpenTimePickerPressed() {
|
||||||
|
return showDialog<TimeOfDay?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => TimePickerDialog(
|
||||||
|
initialTime: TimeOfDay.fromDateTime(
|
||||||
|
widget.initialDueDateTime ?? DateTime.now(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void maybeEnableDueTime(String value) {
|
||||||
|
if (value.isNotEmpty && dateTimeValidator(value) == null) {
|
||||||
|
setState(() {
|
||||||
|
isDueTimeEnabled = true;
|
||||||
|
});
|
||||||
|
} else if (isDueTimeEnabled) {
|
||||||
|
setState(() {
|
||||||
|
isDueTimeEnabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+134
-1
@@ -49,6 +49,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.3"
|
version: "1.3.3"
|
||||||
|
ffi:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: ffi
|
||||||
|
sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
|
file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file
|
||||||
|
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -67,6 +83,11 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -131,6 +152,102 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
|
path_provider_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_linux
|
||||||
|
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
path_provider_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_platform_interface
|
||||||
|
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.2"
|
||||||
|
path_provider_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_windows
|
||||||
|
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
|
platform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: platform
|
||||||
|
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.6"
|
||||||
|
plugin_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: plugin_platform_interface
|
||||||
|
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.8"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.5"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "93ae5884a9df5d3bb696825bceb3a17590754548b5d740eba51500afc8d088f5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.26"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.6"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.2"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.3"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -200,6 +317,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "15.2.0"
|
version: "15.2.0"
|
||||||
|
web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web
|
||||||
|
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
|
xdg_directories:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xdg_directories
|
||||||
|
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.12.1 <4.0.0"
|
dart: ">=3.12.1 <4.0.0"
|
||||||
flutter: ">=3.18.0-18.0.pre.54"
|
flutter: ">=3.44.0"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
shared_preferences: ^2.5.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user