Compare commits
13 Commits
358f3f12c1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 86397e0980 | |||
| ccfc60934a | |||
| 0d03f34371 | |||
| 8cc2b07b1f | |||
| 7db54712fa | |||
| 7e78bcba2c | |||
| 38cf792d09 | |||
| b3a0c33b9e | |||
| dd4533efd2 | |||
| 41a2435cc2 | |||
| cb74135c6c | |||
| 116992b3be | |||
| 27e7f008f0 |
@@ -39,3 +39,4 @@ yarn-error.*
|
||||
# generated native folders
|
||||
/ios
|
||||
/android
|
||||
MAP_STRATEGY.md
|
||||
|
||||
@@ -1,21 +1,663 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2026 Davide Scaini
|
||||
|
||||
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
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.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
Preamble
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<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 Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -95,12 +95,39 @@ npx expo run:ios --device
|
||||
|
||||
### Android — local release APK
|
||||
|
||||
The release build embeds the JS bundle, so it runs standalone without Metro.
|
||||
The default config signs with the debug keystore, which is fine for personal device testing.
|
||||
|
||||
```bash
|
||||
cd android
|
||||
./gradlew assembleRelease
|
||||
# Output: android/app/build/outputs/apk/release/app-release.apk
|
||||
```
|
||||
|
||||
**Install on a connected device via ADB:**
|
||||
|
||||
```bash
|
||||
# Add ADB to PATH (one-time, macOS)
|
||||
echo 'export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools"' >> ~/.zprofile
|
||||
source ~/.zprofile
|
||||
|
||||
# Install (device must have USB Debugging enabled)
|
||||
adb install -r app/build/outputs/apk/release/app-release.apk
|
||||
```
|
||||
|
||||
The `-r` flag reinstalls over any existing version on the device.
|
||||
|
||||
**Android Studio note:** If Gradle sync fails with `Cannot run program "node"`, Android Studio
|
||||
launched without Homebrew in its PATH. Fix by opening from the terminal:
|
||||
```bash
|
||||
open -a "Android Studio" android/
|
||||
```
|
||||
Or make it permanent (no sudo needed):
|
||||
```bash
|
||||
launchctl setenv PATH "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
||||
```
|
||||
Then fully quit and reopen Android Studio.
|
||||
|
||||
To build a release AAB (required for Play Store):
|
||||
|
||||
```bash
|
||||
@@ -108,7 +135,13 @@ To build a release AAB (required for Play Store):
|
||||
# Output: android/app/build/outputs/bundle/release/app-release.aab
|
||||
```
|
||||
|
||||
**Signing:** Create a keystore and configure `android/app/build.gradle` with your signing config before a production release. See [React Native signing docs](https://reactnative.dev/docs/signed-apk-android).
|
||||
**Production signing:** For Play Store or sharing with others, generate a proper keystore:
|
||||
```bash
|
||||
keytool -genkey -v -keystore android/app/bincio-rec.keystore \
|
||||
-alias bincio-rec -keyalg RSA -keysize 2048 -validity 10000
|
||||
```
|
||||
Then update `signingConfigs.release` in `android/app/build.gradle` to reference it.
|
||||
See [React Native signing docs](https://reactnative.dev/docs/signed-apk-android).
|
||||
|
||||
### iOS — local release archive
|
||||
|
||||
@@ -204,3 +237,7 @@ npx expo install <package-name>
|
||||
npx expo prebuild --clean # regenerates android/ and ios/
|
||||
cd ios && pod install && cd ..
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[AGPL v3](LICENSE) — see the `LICENSE` file for details.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "bincio-rec",
|
||||
"name": "Bincio Rec",
|
||||
"slug": "bincio-rec",
|
||||
"scheme": "bincio-rec",
|
||||
"version": "1.0.0",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
@@ -12,15 +13,16 @@
|
||||
"infoPlist": {
|
||||
"NSLocationWhenInUseUsageDescription": "bincio-rec uses your location to record your activity track.",
|
||||
"NSLocationAlwaysAndWhenInUseUsageDescription": "bincio-rec uses your location in the background to record your activity track.",
|
||||
"UIBackgroundModes": ["location"]
|
||||
"UIBackgroundModes": [
|
||||
"location"
|
||||
]
|
||||
}
|
||||
},
|
||||
"android": {
|
||||
"package": "com.bincio.rec",
|
||||
"adaptiveIcon": {
|
||||
"backgroundColor": "#111111",
|
||||
"backgroundColor": "#09090b",
|
||||
"foregroundImage": "./assets/android-icon-foreground.png",
|
||||
"backgroundImage": "./assets/android-icon-background.png",
|
||||
"monochromeImage": "./assets/android-icon-monochrome.png"
|
||||
},
|
||||
"predictiveBackGestureEnabled": false,
|
||||
@@ -39,7 +41,9 @@
|
||||
"web": {
|
||||
"favicon": "./assets/favicon.png"
|
||||
},
|
||||
"ignorePaths": ["CLAUDE.md"],
|
||||
"ignorePaths": [
|
||||
"CLAUDE.md"
|
||||
],
|
||||
"plugins": [
|
||||
"expo-sqlite",
|
||||
[
|
||||
@@ -56,7 +60,8 @@
|
||||
"icon": "./assets/icon.png",
|
||||
"color": "#3b82f6"
|
||||
}
|
||||
]
|
||||
],
|
||||
"expo-web-browser"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 384 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -14,9 +14,10 @@
|
||||
"@react-navigation/native": "^7.2.5",
|
||||
"@react-navigation/native-stack": "^7.16.0",
|
||||
"expo": "~56.0.8",
|
||||
"expo-av": "^16.0.8",
|
||||
"expo-auth-session": "~56.0.13",
|
||||
"expo-crypto": "^56.0.4",
|
||||
"expo-file-system": "~56.0.7",
|
||||
"expo-intent-launcher": "~56.0.4",
|
||||
"expo-keep-awake": "~56.0.3",
|
||||
"expo-location": "~56.0.15",
|
||||
"expo-notifications": "~56.0.15",
|
||||
@@ -24,12 +25,14 @@
|
||||
"expo-sqlite": "~56.0.4",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"expo-task-manager": "~56.0.16",
|
||||
"expo-web-browser": "~56.0.5",
|
||||
"react": "19.2.3",
|
||||
"react-native": "0.85.3",
|
||||
"react-native-ble-plx": "^3.5.1",
|
||||
"react-native-gesture-handler": "~2.31.1",
|
||||
"react-native-safe-area-context": "~5.7.0",
|
||||
"react-native-screens": "4.25.2",
|
||||
"react-native-svg": "15.15.4",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -2441,6 +2444,12 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/bplist-creator": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz",
|
||||
@@ -2842,6 +2851,56 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
|
||||
"integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"nth-check": "^2.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/css-tree": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz",
|
||||
"integrity": "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mdn-data": "2.0.14",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/css-tree/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/css-what": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz",
|
||||
"integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
@@ -2929,6 +2988,61 @@
|
||||
"integrity": "sha512-AmGyK9WpNf06WeP5TjHZq/wNzP76OuEeaiTlKr9E/EEelYLczywUKoqRz+DPRq/ErssjT4lU+/W7wzJW+7K/ZA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"entities": "^4.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domelementtype": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
|
||||
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/domhandler": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
|
||||
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
|
||||
"integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
@@ -2956,6 +3070,18 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/error-stack-parser": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz",
|
||||
@@ -3090,21 +3216,22 @@
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-av": {
|
||||
"version": "16.0.8",
|
||||
"resolved": "https://registry.npmjs.org/expo-av/-/expo-av-16.0.8.tgz",
|
||||
"integrity": "sha512-cmVPftGR/ca7XBgs7R6ky36lF3OC0/MM/lpgX/yXqfv0jASTsh7AYX9JxHCwFmF+Z6JEB1vne9FDx4GiLcGreQ==",
|
||||
"node_modules/expo-auth-session": {
|
||||
"version": "56.0.13",
|
||||
"resolved": "https://registry.npmjs.org/expo-auth-session/-/expo-auth-session-56.0.13.tgz",
|
||||
"integrity": "sha512-LR8Suq8BHKRFBUcAKTMmZufCcDcr0sQa8rIYit1r7kshrqAy9glIUU4aqHt8tflW/ISN0x1vU+HU8AQaackM0A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-web": "*"
|
||||
"dependencies": {
|
||||
"expo-application": "~56.0.3",
|
||||
"expo-constants": "~56.0.16",
|
||||
"expo-crypto": "~56.0.4",
|
||||
"expo-linking": "~56.0.13",
|
||||
"expo-web-browser": "~56.0.5",
|
||||
"invariant": "^2.2.4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-native-web": {
|
||||
"optional": true
|
||||
}
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-constants": {
|
||||
@@ -3139,6 +3266,15 @@
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-intent-launcher": {
|
||||
"version": "56.0.4",
|
||||
"resolved": "https://registry.npmjs.org/expo-intent-launcher/-/expo-intent-launcher-56.0.4.tgz",
|
||||
"integrity": "sha512-ZqRMuPunNSucK9kRbtX+I8bD/OhY0moGNnHKHCWx//1BZ+HyKBCVw6OX12gWHjowz1AhcSVeAasYt48Y+tXPwQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-keep-awake": {
|
||||
"version": "56.0.3",
|
||||
"resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-56.0.3.tgz",
|
||||
@@ -3149,6 +3285,20 @@
|
||||
"react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-linking": {
|
||||
"version": "56.0.13",
|
||||
"resolved": "https://registry.npmjs.org/expo-linking/-/expo-linking-56.0.13.tgz",
|
||||
"integrity": "sha512-38YrpTh6xdiDxmYSDIUffDqev1hIcEggw2fZ3IZhNp2DVLF1xvqsbO6hJD1fuBKN8P34B3Ggc9Yy26fkqdfCOA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"expo-constants": "~56.0.16",
|
||||
"invariant": "^2.2.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-location": {
|
||||
"version": "56.0.15",
|
||||
"resolved": "https://registry.npmjs.org/expo-location/-/expo-location-56.0.15.tgz",
|
||||
@@ -3287,6 +3437,16 @@
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-web-browser": {
|
||||
"version": "56.0.5",
|
||||
"resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-56.0.5.tgz",
|
||||
"integrity": "sha512-kaN+wcR5lHwPCH1IgrU1XyPUQvBRzdF1TMp65uAF9iUCyipqYnmrvV87eqAmrdkFFopWVgU7FcxPu1UZw+gvUQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo/node_modules/@expo/cli": {
|
||||
"version": "56.1.13",
|
||||
"resolved": "https://registry.npmjs.org/@expo/cli/-/cli-56.1.13.tgz",
|
||||
@@ -4681,6 +4841,12 @@
|
||||
"integrity": "sha512-ocnPZQLNpvbedwTy9kNrQEsknEfgvcLMvOtz3sFeWApDq1MXH1TqkCIx58xlpESsfwQOnuBO9beyQuNGzVvuhQ==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/mdn-data": {
|
||||
"version": "2.0.14",
|
||||
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
|
||||
"integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==",
|
||||
"license": "CC0-1.0"
|
||||
},
|
||||
"node_modules/memoize-one": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
|
||||
@@ -5189,6 +5355,18 @@
|
||||
"node": "^16.14.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nth-check": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
|
||||
"integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/nth-check?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/nullthrows": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nullthrows/-/nullthrows-1.1.1.tgz",
|
||||
@@ -5761,6 +5939,21 @@
|
||||
"react-native": ">=0.82.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-svg": {
|
||||
"version": "15.15.4",
|
||||
"resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-15.15.4.tgz",
|
||||
"integrity": "sha512-boT/vIRgj6zZKBpfTPJJiYWMbZE9duBMOwPK6kCSTgxsS947IFMOq9OgIFkpWZTB7t229H24pDRkh3W9ZK/J1A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-select": "^5.1.0",
|
||||
"css-tree": "^1.1.3",
|
||||
"warn-once": "0.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native/node_modules/commander": {
|
||||
"version": "12.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
"@react-navigation/native": "^7.2.5",
|
||||
"@react-navigation/native-stack": "^7.16.0",
|
||||
"expo": "~56.0.8",
|
||||
"expo-av": "^16.0.8",
|
||||
"expo-auth-session": "~56.0.13",
|
||||
"expo-crypto": "^56.0.4",
|
||||
"expo-file-system": "~56.0.7",
|
||||
"expo-intent-launcher": "~56.0.4",
|
||||
"expo-keep-awake": "~56.0.3",
|
||||
"expo-location": "~56.0.15",
|
||||
"expo-notifications": "~56.0.15",
|
||||
@@ -19,12 +20,14 @@
|
||||
"expo-sqlite": "~56.0.4",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"expo-task-manager": "~56.0.16",
|
||||
"expo-web-browser": "~56.0.5",
|
||||
"react": "19.2.3",
|
||||
"react-native": "0.85.3",
|
||||
"react-native-ble-plx": "^3.5.1",
|
||||
"react-native-gesture-handler": "~2.31.1",
|
||||
"react-native-safe-area-context": "~5.7.0",
|
||||
"react-native-screens": "4.25.2",
|
||||
"react-native-svg": "15.15.4",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Generates all icon assets for bincio-rec.
|
||||
# Requires ImageMagick 7 (magick).
|
||||
#
|
||||
# Centering strategy: both letters are rendered with -gravity Center.
|
||||
# Each letter's centre is offset ±HALF pixels from the canvas centre,
|
||||
# where HALF = (letter_width + gap) / 2. This gives mathematically
|
||||
# correct horizontal & vertical centering regardless of font metrics.
|
||||
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
FONT="$HOME/Library/Fonts/NotoSans-Bold.ttf"
|
||||
BG="#09090b"
|
||||
WHITE="#ffffff"
|
||||
RED="#ef4444"
|
||||
|
||||
# render_br CANVAS BG SIZE HALF OUT
|
||||
# HALF = how many pixels each letter centre is offset from canvas centre.
|
||||
render_br() {
|
||||
local CANVAS=$1 BG_COL=$2 SIZE=$3 HALF=$4 OUT=$5
|
||||
magick -size "${CANVAS}x${CANVAS}" xc:"$BG_COL" \
|
||||
-font "$FONT" -pointsize "$SIZE" -gravity Center \
|
||||
-fill "$WHITE" -annotate "-${HALF}+0" 'B' \
|
||||
-fill "$RED" -annotate "+${HALF}+0" 'R' \
|
||||
"$OUT"
|
||||
}
|
||||
|
||||
# render_br_transparent CANVAS SIZE HALF B_FILL R_FILL OUT
|
||||
render_br_transparent() {
|
||||
local CANVAS=$1 SIZE=$2 HALF=$3 B_FILL=$4 R_FILL=$5 OUT=$6
|
||||
magick -size "${CANVAS}x${CANVAS}" xc:none \
|
||||
-font "$FONT" -pointsize "$SIZE" -gravity Center \
|
||||
-fill "$B_FILL" -annotate "-${HALF}+0" 'B' \
|
||||
-fill "$R_FILL" -annotate "+${HALF}+0" 'R' \
|
||||
"$OUT"
|
||||
}
|
||||
|
||||
# At 480 pt NotoSans-Bold, each capital is ~320 px wide.
|
||||
# Gap between inner edges: 60 px. Inter-centre: 320 + 60 = 380 → HALF = 190.
|
||||
render_br 1024 "$BG" 480 190 assets/icon.png
|
||||
|
||||
# Adaptive foreground (transparent, fits the 66% safe zone).
|
||||
# 320 pt → letter ~215 px wide. Gap 50 px → HALF = 132.
|
||||
render_br_transparent 1024 320 132 "$WHITE" "$RED" assets/android-icon-foreground.png
|
||||
render_br_transparent 1024 320 132 "$WHITE" "$WHITE" assets/android-icon-monochrome.png
|
||||
|
||||
# Splash 512×512 — 240 pt → letter ~160 px wide. Gap 36 px → HALF = 98.
|
||||
render_br 512 "$BG" 240 98 assets/splash-icon.png
|
||||
|
||||
echo "✓ Icon assets generated in assets/"
|
||||
@@ -1,60 +1,73 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { PALETTES, FONT_SCALE, type PaletteKey, type FontSizeKey } from './theme';
|
||||
import { MAP_STYLES, type MapTileStyle } from './mapStyles';
|
||||
|
||||
export type MapOrientation = 'north' | 'compass' | 'course';
|
||||
|
||||
interface ThemeValue {
|
||||
accent: string;
|
||||
accentDim: string;
|
||||
palette: PaletteKey;
|
||||
setPalette: (p: PaletteKey) => void;
|
||||
fontSize: FontSizeKey;
|
||||
setFontSize: (s: FontSizeKey) => void;
|
||||
boldLabels: boolean;
|
||||
setBoldLabels: (b: boolean) => void;
|
||||
scale: number;
|
||||
accent: string;
|
||||
accentDim: string;
|
||||
palette: PaletteKey;
|
||||
setPalette: (p: PaletteKey) => void;
|
||||
fontSize: FontSizeKey;
|
||||
setFontSize: (s: FontSizeKey) => void;
|
||||
boldLabels: boolean;
|
||||
setBoldLabels: (b: boolean) => void;
|
||||
scale: number;
|
||||
mapOrientation: MapOrientation;
|
||||
setMapOrientation: (o: MapOrientation) => void;
|
||||
mapTileStyle: MapTileStyle;
|
||||
setMapTileStyle: (s: MapTileStyle) => void;
|
||||
}
|
||||
|
||||
const MAP_ORIENTATIONS: MapOrientation[] = ['north', 'compass', 'course'];
|
||||
|
||||
const ThemeContext = createContext<ThemeValue>({
|
||||
...PALETTES.default,
|
||||
palette: 'default',
|
||||
setPalette: () => {},
|
||||
fontSize: 'medium',
|
||||
setFontSize: () => {},
|
||||
boldLabels: false,
|
||||
setBoldLabels: () => {},
|
||||
scale: 1,
|
||||
palette: 'default',
|
||||
setPalette: () => {},
|
||||
fontSize: 'medium',
|
||||
setFontSize: () => {},
|
||||
boldLabels: false,
|
||||
setBoldLabels: () => {},
|
||||
scale: 1,
|
||||
mapOrientation: 'north',
|
||||
setMapOrientation: () => {},
|
||||
mapTileStyle: 'liberty',
|
||||
setMapTileStyle: () => {},
|
||||
});
|
||||
|
||||
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
const [palette, setPaletteState] = useState<PaletteKey>('default');
|
||||
const [fontSize, setFontSizeState] = useState<FontSizeKey>('medium');
|
||||
const [boldLabels, setBoldLabelsState] = useState(false);
|
||||
const [palette, setPaletteState] = useState<PaletteKey>('default');
|
||||
const [fontSize, setFontSizeState] = useState<FontSizeKey>('medium');
|
||||
const [boldLabels, setBoldLabelsState] = useState(false);
|
||||
const [mapOrientation, setMapOrientationState] = useState<MapOrientation>('north');
|
||||
const [mapTileStyle, setMapTileStyleState] = useState<MapTileStyle>('liberty');
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const [p, f, b] = await Promise.all([
|
||||
const [p, f, b, m, t] = await Promise.all([
|
||||
AsyncStorage.getItem('themePalette'),
|
||||
AsyncStorage.getItem('themeFontSize'),
|
||||
AsyncStorage.getItem('themeBoldLabels'),
|
||||
AsyncStorage.getItem('mapOrientation'),
|
||||
AsyncStorage.getItem('mapTileStyle'),
|
||||
]);
|
||||
if (p && p in PALETTES) setPaletteState(p as PaletteKey);
|
||||
if (f && f in FONT_SCALE) setFontSizeState(f as FontSizeKey);
|
||||
if (b !== null) setBoldLabelsState(b === 'true');
|
||||
if (p && p in PALETTES) setPaletteState(p as PaletteKey);
|
||||
if (f && f in FONT_SCALE) setFontSizeState(f as FontSizeKey);
|
||||
if (b !== null) setBoldLabelsState(b === 'true');
|
||||
if (m && MAP_ORIENTATIONS.includes(m as MapOrientation))
|
||||
setMapOrientationState(m as MapOrientation);
|
||||
if (t && t in MAP_STYLES) setMapTileStyleState(t as MapTileStyle);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
function setPalette(p: PaletteKey) {
|
||||
setPaletteState(p);
|
||||
AsyncStorage.setItem('themePalette', p);
|
||||
}
|
||||
function setFontSize(f: FontSizeKey) {
|
||||
setFontSizeState(f);
|
||||
AsyncStorage.setItem('themeFontSize', f);
|
||||
}
|
||||
function setBoldLabels(b: boolean) {
|
||||
setBoldLabelsState(b);
|
||||
AsyncStorage.setItem('themeBoldLabels', String(b));
|
||||
}
|
||||
function setPalette(p: PaletteKey) { setPaletteState(p); AsyncStorage.setItem('themePalette', p); }
|
||||
function setFontSize(f: FontSizeKey) { setFontSizeState(f); AsyncStorage.setItem('themeFontSize', f); }
|
||||
function setBoldLabels(b: boolean) { setBoldLabelsState(b); AsyncStorage.setItem('themeBoldLabels', String(b)); }
|
||||
function setMapOrientation(o: MapOrientation) { setMapOrientationState(o); AsyncStorage.setItem('mapOrientation', o); }
|
||||
function setMapTileStyle(s: MapTileStyle) { setMapTileStyleState(s); AsyncStorage.setItem('mapTileStyle', s); }
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{
|
||||
@@ -64,6 +77,8 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
fontSize, setFontSize,
|
||||
boldLabels, setBoldLabels,
|
||||
scale: FONT_SCALE[fontSize],
|
||||
mapOrientation, setMapOrientation,
|
||||
mapTileStyle, setMapTileStyle,
|
||||
}}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import type { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
|
||||
|
||||
export type MapTileStyle = 'liberty' | 'cyclosm' | 'topo' | 'satellite' | 'osm';
|
||||
|
||||
export interface MapStyleDef {
|
||||
label: string;
|
||||
description: string;
|
||||
style: string | StyleSpecification;
|
||||
}
|
||||
|
||||
function rasterStyle(tiles: string[], attribution: string): StyleSpecification {
|
||||
return {
|
||||
version: 8,
|
||||
sources: {
|
||||
base: { type: 'raster', tiles, tileSize: 256, attribution },
|
||||
},
|
||||
layers: [{ id: 'base', type: 'raster', source: 'base' }],
|
||||
} as StyleSpecification;
|
||||
}
|
||||
|
||||
export const MAP_STYLES: Record<MapTileStyle, MapStyleDef> = {
|
||||
liberty: {
|
||||
label: 'Liberty',
|
||||
description: 'Vector street map',
|
||||
style: 'https://tiles.openfreemap.org/styles/liberty',
|
||||
},
|
||||
cyclosm: {
|
||||
label: 'CyclOSM',
|
||||
description: 'Cycling infrastructure',
|
||||
style: rasterStyle(
|
||||
[
|
||||
'https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
|
||||
'https://b.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
|
||||
'https://c.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
|
||||
],
|
||||
'© OpenStreetMap contributors, CyclOSM',
|
||||
),
|
||||
},
|
||||
topo: {
|
||||
label: 'Topo',
|
||||
description: 'Elevation & terrain',
|
||||
style: rasterStyle(
|
||||
[
|
||||
'https://a.tile.opentopomap.org/{z}/{x}/{y}.png',
|
||||
'https://b.tile.opentopomap.org/{z}/{x}/{y}.png',
|
||||
'https://c.tile.opentopomap.org/{z}/{x}/{y}.png',
|
||||
],
|
||||
'© OpenStreetMap contributors, OpenTopoMap',
|
||||
),
|
||||
},
|
||||
satellite: {
|
||||
label: 'Satellite',
|
||||
description: 'Esri World Imagery',
|
||||
style: rasterStyle(
|
||||
['https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'],
|
||||
'© Esri, Maxar, Earthstar Geographics',
|
||||
),
|
||||
},
|
||||
osm: {
|
||||
label: 'OSM',
|
||||
description: 'Standard street map',
|
||||
style: rasterStyle(
|
||||
['https://tile.openstreetmap.org/{z}/{x}/{y}.png'],
|
||||
'© OpenStreetMap contributors',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const MAP_TILE_STYLE_ORDER: MapTileStyle[] = ['liberty', 'cyclosm', 'topo', 'satellite', 'osm'];
|
||||
@@ -4,11 +4,12 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
||||
import { Text } from 'react-native';
|
||||
|
||||
import { RecordingScreen } from '../screens/RecordingScreen';
|
||||
import { PostRecordingScreen } from '../screens/PostRecordingScreen';
|
||||
import { SensorPairingScreen } from '../screens/SensorPairingScreen';
|
||||
import { SavedRecordingsScreen } from '../screens/SavedRecordingsScreen';
|
||||
import { SettingsScreen } from '../screens/SettingsScreen';
|
||||
import { RecordingScreen } from '../screens/RecordingScreen';
|
||||
import { PostRecordingScreen } from '../screens/PostRecordingScreen';
|
||||
import { SensorPairingScreen } from '../screens/SensorPairingScreen';
|
||||
import { SavedRecordingsScreen } from '../screens/SavedRecordingsScreen';
|
||||
import { SettingsScreen } from '../screens/SettingsScreen';
|
||||
import { ActivityDetailScreen } from '../screens/ActivityDetailScreen';
|
||||
import { RootStackParamList, TabParamList } from '../types';
|
||||
import { colors } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
@@ -55,8 +56,9 @@ export function AppNavigator() {
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="Tabs" component={Tabs} options={{ headerShown: false }} />
|
||||
<Stack.Screen name="PostRecording" component={PostRecordingScreen} options={{ title: 'Save Recording', presentation: 'modal' }} />
|
||||
<Stack.Screen name="SensorPairing" component={SensorPairingScreen} options={{ title: 'Sensors', presentation: 'modal' }} />
|
||||
<Stack.Screen name="PostRecording" component={PostRecordingScreen} options={{ title: 'Save Recording', presentation: 'modal' }} />
|
||||
<Stack.Screen name="SensorPairing" component={SensorPairingScreen} options={{ title: 'Sensors', presentation: 'modal' }} />
|
||||
<Stack.Screen name="ActivityDetail" component={ActivityDetailScreen} options={{ title: '' }} />
|
||||
</Stack.Navigator>
|
||||
</NavigationContainer>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
View, Text, StyleSheet, ActivityIndicator, ScrollView,
|
||||
Modal, TextInput, TouchableOpacity, Alert,
|
||||
} from 'react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { useRoute, RouteProp, useNavigation } from '@react-navigation/native';
|
||||
import { Map, Camera, GeoJSONSource, Layer } from '@maplibre/maplibre-react-native';
|
||||
import type { LineLayerStyle } from '@maplibre/maplibre-react-native';
|
||||
import { parseGpxFile } from '../services/gpx';
|
||||
import { updateRecording } from '../services/db';
|
||||
import { TrackPoint, RootStackParamList, SavedRecording } from '../types';
|
||||
import {
|
||||
ALL_SPORTS, SPORT_ICONS, SPORT_LABELS, SPORT_SUBTYPES, SUB_SPORT_LABELS,
|
||||
type Sport, type SubSport,
|
||||
} from '../sports';
|
||||
import { colors } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
import { MAP_STYLES } from '../mapStyles';
|
||||
|
||||
type Route = RouteProp<RootStackParamList, 'ActivityDetail'>;
|
||||
|
||||
// ── Stats helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
interface Stats {
|
||||
elevationGainM: number;
|
||||
avgHr: number | null;
|
||||
avgPower: number | null;
|
||||
avgCadence: number | null;
|
||||
}
|
||||
|
||||
function computeStats(points: TrackPoint[]): Stats {
|
||||
let elevationGainM = 0;
|
||||
const hrVals: number[] = [], powerVals: number[] = [], cadVals: number[] = [];
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
const gain = points[i].ele - points[i - 1].ele;
|
||||
if (gain > 0) elevationGainM += gain;
|
||||
}
|
||||
for (const p of points) {
|
||||
if (p.hr != null) hrVals.push(p.hr);
|
||||
if (p.power != null) powerVals.push(p.power);
|
||||
if (p.cad != null) cadVals.push(p.cad);
|
||||
}
|
||||
const avg = (a: number[]) => a.length ? Math.round(a.reduce((s, v) => s + v, 0) / a.length) : null;
|
||||
return { elevationGainM, avgHr: avg(hrVals), avgPower: avg(powerVals), avgCadence: avg(cadVals) };
|
||||
}
|
||||
|
||||
function formatDuration(secs: number) {
|
||||
const h = Math.floor(secs / 3600).toString().padStart(2, '0');
|
||||
const m = Math.floor((secs % 3600) / 60).toString().padStart(2, '00');
|
||||
const s = (secs % 60).toString().padStart(2, '0');
|
||||
return `${h}:${m}:${s}`;
|
||||
}
|
||||
|
||||
// ── Screen ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export function ActivityDetailScreen() {
|
||||
const nav = useNavigation();
|
||||
const { accent, accentDim, mapTileStyle } = useTheme();
|
||||
const mapStyle = MAP_STYLES[mapTileStyle].style;
|
||||
const insets = useSafeAreaInsets();
|
||||
const route = useRoute<Route>();
|
||||
|
||||
const [rec, setRec] = useState<SavedRecording>(route.params.recording);
|
||||
const [points, setPoints] = useState<TrackPoint[] | null>(null);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
|
||||
// Edit modal state
|
||||
const [editVisible, setEditVisible] = useState(false);
|
||||
const [editTitle, setEditTitle] = useState(rec.title);
|
||||
const [editSport, setEditSport] = useState<Sport>(rec.sport as Sport);
|
||||
const [editSubSport, setEditSubSport] = useState<SubSport | null>(rec.subSport as SubSport | null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
// Header "Edit" button
|
||||
useLayoutEffect(() => {
|
||||
nav.setOptions({
|
||||
headerTitle: rec.title,
|
||||
headerRight: () => (
|
||||
<TouchableOpacity onPress={() => setEditVisible(true)} style={{ marginRight: 16 }}>
|
||||
<Text style={{ color: accent, fontSize: 15, fontWeight: '600' }}>Edit</Text>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
});
|
||||
}, [nav, rec.title, accent]);
|
||||
|
||||
useEffect(() => {
|
||||
parseGpxFile(rec.filePath)
|
||||
.then(setPoints)
|
||||
.catch((e) => setLoadError(e?.message ?? 'Failed to load track'));
|
||||
}, [rec.filePath]);
|
||||
|
||||
const trackLineStyle = useMemo<LineLayerStyle>(() => ({
|
||||
lineColor: accent, lineWidth: 3, lineJoin: 'round', lineCap: 'round',
|
||||
}), [accent]);
|
||||
|
||||
const trackGeoJSON = useMemo<GeoJSON.Feature<GeoJSON.LineString> | null>(() => {
|
||||
if (!points || points.length < 2) return null;
|
||||
return {
|
||||
type: 'Feature',
|
||||
geometry: { type: 'LineString', coordinates: points.map((p) => [p.lon, p.lat]) },
|
||||
properties: {},
|
||||
};
|
||||
}, [points]);
|
||||
|
||||
const bounds = useMemo(() => {
|
||||
if (!points || points.length === 0) return null;
|
||||
const pad = 0.001;
|
||||
return [
|
||||
Math.min(...points.map((p) => p.lon)) - pad,
|
||||
Math.min(...points.map((p) => p.lat)) - pad,
|
||||
Math.max(...points.map((p) => p.lon)) + pad,
|
||||
Math.max(...points.map((p) => p.lat)) + pad,
|
||||
] as [number, number, number, number];
|
||||
}, [points]);
|
||||
|
||||
const stats = useMemo(() => points ? computeStats(points) : null, [points]);
|
||||
|
||||
const avgSpeedKph = rec.durationSeconds > 0
|
||||
? (rec.distanceMeters / 1000) / (rec.durationSeconds / 3600) : 0;
|
||||
|
||||
const sportSummary = [
|
||||
SPORT_ICONS[rec.sport as Sport] ?? '⚡',
|
||||
SPORT_LABELS[rec.sport as Sport] ?? rec.sport,
|
||||
rec.subSport ? (SUB_SPORT_LABELS[rec.subSport as SubSport] ?? rec.subSport) : null,
|
||||
].filter(Boolean).join(' · ');
|
||||
|
||||
// ── Edit handlers ──────────────────────────────────────────────────────────
|
||||
|
||||
function handleEditSport(s: Sport) { setEditSport(s); setEditSubSport(null); }
|
||||
|
||||
async function handleSave() {
|
||||
if (!editTitle.trim()) { Alert.alert('Title required'); return; }
|
||||
setSaving(true);
|
||||
try {
|
||||
await updateRecording(rec.id, { title: editTitle.trim(), sport: editSport, subSport: editSubSport });
|
||||
setRec((prev) => ({ ...prev, title: editTitle.trim(), sport: editSport, subSport: editSubSport }));
|
||||
setEditVisible(false);
|
||||
} catch (e: any) {
|
||||
Alert.alert('Save failed', e?.message ?? 'Unknown error');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
function handleCancelEdit() {
|
||||
// Reset edit fields to current rec values
|
||||
setEditTitle(rec.title);
|
||||
setEditSport(rec.sport as Sport);
|
||||
setEditSubSport(rec.subSport as SubSport | null);
|
||||
setEditVisible(false);
|
||||
}
|
||||
|
||||
const editSubtypes = SPORT_SUBTYPES[editSport] ?? [];
|
||||
|
||||
// ── Render ─────────────────────────────────────────────────────────────────
|
||||
|
||||
if (loadError) {
|
||||
return <View style={styles.center}><Text style={styles.errorText}>{loadError}</Text></View>;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{/* Map */}
|
||||
<View style={styles.mapArea}>
|
||||
{points === null
|
||||
? <View style={styles.center}><ActivityIndicator color={accent} /></View>
|
||||
: (
|
||||
<Map mapStyle={mapStyle} style={StyleSheet.absoluteFill} logo={false} attribution={false}>
|
||||
{bounds && (
|
||||
<Camera
|
||||
initialViewState={{ bounds, padding: { top: 32, bottom: 32, left: 32, right: 32 } }}
|
||||
/>
|
||||
)}
|
||||
{trackGeoJSON && (
|
||||
<GeoJSONSource id="track" data={trackGeoJSON}>
|
||||
<Layer id="track-line" type="line" style={trackLineStyle} />
|
||||
</GeoJSONSource>
|
||||
)}
|
||||
</Map>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{/* Stats */}
|
||||
<ScrollView style={styles.statsScroll} contentContainerStyle={styles.statsContent}>
|
||||
<Text style={styles.sportSummary}>{sportSummary}</Text>
|
||||
<Text style={styles.date}>{new Date(rec.date).toLocaleString()}</Text>
|
||||
|
||||
<View style={styles.grid}>
|
||||
<StatBox label="Duration" value={formatDuration(rec.durationSeconds)} />
|
||||
<StatBox label="Distance" value={`${(rec.distanceMeters / 1000).toFixed(2)} km`} />
|
||||
<StatBox label="Avg Speed" value={`${avgSpeedKph.toFixed(1)} km/h`} />
|
||||
<StatBox label="Elevation" value={stats ? `+${stats.elevationGainM.toFixed(0)} m` : '…'} />
|
||||
<StatBox label="Avg HR" value={stats?.avgHr != null ? `${stats.avgHr} bpm` : '—'} />
|
||||
<StatBox label="Avg Power" value={stats?.avgPower != null ? `${stats.avgPower} W` : '—'} />
|
||||
<StatBox label="Avg Cadence" value={stats?.avgCadence != null ? `${stats.avgCadence} rpm` : '—'} />
|
||||
<StatBox label="Points" value={points != null ? `${points.length}` : '…'} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
{/* ── Edit modal ── */}
|
||||
<Modal visible={editVisible} animationType="slide" onRequestClose={handleCancelEdit}>
|
||||
<View style={[styles.editContainer, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
|
||||
<View style={styles.editHeader}>
|
||||
<TouchableOpacity onPress={handleCancelEdit}>
|
||||
<Text style={styles.editCancel}>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
<Text style={styles.editHeading}>Edit activity</Text>
|
||||
<TouchableOpacity onPress={handleSave} disabled={saving}>
|
||||
<Text style={[styles.editSave, { color: accent }, saving && { opacity: 0.5 }]}>
|
||||
{saving ? 'Saving…' : 'Save'}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<ScrollView contentContainerStyle={styles.editContent}>
|
||||
<Text style={styles.editSectionLabel}>Title</Text>
|
||||
<TextInput
|
||||
style={styles.editInput}
|
||||
value={editTitle}
|
||||
onChangeText={setEditTitle}
|
||||
placeholder="Activity title"
|
||||
placeholderTextColor={colors.placeholder}
|
||||
autoCorrect={false}
|
||||
/>
|
||||
|
||||
<Text style={styles.editSectionLabel}>Activity type</Text>
|
||||
<View style={styles.sportGrid}>
|
||||
{ALL_SPORTS.map((s) => {
|
||||
const active = editSport === s;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={s}
|
||||
style={[styles.sportPill, active && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
onPress={() => handleEditSport(s)}
|
||||
>
|
||||
<Text style={styles.sportIcon}>{SPORT_ICONS[s]}</Text>
|
||||
<Text style={[styles.sportLabel, active && { color: accent }]}>{SPORT_LABELS[s]}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
{editSubtypes.length > 0 && (
|
||||
<>
|
||||
<Text style={styles.editSectionLabel}>Subtype</Text>
|
||||
<View style={styles.subRow}>
|
||||
{editSubtypes.map((sub) => {
|
||||
const active = editSubSport === sub;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={sub}
|
||||
style={[styles.subPill, active && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
onPress={() => setEditSubSport(active ? null : sub)}
|
||||
>
|
||||
<Text style={[styles.subLabel, active && { color: accent }]}>{SUB_SPORT_LABELS[sub]}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</Modal>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function StatBox({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<View style={styles.statBox}>
|
||||
<Text style={styles.statLabel}>{label}</Text>
|
||||
<Text style={styles.statValue}>{value}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
center: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: colors.bg },
|
||||
errorText: { color: colors.error, fontSize: 14 },
|
||||
mapArea: { flex: 1 },
|
||||
statsScroll: { maxHeight: 260, borderTopWidth: 1, borderTopColor: colors.border },
|
||||
statsContent: { padding: 16, gap: 10 },
|
||||
sportSummary: { color: colors.text, fontSize: 15, fontWeight: '600' },
|
||||
date: { color: colors.textMuted, fontSize: 12 },
|
||||
grid: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
statBox: { width: '47%', backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, borderRadius: 10, padding: 12 },
|
||||
statLabel: { color: colors.textMuted, fontSize: 10, textTransform: 'uppercase', letterSpacing: 0.5 },
|
||||
statValue: { color: colors.text, fontSize: 18, fontWeight: '600', marginTop: 4 },
|
||||
// Edit modal
|
||||
editContainer: { flex: 1, backgroundColor: colors.bg },
|
||||
editHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: 16, borderBottomWidth: 1, borderBottomColor: colors.border },
|
||||
editHeading: { color: colors.text, fontSize: 16, fontWeight: '700' },
|
||||
editCancel: { color: colors.textSub, fontSize: 15 },
|
||||
editSave: { fontSize: 15, fontWeight: '700' },
|
||||
editContent: { padding: 16, gap: 12 },
|
||||
editSectionLabel: { color: colors.textMuted, fontSize: 11, textTransform: 'uppercase', letterSpacing: 0.8 },
|
||||
editInput: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, color: colors.text, borderRadius: 10, padding: 14, fontSize: 16 },
|
||||
sportGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
sportPill: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingVertical: 9, paddingHorizontal: 14, borderRadius: 20, borderWidth: 1, borderColor: colors.borderStrong, backgroundColor: colors.surface },
|
||||
sportIcon: { fontSize: 16 },
|
||||
sportLabel: { color: colors.textSub, fontSize: 13, fontWeight: '500' },
|
||||
subRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
subPill: { paddingVertical: 7, paddingHorizontal: 14, borderRadius: 20, borderWidth: 1, borderColor: colors.borderStrong, backgroundColor: colors.surface },
|
||||
subLabel: { color: colors.textSub, fontSize: 13, fontWeight: '500' },
|
||||
});
|
||||
@@ -7,17 +7,32 @@ import { insertRecording } from '../services/db';
|
||||
import { SavedRecording } from '../types';
|
||||
import { randomUUID } from 'expo-crypto';
|
||||
import { colors } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
import {
|
||||
ALL_SPORTS, SPORT_ICONS, SPORT_LABELS, SPORT_SUBTYPES, SUB_SPORT_LABELS,
|
||||
type Sport, type SubSport,
|
||||
} from '../sports';
|
||||
|
||||
export function PostRecordingScreen() {
|
||||
const nav = useNavigation();
|
||||
const { accent, accentDim } = useTheme();
|
||||
const { trackPoints, reset, getStats } = useRecordingStore();
|
||||
const stats = getStats();
|
||||
const [title, setTitle] = useState('');
|
||||
const [sport, setSport] = useState<Sport>('cycling');
|
||||
const [subSport, setSubSport] = useState<SubSport | null>(null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const subtypes = SPORT_SUBTYPES[sport] ?? [];
|
||||
|
||||
function handleSportSelect(s: Sport) {
|
||||
setSport(s);
|
||||
setSubSport(null); // reset subtype when sport changes
|
||||
}
|
||||
|
||||
const formatDuration = (secs: number) => {
|
||||
const h = Math.floor(secs / 3600).toString().padStart(2, '0');
|
||||
const m = Math.floor((secs % 3600) / 60).toString().padStart(2, '0');
|
||||
const m = Math.floor((secs % 3600) / 60).toString().padStart(2, '00');
|
||||
const s = (secs % 60).toString().padStart(2, '0');
|
||||
return `${h}:${m}:${s}`;
|
||||
};
|
||||
@@ -34,6 +49,8 @@ export function PostRecordingScreen() {
|
||||
durationSeconds: stats.elapsedSeconds,
|
||||
distanceMeters: stats.distanceMeters,
|
||||
filePath,
|
||||
sport,
|
||||
subSport,
|
||||
};
|
||||
await insertRecording(rec);
|
||||
reset();
|
||||
@@ -57,12 +74,51 @@ export function PostRecordingScreen() {
|
||||
<Text style={styles.heading}>Recording complete</Text>
|
||||
|
||||
<View style={styles.statsRow}>
|
||||
<Stat label="Duration" value={formatDuration(stats.elapsedSeconds)} />
|
||||
<Stat label="Distance" value={`${(stats.distanceMeters / 1000).toFixed(2)} km`} />
|
||||
<Stat label="Duration" value={formatDuration(stats.elapsedSeconds)} />
|
||||
<Stat label="Distance" value={`${(stats.distanceMeters / 1000).toFixed(2)} km`} />
|
||||
<Stat label="Avg Speed" value={`${stats.avgSpeedKph.toFixed(1)} km/h`} />
|
||||
<Stat label="Elevation" value={`+${stats.elevationGainMeters.toFixed(0)} m`} />
|
||||
</View>
|
||||
|
||||
{/* Sport selector */}
|
||||
<Text style={styles.sectionLabel}>Activity type</Text>
|
||||
<View style={styles.sportGrid}>
|
||||
{ALL_SPORTS.map((s) => {
|
||||
const active = sport === s;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={s}
|
||||
style={[styles.sportPill, active && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
onPress={() => handleSportSelect(s)}
|
||||
>
|
||||
<Text style={styles.sportIcon}>{SPORT_ICONS[s]}</Text>
|
||||
<Text style={[styles.sportLabel, active && { color: accent }]}>{SPORT_LABELS[s]}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
{/* Subtype selector — only shown when sport has subtypes */}
|
||||
{subtypes.length > 0 && (
|
||||
<>
|
||||
<Text style={styles.sectionLabel}>Subtype</Text>
|
||||
<View style={styles.subRow}>
|
||||
{subtypes.map((sub) => {
|
||||
const active = subSport === sub;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={sub}
|
||||
style={[styles.subPill, active && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
onPress={() => setSubSport(active ? null : sub)}
|
||||
>
|
||||
<Text style={[styles.subLabel, active && { color: accent }]}>{SUB_SPORT_LABELS[sub]}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
placeholder="Activity title"
|
||||
@@ -92,16 +148,24 @@ function Stat({ label, value }: { label: string; value: string }) {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
content: { padding: 24, gap: 12 },
|
||||
heading: { color: colors.text, fontSize: 22, fontWeight: '700', marginBottom: 4 },
|
||||
statsRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginBottom: 4 },
|
||||
stat: { flex: 1, minWidth: '40%', backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, borderRadius: 10, padding: 14 },
|
||||
statLabel: { color: colors.textMuted, fontSize: 11, textTransform: 'uppercase', letterSpacing: 0.5 },
|
||||
statValue: { color: colors.text, fontSize: 22, fontWeight: '700', marginTop: 4 },
|
||||
input: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, color: colors.text, borderRadius: 10, padding: 14, fontSize: 16 },
|
||||
btn: { borderRadius: 10, padding: 16, alignItems: 'center' },
|
||||
btnSave: { backgroundColor: colors.btnStart },
|
||||
btnDiscard:{ backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border },
|
||||
btnText: { fontSize: 16, fontWeight: '600', color: colors.text },
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
content: { padding: 24, gap: 12 },
|
||||
heading: { color: colors.text, fontSize: 22, fontWeight: '700', marginBottom: 4 },
|
||||
statsRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
stat: { flex: 1, minWidth: '40%', backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, borderRadius: 10, padding: 14 },
|
||||
statLabel: { color: colors.textMuted, fontSize: 11, textTransform: 'uppercase', letterSpacing: 0.5 },
|
||||
statValue: { color: colors.text, fontSize: 20, fontWeight: '700', marginTop: 4 },
|
||||
sectionLabel:{ color: colors.textMuted, fontSize: 11, textTransform: 'uppercase', letterSpacing: 0.8, marginTop: 4 },
|
||||
sportGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
sportPill: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingVertical: 9, paddingHorizontal: 14, borderRadius: 20, borderWidth: 1, borderColor: colors.borderStrong, backgroundColor: colors.surface },
|
||||
sportIcon: { fontSize: 16 },
|
||||
sportLabel: { color: colors.textSub, fontSize: 13, fontWeight: '500' },
|
||||
subRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
||||
subPill: { paddingVertical: 7, paddingHorizontal: 14, borderRadius: 20, borderWidth: 1, borderColor: colors.borderStrong, backgroundColor: colors.surface },
|
||||
subLabel: { color: colors.textSub, fontSize: 13, fontWeight: '500' },
|
||||
input: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, color: colors.text, borderRadius: 10, padding: 14, fontSize: 16 },
|
||||
btn: { borderRadius: 10, padding: 16, alignItems: 'center' },
|
||||
btnSave: { backgroundColor: colors.btnStart },
|
||||
btnDiscard: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border },
|
||||
btnText: { fontSize: 16, fontWeight: '600', color: colors.text },
|
||||
});
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
import React, { useEffect, useRef, useState, useMemo } from 'react';
|
||||
import { View, Text, StyleSheet, TouchableOpacity, Alert } from 'react-native';
|
||||
import { View, Text, StyleSheet, TouchableOpacity, Alert, Modal, TextInput, Pressable } from 'react-native';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';
|
||||
import { Map, Camera, GeoJSONSource, Layer, UserLocation } from '@maplibre/maplibre-react-native';
|
||||
import { Map, Camera, GeoJSONSource, Layer, UserLocation, type MapRef } from '@maplibre/maplibre-react-native';
|
||||
import type { LineLayerStyle, CircleLayerStyle } from '@maplibre/maplibre-react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { useRecordingStore } from '../store/recording';
|
||||
import { startGpsRecording, stopGpsRecording, requestLocationPermissions, requestForegroundLocation } from '../services/gps';
|
||||
import { RootStackParamList } from '../types';
|
||||
import { colors } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
|
||||
const MAP_STYLE = 'https://tiles.openfreemap.org/styles/liberty';
|
||||
import { MAP_STYLES } from '../mapStyles';
|
||||
import { downloadRegion, formatBytes, expandBounds, OFFLINE_STYLE_URL } from '../services/offline';
|
||||
|
||||
type Nav = NativeStackNavigationProp<RootStackParamList>;
|
||||
|
||||
export function RecordingScreen() {
|
||||
const nav = useNavigation<Nav>();
|
||||
const { accent, accentDim, scale, boldLabels } = useTheme();
|
||||
const insets = useSafeAreaInsets();
|
||||
const { accent, accentDim, scale, boldLabels, mapOrientation, mapTileStyle } = useTheme();
|
||||
const mapStyle = MAP_STYLES[mapTileStyle].style;
|
||||
const mapRef = useRef<MapRef>(null);
|
||||
|
||||
// Offline download state
|
||||
const [dlVisible, setDlVisible] = useState(false);
|
||||
const [dlName, setDlName] = useState('');
|
||||
const [dlProgress, setDlProgress] = useState<number | null>(null);
|
||||
const [dlSize, setDlSize] = useState(0);
|
||||
const isVectorStyle = mapTileStyle === 'liberty';
|
||||
|
||||
// Map orientation setting → MapLibre trackUserLocation value
|
||||
const trackUserLocation = mapOrientation === 'north' ? 'default'
|
||||
: mapOrientation === 'compass' ? 'heading'
|
||||
: 'course';
|
||||
const { status, ble, keepAwake, trackPoints, start, pause, resume, stop, setKeepAwake, getStats } = useRecordingStore();
|
||||
const [stats, setStats] = useState(getStats());
|
||||
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
@@ -83,6 +99,27 @@ export function RecordingScreen() {
|
||||
async function handleResume() { resume(); await startGpsRecording(); }
|
||||
async function handleStop() { await stopGpsRecording(); stop(); nav.navigate('PostRecording'); }
|
||||
|
||||
async function handleDownloadConfirm() {
|
||||
if (!dlName.trim()) { Alert.alert('Name required'); return; }
|
||||
const bounds = await mapRef.current?.getBounds();
|
||||
if (!bounds) { Alert.alert('Could not read map bounds'); return; }
|
||||
const expanded = expandBounds(bounds, 5); // add 5 km buffer
|
||||
setDlProgress(0);
|
||||
try {
|
||||
await downloadRegion(
|
||||
dlName.trim(),
|
||||
expanded,
|
||||
(pct, _tiles, sizeBytes) => { setDlProgress(pct); setDlSize(sizeBytes); },
|
||||
);
|
||||
setDlVisible(false);
|
||||
setDlProgress(null);
|
||||
Alert.alert('Download complete', `"${dlName.trim()}" is now available offline.`);
|
||||
} catch (e: any) {
|
||||
setDlProgress(null);
|
||||
Alert.alert('Download failed', e?.message ?? 'Unknown error');
|
||||
}
|
||||
}
|
||||
|
||||
const formatDuration = (secs: number) => {
|
||||
const h = Math.floor(secs / 3600).toString().padStart(2, '0');
|
||||
const m = Math.floor((secs % 3600) / 60).toString().padStart(2, '0');
|
||||
@@ -104,9 +141,9 @@ export function RecordingScreen() {
|
||||
</View>
|
||||
|
||||
<View style={styles.mapArea}>
|
||||
<Map mapStyle={MAP_STYLE} style={StyleSheet.absoluteFill} logo={false} attribution={false}>
|
||||
<Map ref={mapRef} mapStyle={mapStyle} style={StyleSheet.absoluteFill} logo={false} attribution={false}>
|
||||
<Camera
|
||||
trackUserLocation={status === 'recording' ? 'course' : 'default'}
|
||||
trackUserLocation={trackUserLocation}
|
||||
initialViewState={{ zoom: 14 }}
|
||||
/>
|
||||
<UserLocation>
|
||||
@@ -118,11 +155,62 @@ export function RecordingScreen() {
|
||||
</GeoJSONSource>
|
||||
)}
|
||||
</Map>
|
||||
<TouchableOpacity style={[styles.sensorBtn, { borderColor: colors.border }]} onPress={() => nav.navigate('SensorPairing')}>
|
||||
<Text style={[styles.sensorBtnText, { color: accent }]}>⚡ Sensors</Text>
|
||||
</TouchableOpacity>
|
||||
<View style={[styles.mapOverlay, { top: insets.top > 0 ? insets.top + 8 : 10 }]}>
|
||||
<TouchableOpacity style={[styles.overlayBtn, { borderColor: colors.border }]} onPress={() => nav.navigate('SensorPairing')}>
|
||||
<Text style={[styles.overlayBtnText, { color: accent }]}>⚡ Sensors</Text>
|
||||
</TouchableOpacity>
|
||||
{isVectorStyle && status === 'idle' && (
|
||||
<TouchableOpacity
|
||||
style={[styles.overlayBtn, { borderColor: colors.border }]}
|
||||
onPress={() => { setDlName(''); setDlVisible(true); }}
|
||||
>
|
||||
<Text style={[styles.overlayBtnText, { color: accent }]}>↓ Offline</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Offline download modal */}
|
||||
<Modal visible={dlVisible} transparent animationType="fade" onRequestClose={() => dlProgress === null && setDlVisible(false)}>
|
||||
<Pressable style={styles.modalOverlay} onPress={() => dlProgress === null && setDlVisible(false)}>
|
||||
<Pressable style={styles.modalBox} onPress={() => {}}>
|
||||
{dlProgress === null ? (
|
||||
<>
|
||||
<Text style={styles.modalHeading}>Download visible area</Text>
|
||||
<Text style={styles.modalSub}>
|
||||
Downloads the current map view (zoom 6–16) for offline use.{'\n'}
|
||||
Only available with the Liberty vector style.
|
||||
</Text>
|
||||
<TextInput
|
||||
style={styles.modalInput}
|
||||
value={dlName}
|
||||
onChangeText={setDlName}
|
||||
placeholder="Region name (e.g. Alps 2026)"
|
||||
placeholderTextColor={colors.placeholder}
|
||||
autoFocus
|
||||
/>
|
||||
<View style={styles.modalButtons}>
|
||||
<TouchableOpacity style={styles.modalBtn} onPress={() => setDlVisible(false)}>
|
||||
<Text style={[styles.modalBtnText, { color: colors.textSub }]}>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={[styles.modalBtn, { backgroundColor: accent }]} onPress={handleDownloadConfirm}>
|
||||
<Text style={[styles.modalBtnText, { color: '#fff' }]}>Download</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Text style={styles.modalHeading}>Downloading…</Text>
|
||||
<View style={styles.progressBarBg}>
|
||||
<View style={[styles.progressBarFill, { width: `${dlProgress}%` as any, backgroundColor: accent }]} />
|
||||
</View>
|
||||
<Text style={styles.modalSub}>{dlProgress.toFixed(0)}% · {formatBytes(dlSize)} downloaded</Text>
|
||||
</>
|
||||
)}
|
||||
</Pressable>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
|
||||
<View style={styles.controls}>
|
||||
<TouchableOpacity
|
||||
style={[styles.awakeBtn, keepAwake && { borderColor: accent }]}
|
||||
@@ -177,9 +265,21 @@ const styles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
statsGrid: { flexDirection: 'row', flexWrap: 'wrap', padding: 8, borderBottomWidth: 1, borderBottomColor: colors.border },
|
||||
statBox: { width: '25%', padding: 8, alignItems: 'center' },
|
||||
mapArea: { flex: 1, overflow: 'hidden' },
|
||||
sensorBtn: { position: 'absolute', top: 10, right: 10, backgroundColor: 'rgba(9,9,11,0.8)', borderRadius: 8, borderWidth: 1, paddingVertical: 6, paddingHorizontal: 12 },
|
||||
sensorBtnText: { fontSize: 13, fontWeight: '600' },
|
||||
mapArea: { flex: 1, overflow: 'hidden' },
|
||||
mapOverlay: { position: 'absolute', right: 10, flexDirection: 'column', gap: 8 },
|
||||
overlayBtn: { backgroundColor: 'rgba(9,9,11,0.85)', borderRadius: 8, borderWidth: 1, paddingVertical: 6, paddingHorizontal: 12 },
|
||||
overlayBtnText: { fontSize: 13, fontWeight: '600' },
|
||||
// Download modal
|
||||
modalOverlay: { flex: 1, backgroundColor: 'rgba(0,0,0,0.7)', justifyContent: 'center', padding: 32 },
|
||||
modalBox: { backgroundColor: colors.surface, borderRadius: 14, padding: 20, gap: 14 },
|
||||
modalHeading: { color: colors.text, fontSize: 17, fontWeight: '700' },
|
||||
modalSub: { color: colors.textMuted, fontSize: 13, lineHeight: 18 },
|
||||
modalInput: { backgroundColor: colors.bg, borderWidth: 1, borderColor: colors.border, color: colors.text, borderRadius: 8, padding: 12, fontSize: 15 },
|
||||
modalButtons: { flexDirection: 'row', gap: 10 },
|
||||
modalBtn: { flex: 1, borderRadius: 8, padding: 12, alignItems: 'center', backgroundColor: colors.bg, borderWidth: 1, borderColor: colors.border },
|
||||
modalBtnText: { fontSize: 15, fontWeight: '600' },
|
||||
progressBarBg: { height: 8, backgroundColor: colors.border, borderRadius: 4, overflow: 'hidden' },
|
||||
progressBarFill:{ height: '100%', borderRadius: 4 },
|
||||
controls: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 12, padding: 20, borderTopWidth: 1, borderTopColor: colors.border },
|
||||
awakeBtn: { backgroundColor: colors.surface, borderRadius: 20, borderWidth: 1, borderColor: colors.border, paddingVertical: 8, paddingHorizontal: 14 },
|
||||
awakeBtnText: { color: colors.textSub, fontSize: 13 },
|
||||
|
||||
@@ -1,19 +1,56 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { View, Text, StyleSheet, FlatList, TouchableOpacity, Alert, ActivityIndicator } from 'react-native';
|
||||
import { useFocusEffect } from '@react-navigation/native';
|
||||
import React, { useCallback, useLayoutEffect, useState } from 'react';
|
||||
import {
|
||||
View, Text, StyleSheet, FlatList, TouchableOpacity,
|
||||
Alert, ActivityIndicator, Modal, TextInput, Pressable,
|
||||
} from 'react-native';
|
||||
import { useFocusEffect, useNavigation } from '@react-navigation/native';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { RootStackParamList } from '../types';
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { listRecordings, deleteRecording } from '../services/db';
|
||||
import { listRecordings, deleteRecording, insertRecording } from '../services/db';
|
||||
import { uploadGpx } from '../services/upload';
|
||||
import { saveGpx, parseGpxFile } from '../services/gpx';
|
||||
import { SavedRecording } from '../types';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { randomUUID } from 'expo-crypto';
|
||||
import { colors } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
import { SPORT_ICONS, SPORT_LABELS, SUB_SPORT_LABELS, type Sport, type SubSport } from '../sports';
|
||||
|
||||
export function SavedRecordingsScreen() {
|
||||
const { accent } = useTheme();
|
||||
const [recordings, setRecordings] = useState<SavedRecording[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [uploading, setUploading] = useState<string | null>(null);
|
||||
const nav = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
||||
const { accent, accentDim } = useTheme();
|
||||
const [recordings, setRecordings] = useState<SavedRecording[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectionMode, setSelectionMode] = useState(false);
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
||||
const [busyMsg, setBusyMsg] = useState<string | null>(null);
|
||||
const [mergeVisible, setMergeVisible] = useState(false);
|
||||
const [mergeTitle, setMergeTitle] = useState('');
|
||||
|
||||
// ── Header button ────────────────────────────────────────────────────────
|
||||
|
||||
useLayoutEffect(() => {
|
||||
nav.setOptions(
|
||||
selectionMode
|
||||
? {
|
||||
headerTitle: `${selectedIds.size} selected`,
|
||||
headerRight: () => (
|
||||
<TouchableOpacity onPress={exitSelection} style={{ marginRight: 16 }}>
|
||||
<Text style={{ color: accent, fontSize: 15, fontWeight: '600' }}>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
}
|
||||
: {
|
||||
headerTitle: 'Saved',
|
||||
headerRight: () => (
|
||||
<TouchableOpacity onPress={enterSelection} style={{ marginRight: 16 }}>
|
||||
<Text style={{ color: accent, fontSize: 15, fontWeight: '600' }}>Select</Text>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
},
|
||||
);
|
||||
}, [nav, selectionMode, selectedIds.size, accent]);
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
@@ -21,38 +58,132 @@ export function SavedRecordingsScreen() {
|
||||
}, []),
|
||||
);
|
||||
|
||||
// ── Selection helpers ────────────────────────────────────────────────────
|
||||
|
||||
function enterSelection() { setSelectionMode(true); setSelectedIds(new Set()); }
|
||||
function exitSelection() { setSelectionMode(false); setSelectedIds(new Set()); }
|
||||
|
||||
function toggleId(id: string) {
|
||||
setSelectedIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.has(id) ? next.delete(id) : next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
const selected = recordings.filter((r) => selectedIds.has(r.id));
|
||||
|
||||
// ── Single-item actions (normal mode) ────────────────────────────────────
|
||||
|
||||
async function handleShare(rec: SavedRecording) {
|
||||
await Sharing.shareAsync(rec.filePath, { mimeType: 'application/gpx+xml', dialogTitle: rec.title });
|
||||
}
|
||||
|
||||
async function handleUpload(rec: SavedRecording) {
|
||||
const instanceUrl = await AsyncStorage.getItem('instanceUrl');
|
||||
const apiToken = await AsyncStorage.getItem('apiToken');
|
||||
if (!instanceUrl || !apiToken) {
|
||||
Alert.alert('Not connected', 'Log in to your bincio instance in Settings first.');
|
||||
return;
|
||||
}
|
||||
setUploading(rec.id);
|
||||
const [instanceUrl, apiToken] = await Promise.all([
|
||||
AsyncStorage.getItem('instanceUrl'), AsyncStorage.getItem('apiToken'),
|
||||
]);
|
||||
if (!instanceUrl || !apiToken) { Alert.alert('Not connected', 'Log in in Settings → Sync first.'); return; }
|
||||
const result = await uploadGpx(rec.filePath, instanceUrl, apiToken);
|
||||
setUploading(null);
|
||||
if (result.ok) Alert.alert('Uploaded', `"${rec.title}" uploaded successfully.`);
|
||||
if (result.ok) Alert.alert('Uploaded', `"${rec.title}" uploaded.`);
|
||||
else Alert.alert('Upload failed', result.error);
|
||||
}
|
||||
|
||||
function handleDelete(rec: SavedRecording) {
|
||||
Alert.alert('Delete recording?', `"${rec.title}" will be removed.`, [
|
||||
Alert.alert('Delete?', `"${rec.title}" will be removed.`, [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{
|
||||
text: 'Delete',
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
await deleteRecording(rec.id);
|
||||
setRecordings((prev) => prev.filter((r) => r.id !== rec.id));
|
||||
},
|
||||
},
|
||||
{ text: 'Delete', style: 'destructive', onPress: async () => {
|
||||
await deleteRecording(rec.id);
|
||||
setRecordings((prev) => prev.filter((r) => r.id !== rec.id));
|
||||
}},
|
||||
]);
|
||||
}
|
||||
|
||||
// ── Bulk actions ─────────────────────────────────────────────────────────
|
||||
|
||||
async function handleBulkExport() {
|
||||
for (let i = 0; i < selected.length; i++) {
|
||||
setBusyMsg(`Exporting ${i + 1}/${selected.length}…`);
|
||||
await Sharing.shareAsync(selected[i].filePath, { mimeType: 'application/gpx+xml', dialogTitle: selected[i].title });
|
||||
}
|
||||
setBusyMsg(null);
|
||||
}
|
||||
|
||||
async function handleBulkUpload() {
|
||||
const [instanceUrl, apiToken] = await Promise.all([
|
||||
AsyncStorage.getItem('instanceUrl'), AsyncStorage.getItem('apiToken'),
|
||||
]);
|
||||
if (!instanceUrl || !apiToken) { Alert.alert('Not connected', 'Log in in Settings → Sync first.'); return; }
|
||||
let ok = 0, fail = 0;
|
||||
for (let i = 0; i < selected.length; i++) {
|
||||
setBusyMsg(`Uploading ${i + 1}/${selected.length}…`);
|
||||
const result = await uploadGpx(selected[i].filePath, instanceUrl, apiToken);
|
||||
result.ok ? ok++ : fail++;
|
||||
}
|
||||
setBusyMsg(null);
|
||||
Alert.alert('Upload complete', `${ok} uploaded${fail ? `, ${fail} failed` : ''}.`);
|
||||
}
|
||||
|
||||
function handleBulkDelete() {
|
||||
Alert.alert(
|
||||
`Delete ${selected.length} recording${selected.length !== 1 ? 's' : ''}?`,
|
||||
'This cannot be undone.',
|
||||
[
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{ text: 'Delete', style: 'destructive', onPress: async () => {
|
||||
setBusyMsg('Deleting…');
|
||||
for (const rec of selected) await deleteRecording(rec.id);
|
||||
setRecordings((prev) => prev.filter((r) => !selectedIds.has(r.id)));
|
||||
setBusyMsg(null);
|
||||
exitSelection();
|
||||
}},
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
function openMergeModal() {
|
||||
const names = selected.map((r) => r.title).join(' + ');
|
||||
setMergeTitle(names.length > 60 ? names.slice(0, 60) + '…' : names);
|
||||
setMergeVisible(true);
|
||||
}
|
||||
|
||||
async function handleMergeConfirm() {
|
||||
if (!mergeTitle.trim()) { Alert.alert('Title required'); return; }
|
||||
setMergeVisible(false);
|
||||
setBusyMsg('Merging…');
|
||||
try {
|
||||
// Parse all GPX files and combine track points sorted by time
|
||||
const allPoints = (
|
||||
await Promise.all(selected.map((r) => parseGpxFile(r.filePath)))
|
||||
).flat().sort((a, b) => a.time.getTime() - b.time.getTime());
|
||||
|
||||
const sport = selected[0].sport;
|
||||
const subSport = selected[0].subSport;
|
||||
const filePath = saveGpx(allPoints, mergeTitle.trim());
|
||||
const merged: SavedRecording = {
|
||||
id: randomUUID(),
|
||||
title: mergeTitle.trim(),
|
||||
date: allPoints[0]?.time.toISOString() ?? new Date().toISOString(),
|
||||
durationSeconds: selected.reduce((s, r) => s + r.durationSeconds, 0),
|
||||
distanceMeters: selected.reduce((s, r) => s + r.distanceMeters, 0),
|
||||
filePath,
|
||||
sport,
|
||||
subSport,
|
||||
};
|
||||
await insertRecording(merged);
|
||||
const updated = await listRecordings();
|
||||
setRecordings(updated);
|
||||
setBusyMsg(null);
|
||||
exitSelection();
|
||||
Alert.alert('Merged', `"${merged.title}" saved with ${allPoints.length} track points.`);
|
||||
} catch (e: any) {
|
||||
setBusyMsg(null);
|
||||
Alert.alert('Merge failed', e?.message ?? 'Unknown error');
|
||||
}
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
const formatDuration = (secs: number) => {
|
||||
const h = Math.floor(secs / 3600);
|
||||
const m = Math.floor((secs % 3600) / 60);
|
||||
@@ -67,42 +198,143 @@ export function SavedRecordingsScreen() {
|
||||
data={recordings}
|
||||
keyExtractor={(r) => r.id}
|
||||
contentContainerStyle={styles.list}
|
||||
renderItem={({ item }) => (
|
||||
<View style={styles.card}>
|
||||
<View style={styles.cardMeta}>
|
||||
<Text style={styles.cardTitle}>{item.title}</Text>
|
||||
<Text style={styles.cardSub}>
|
||||
{new Date(item.date).toLocaleDateString()} · {formatDuration(item.durationSeconds)} · {(item.distanceMeters / 1000).toFixed(2)} km
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.cardActions}>
|
||||
<TouchableOpacity onPress={() => handleShare(item)}>
|
||||
<Text style={[styles.action, { color: accent }]}>Export</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleUpload(item)} disabled={uploading === item.id}>
|
||||
<Text style={[styles.action, { color: accent }]}>{uploading === item.id ? '…' : 'Upload'}</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleDelete(item)}>
|
||||
<Text style={[styles.action, { color: colors.error }]}>Delete</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
renderItem={({ item }) => {
|
||||
const isSelected = selectedIds.has(item.id);
|
||||
return (
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.7}
|
||||
onPress={() => selectionMode ? toggleId(item.id) : nav.navigate('ActivityDetail', { recording: item })}
|
||||
style={[styles.card, isSelected && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
>
|
||||
<View style={styles.cardInner}>
|
||||
{/* Checkbox (selection mode only) */}
|
||||
{selectionMode && (
|
||||
<View style={[styles.checkbox, isSelected && { borderColor: accent, backgroundColor: accent }]}>
|
||||
{isSelected && <Text style={styles.checkmark}>✓</Text>}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Meta */}
|
||||
<View style={styles.cardMeta}>
|
||||
<View style={styles.cardTitleRow}>
|
||||
<Text style={styles.cardIcon}>{SPORT_ICONS[item.sport as Sport] ?? '⚡'}</Text>
|
||||
<Text style={styles.cardTitle} numberOfLines={1}>{item.title}</Text>
|
||||
</View>
|
||||
<Text style={styles.cardSub}>
|
||||
{SPORT_LABELS[item.sport as Sport] ?? item.sport}
|
||||
{item.subSport ? ` · ${SUB_SPORT_LABELS[item.subSport as SubSport] ?? item.subSport}` : ''}
|
||||
{' · '}{new Date(item.date).toLocaleDateString()}
|
||||
{' · '}{formatDuration(item.durationSeconds)}
|
||||
{' · '}{(item.distanceMeters / 1000).toFixed(2)} km
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Per-card actions (normal mode only) */}
|
||||
{!selectionMode && (
|
||||
<View style={styles.cardActions}>
|
||||
<TouchableOpacity onPress={() => handleShare(item)}>
|
||||
<Text style={[styles.action, { color: accent }]}>Export</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleUpload(item)}>
|
||||
<Text style={[styles.action, { color: accent }]}>Upload</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleDelete(item)}>
|
||||
<Text style={[styles.action, { color: colors.error }]}>Delete</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}}
|
||||
ListEmptyComponent={<Text style={styles.empty}>No recordings yet.</Text>}
|
||||
/>
|
||||
|
||||
{/* Bulk action bar */}
|
||||
{selectionMode && (
|
||||
<View style={styles.actionBar}>
|
||||
{busyMsg ? (
|
||||
<View style={styles.busyRow}>
|
||||
<ActivityIndicator color={accent} />
|
||||
<Text style={[styles.busyText, { color: accent }]}>{busyMsg}</Text>
|
||||
</View>
|
||||
) : (
|
||||
<>
|
||||
<BulkBtn label="Export" onPress={handleBulkExport} disabled={selected.length === 0} accent={accent} />
|
||||
<BulkBtn label="Upload" onPress={handleBulkUpload} disabled={selected.length === 0} accent={accent} />
|
||||
<BulkBtn label="Delete" onPress={handleBulkDelete} disabled={selected.length === 0} accent={colors.error} />
|
||||
<BulkBtn label="Merge" onPress={openMergeModal} disabled={selected.length < 2} accent={accent} />
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Merge title modal */}
|
||||
<Modal visible={mergeVisible} transparent animationType="fade" onRequestClose={() => setMergeVisible(false)}>
|
||||
<Pressable style={styles.modalOverlay} onPress={() => setMergeVisible(false)}>
|
||||
<Pressable style={styles.modalBox} onPress={() => {}}>
|
||||
<Text style={styles.modalHeading}>Merge {selected.length} recordings</Text>
|
||||
<TextInput
|
||||
style={styles.modalInput}
|
||||
value={mergeTitle}
|
||||
onChangeText={setMergeTitle}
|
||||
placeholder="Merged activity title"
|
||||
placeholderTextColor={colors.placeholder}
|
||||
autoFocus
|
||||
selectTextOnFocus
|
||||
/>
|
||||
<View style={styles.modalButtons}>
|
||||
<TouchableOpacity style={styles.modalBtn} onPress={() => setMergeVisible(false)}>
|
||||
<Text style={[styles.modalBtnText, { color: colors.textSub }]}>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={[styles.modalBtn, { backgroundColor: accent }]} onPress={handleMergeConfirm}>
|
||||
<Text style={[styles.modalBtnText, { color: '#fff' }]}>Merge</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</Pressable>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function BulkBtn({ label, onPress, disabled, accent }: { label: string; onPress: () => void; disabled: boolean; accent: string }) {
|
||||
return (
|
||||
<TouchableOpacity style={[styles.bulkBtn, disabled && styles.bulkBtnDisabled]} onPress={onPress} disabled={disabled}>
|
||||
<Text style={[styles.bulkBtnText, { color: disabled ? colors.textMuted : accent }]}>{label}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
center: { flex: 1, backgroundColor: colors.bg, alignItems: 'center', justifyContent: 'center' },
|
||||
list: { padding: 16, gap: 10 },
|
||||
card: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, borderRadius: 12, padding: 16 },
|
||||
cardMeta: { marginBottom: 12 },
|
||||
cardTitle: { color: colors.text, fontSize: 15, fontWeight: '600' },
|
||||
cardSub: { color: colors.textMuted, fontSize: 12, marginTop: 4 },
|
||||
cardActions:{ flexDirection: 'row', gap: 20 },
|
||||
action: { fontWeight: '600', fontSize: 14 },
|
||||
empty: { color: colors.textMuted, textAlign: 'center', marginTop: 60 },
|
||||
container: { flex: 1, backgroundColor: colors.bg },
|
||||
center: { flex: 1, backgroundColor: colors.bg, alignItems: 'center', justifyContent: 'center' },
|
||||
list: { padding: 16, gap: 10, paddingBottom: 24 },
|
||||
card: { backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.border, borderRadius: 12, padding: 14 },
|
||||
cardInner: { flexDirection: 'row', alignItems: 'center', gap: 12 },
|
||||
checkbox: { width: 22, height: 22, borderRadius: 11, borderWidth: 1.5, borderColor: colors.borderStrong, alignItems: 'center', justifyContent: 'center' },
|
||||
checkmark: { color: '#fff', fontSize: 13, fontWeight: '700' },
|
||||
cardMeta: { flex: 1 },
|
||||
cardTitleRow: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 4 },
|
||||
cardIcon: { fontSize: 17 },
|
||||
cardTitle: { color: colors.text, fontSize: 15, fontWeight: '600', flex: 1 },
|
||||
cardSub: { color: colors.textMuted, fontSize: 12 },
|
||||
cardActions: { flexDirection: 'row', gap: 20, marginTop: 12, paddingTop: 12, borderTopWidth: 1, borderTopColor: colors.border },
|
||||
action: { fontWeight: '600', fontSize: 14 },
|
||||
empty: { color: colors.textMuted, textAlign: 'center', marginTop: 60 },
|
||||
// Action bar
|
||||
actionBar: { flexDirection: 'row', backgroundColor: colors.surface, borderTopWidth: 1, borderTopColor: colors.border, paddingVertical: 12, paddingHorizontal: 8 },
|
||||
bulkBtn: { flex: 1, alignItems: 'center', paddingVertical: 8 },
|
||||
bulkBtnDisabled:{ opacity: 0.4 },
|
||||
bulkBtnText: { fontSize: 14, fontWeight: '600' },
|
||||
busyRow: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 },
|
||||
busyText: { fontSize: 14, fontWeight: '500' },
|
||||
// Merge modal
|
||||
modalOverlay: { flex: 1, backgroundColor: 'rgba(0,0,0,0.7)', justifyContent: 'center', padding: 32 },
|
||||
modalBox: { backgroundColor: colors.surface, borderRadius: 14, padding: 20, gap: 16 },
|
||||
modalHeading: { color: colors.text, fontSize: 17, fontWeight: '700' },
|
||||
modalInput: { backgroundColor: colors.bg, borderWidth: 1, borderColor: colors.border, color: colors.text, borderRadius: 8, padding: 12, fontSize: 15 },
|
||||
modalButtons: { flexDirection: 'row', gap: 10 },
|
||||
modalBtn: { flex: 1, borderRadius: 8, padding: 12, alignItems: 'center', backgroundColor: colors.bg, borderWidth: 1, borderColor: colors.border },
|
||||
modalBtnText: { fontSize: 15, fontWeight: '600' },
|
||||
});
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
View, Text, TextInput, StyleSheet, Switch,
|
||||
View, Text, StyleSheet, Switch,
|
||||
TouchableOpacity, Alert, ScrollView, ActivityIndicator,
|
||||
} from 'react-native';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { login, logout, loadAuthState } from '../services/auth';
|
||||
import { colors, PALETTES, type PaletteKey, type FontSizeKey } from '../theme';
|
||||
import { useTheme } from '../ThemeContext';
|
||||
import { useTheme, type MapOrientation } from '../ThemeContext';
|
||||
import { MAP_STYLES, MAP_TILE_STYLE_ORDER } from '../mapStyles';
|
||||
import { listRegions, deleteRegion, formatBytes, type OfflineRegion } from '../services/offline';
|
||||
|
||||
type Tab = 'ui' | 'app' | 'sync';
|
||||
|
||||
@@ -41,7 +43,7 @@ export function SettingsScreen() {
|
||||
// ─── UI tab ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function UITab() {
|
||||
const { accent, palette, setPalette, fontSize, setFontSize, boldLabels, setBoldLabels } = useTheme();
|
||||
const { accent, palette, setPalette, fontSize, setFontSize, boldLabels, setBoldLabels, mapTileStyle, setMapTileStyle } = useTheme();
|
||||
|
||||
const fontSizes: FontSizeKey[] = ['small', 'medium', 'large'];
|
||||
const palettes = Object.entries(PALETTES) as [PaletteKey, typeof PALETTES[PaletteKey]][];
|
||||
@@ -77,6 +79,25 @@ function UITab() {
|
||||
))}
|
||||
</View>
|
||||
|
||||
<Text style={styles.sectionTitle}>Map style</Text>
|
||||
{MAP_TILE_STYLE_ORDER.map((key) => {
|
||||
const def = MAP_STYLES[key];
|
||||
const active = mapTileStyle === key;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={key}
|
||||
style={[styles.row, active && { borderColor: accent, backgroundColor: PALETTES[palette].accentDim }]}
|
||||
onPress={() => setMapTileStyle(key)}
|
||||
>
|
||||
<View>
|
||||
<Text style={[styles.rowLabel, active && { color: accent }]}>{def.label}</Text>
|
||||
<Text style={styles.rowSub}>{def.description}</Text>
|
||||
</View>
|
||||
{active && <Text style={{ color: accent, fontSize: 16 }}>✓</Text>}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
|
||||
<Text style={styles.sectionTitle}>Stat labels</Text>
|
||||
<View style={styles.row}>
|
||||
<Text style={styles.rowLabel}>Bold labels</Text>
|
||||
@@ -93,14 +114,22 @@ function UITab() {
|
||||
|
||||
// ─── App tab ─────────────────────────────────────────────────────────────────
|
||||
|
||||
const MAP_ORIENTATION_OPTIONS: { key: MapOrientation; label: string; sub: string }[] = [
|
||||
{ key: 'north', label: 'North up', sub: 'Map always points north' },
|
||||
{ key: 'compass', label: 'Compass', sub: 'Rotates with device heading' },
|
||||
{ key: 'course', label: 'Course up', sub: 'Rotates to direction of travel' },
|
||||
];
|
||||
|
||||
function AppTab() {
|
||||
const { accent } = useTheme();
|
||||
const { accent, accentDim, mapOrientation, setMapOrientation } = useTheme();
|
||||
const [kmNotifications, setKmNotifications] = useState(true);
|
||||
const [regions, setRegions] = useState<OfflineRegion[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
AsyncStorage.getItem('kmNotifications').then((v) => {
|
||||
if (v !== null) setKmNotifications(v === 'true');
|
||||
});
|
||||
listRegions().then(setRegions).catch(() => {});
|
||||
}, []);
|
||||
|
||||
async function handleKmToggle(value: boolean) {
|
||||
@@ -108,8 +137,36 @@ function AppTab() {
|
||||
await AsyncStorage.setItem('kmNotifications', String(value));
|
||||
}
|
||||
|
||||
async function handleDeleteRegion(id: string, name: string) {
|
||||
Alert.alert('Delete offline region?', `"${name}" will be removed from the device.`, [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{ text: 'Delete', style: 'destructive', onPress: async () => {
|
||||
await deleteRegion(id);
|
||||
setRegions((prev) => prev.filter((r) => r.id !== id));
|
||||
}},
|
||||
]);
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerStyle={styles.content}>
|
||||
<Text style={styles.sectionTitle}>Map orientation</Text>
|
||||
{MAP_ORIENTATION_OPTIONS.map(({ key, label, sub }) => {
|
||||
const active = mapOrientation === key;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={key}
|
||||
style={[styles.row, active && { borderColor: accent, backgroundColor: accentDim }]}
|
||||
onPress={() => setMapOrientation(key)}
|
||||
>
|
||||
<View>
|
||||
<Text style={[styles.rowLabel, active && { color: accent }]}>{label}</Text>
|
||||
<Text style={styles.rowSub}>{sub}</Text>
|
||||
</View>
|
||||
{active && <Text style={{ color: accent, fontSize: 16 }}>✓</Text>}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
|
||||
<Text style={styles.sectionTitle}>Notifications</Text>
|
||||
<View style={styles.row}>
|
||||
<View>
|
||||
@@ -123,6 +180,32 @@ function AppTab() {
|
||||
thumbColor={colors.text}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Text style={styles.sectionTitle}>Offline maps</Text>
|
||||
{regions.length === 0 ? (
|
||||
<View style={[styles.row, { opacity: 0.5 }]}>
|
||||
<Text style={styles.rowSub}>
|
||||
No offline regions yet.{'\n'}
|
||||
Tap "↓ Offline" on the map (Liberty style) to download an area.
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
regions.map((r) => (
|
||||
<View key={r.id} style={styles.row}>
|
||||
<View style={{ flex: 1 }}>
|
||||
<Text style={styles.rowLabel}>{r.name}</Text>
|
||||
<Text style={styles.rowSub}>
|
||||
{r.state === 'complete'
|
||||
? `${formatBytes(r.totalSizeBytes)} · ${r.completedTiles} tiles`
|
||||
: `${r.percentage.toFixed(0)}% downloading…`}
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => handleDeleteRegion(r.id, r.name)}>
|
||||
<Text style={{ color: colors.error, fontSize: 13, fontWeight: '600' }}>Delete</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
))
|
||||
)}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
@@ -131,34 +214,28 @@ function AppTab() {
|
||||
|
||||
function SyncTab() {
|
||||
const { accent } = useTheme();
|
||||
const [instanceUrl, setInstanceUrl] = useState('');
|
||||
const [handle, setHandle] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [connectedAs, setConnectedAs] = useState<string | null>(null);
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
loadAuthState().then((auth) => {
|
||||
if (auth) { setInstanceUrl(auth.instanceUrl); setHandle(auth.handle); setConnectedAs(auth.handle); }
|
||||
if (auth) setConnectedAs(auth.handle);
|
||||
});
|
||||
}, []);
|
||||
|
||||
async function handleConnect() {
|
||||
if (!instanceUrl.trim()) { Alert.alert('Required', 'Enter the instance URL.'); return; }
|
||||
if (!handle.trim()) { Alert.alert('Required', 'Enter your handle.'); return; }
|
||||
if (!password) { Alert.alert('Required', 'Enter your password.'); return; }
|
||||
setConnecting(true);
|
||||
const result = await login(instanceUrl.trim(), handle.trim(), password);
|
||||
const result = await login();
|
||||
setConnecting(false);
|
||||
if (result.ok) { setConnectedAs(result.displayName || handle.trim()); setPassword(''); }
|
||||
else Alert.alert('Login failed', result.error ?? 'Unknown error');
|
||||
if (result.ok) setConnectedAs(result.displayName ?? '');
|
||||
else if (result.error !== 'Cancelled') Alert.alert('Sign in failed', result.error ?? 'Unknown error');
|
||||
}
|
||||
|
||||
async function handleDisconnect() {
|
||||
Alert.alert('Disconnect', 'Remove saved credentials?', [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{ text: 'Disconnect', style: 'destructive', onPress: async () => {
|
||||
await logout(); setConnectedAs(null); setHandle(''); setPassword('');
|
||||
await logout(); setConnectedAs(null);
|
||||
}},
|
||||
]);
|
||||
}
|
||||
@@ -167,18 +244,6 @@ function SyncTab() {
|
||||
<ScrollView contentContainerStyle={styles.content}>
|
||||
<Text style={styles.sectionTitle}>bincio instance</Text>
|
||||
|
||||
<Text style={styles.label}>Instance URL</Text>
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={instanceUrl}
|
||||
onChangeText={setInstanceUrl}
|
||||
placeholder="https://bincio.example.com"
|
||||
placeholderTextColor={colors.placeholder}
|
||||
autoCapitalize="none"
|
||||
keyboardType="url"
|
||||
editable={!connectedAs}
|
||||
/>
|
||||
|
||||
{connectedAs ? (
|
||||
<View style={styles.connectedBox}>
|
||||
<View>
|
||||
@@ -191,16 +256,9 @@ function SyncTab() {
|
||||
</View>
|
||||
) : (
|
||||
<>
|
||||
<Text style={styles.label}>Handle</Text>
|
||||
<TextInput style={styles.input} value={handle} onChangeText={setHandle} placeholder="your-handle" placeholderTextColor={colors.placeholder} autoCapitalize="none" autoCorrect={false} />
|
||||
|
||||
<Text style={styles.label}>Password</Text>
|
||||
<TextInput style={styles.input} value={password} onChangeText={setPassword} placeholder="••••••••" placeholderTextColor={colors.placeholder} secureTextEntry />
|
||||
|
||||
<Text style={styles.hint}>Your password is used once to obtain a session token, then forgotten.</Text>
|
||||
|
||||
<Text style={styles.hint}>Sign in with your bincio account to sync recordings.</Text>
|
||||
<TouchableOpacity style={[styles.connectBtn, connecting && styles.connectBtnDisabled]} onPress={handleConnect} disabled={connecting}>
|
||||
{connecting ? <ActivityIndicator color={colors.text} /> : <Text style={styles.connectBtnText}>Connect</Text>}
|
||||
{connecting ? <ActivityIndicator color={colors.text} /> : <Text style={styles.connectBtnText}>Sign in with bincio</Text>}
|
||||
</TouchableOpacity>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,42 +1,89 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import * as Crypto from 'expo-crypto';
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
import { makeRedirectUri } from 'expo-auth-session';
|
||||
|
||||
interface LoginResult {
|
||||
const ISSUER = 'https://bincio.org';
|
||||
const CLIENT_ID = 'bincio-rec';
|
||||
const REDIRECT_URI = makeRedirectUri({ scheme: 'bincio-rec', path: 'oauth' });
|
||||
|
||||
// ── PKCE helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
async function generateVerifier(): Promise<string> {
|
||||
const bytes = await Crypto.getRandomBytesAsync(32);
|
||||
return btoa(String.fromCharCode(...bytes))
|
||||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
}
|
||||
|
||||
async function deriveChallenge(verifier: string): Promise<string> {
|
||||
const digest = await Crypto.digestStringAsync(
|
||||
Crypto.CryptoDigestAlgorithm.SHA256,
|
||||
verifier,
|
||||
{ encoding: Crypto.CryptoEncoding.BASE64 },
|
||||
);
|
||||
return digest.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
}
|
||||
|
||||
// ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LoginResult {
|
||||
ok: boolean;
|
||||
displayName?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export async function login(
|
||||
instanceUrl: string,
|
||||
handle: string,
|
||||
password: string,
|
||||
): Promise<LoginResult> {
|
||||
const url = instanceUrl.replace(/\/$/, '') + '/api/auth/token';
|
||||
try {
|
||||
const resp = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ handle, password }),
|
||||
});
|
||||
export async function login(): Promise<LoginResult> {
|
||||
const verifier = await generateVerifier();
|
||||
const challenge = await deriveChallenge(verifier);
|
||||
|
||||
if (!resp.ok) {
|
||||
const text = await resp.text().catch(() => '');
|
||||
return { ok: false, error: text || `HTTP ${resp.status}` };
|
||||
}
|
||||
const authUrl = `${ISSUER}/oauth2/authorize?` + new URLSearchParams({
|
||||
client_id: CLIENT_ID,
|
||||
redirect_uri: REDIRECT_URI,
|
||||
response_type: 'code',
|
||||
scope: 'openid profile',
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: 'S256',
|
||||
});
|
||||
|
||||
const data = await resp.json();
|
||||
if (!data.token) return { ok: false, error: 'No token in response' };
|
||||
|
||||
await Promise.all([
|
||||
AsyncStorage.setItem('instanceUrl', instanceUrl.trim()),
|
||||
AsyncStorage.setItem('handle', handle.trim()),
|
||||
AsyncStorage.setItem('apiToken', data.token),
|
||||
]);
|
||||
|
||||
return { ok: true, displayName: data.display_name };
|
||||
} catch (e: any) {
|
||||
return { ok: false, error: e?.message ?? 'Connection failed' };
|
||||
const result = await WebBrowser.openAuthSessionAsync(authUrl, REDIRECT_URI);
|
||||
if (result.type !== 'success') {
|
||||
return { ok: false, error: result.type === 'cancel' ? 'Cancelled' : 'Browser error' };
|
||||
}
|
||||
|
||||
const code = new URL(result.url).searchParams.get('code');
|
||||
if (!code) return { ok: false, error: 'No code in redirect' };
|
||||
|
||||
const tokenResp = await fetch(`${ISSUER}/oauth2/token`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({
|
||||
grant_type: 'authorization_code',
|
||||
code,
|
||||
redirect_uri: REDIRECT_URI,
|
||||
client_id: CLIENT_ID,
|
||||
code_verifier: verifier,
|
||||
}).toString(),
|
||||
});
|
||||
|
||||
if (!tokenResp.ok) {
|
||||
const text = await tokenResp.text().catch(() => '');
|
||||
return { ok: false, error: `Token exchange failed: ${text}` };
|
||||
}
|
||||
|
||||
const tokenData = await tokenResp.json();
|
||||
const idToken: string = tokenData.id_token;
|
||||
if (!idToken) return { ok: false, error: 'No id_token in response' };
|
||||
|
||||
// Decode payload (no verification needed — server already validated)
|
||||
const payload = JSON.parse(atob(idToken.split('.')[1].replace(/-/g, '+').replace(/_/g, '/')));
|
||||
|
||||
await Promise.all([
|
||||
AsyncStorage.setItem('instanceUrl', ISSUER),
|
||||
AsyncStorage.setItem('handle', payload.sub ?? ''),
|
||||
AsyncStorage.setItem('apiToken', idToken),
|
||||
]);
|
||||
|
||||
return { ok: true, displayName: payload.name ?? payload.preferred_username };
|
||||
}
|
||||
|
||||
export async function logout(): Promise<void> {
|
||||
|
||||
@@ -13,9 +13,18 @@ async function getDb(): Promise<SQLite.SQLiteDatabase> {
|
||||
date TEXT NOT NULL,
|
||||
duration_seconds INTEGER NOT NULL,
|
||||
distance_meters REAL NOT NULL,
|
||||
file_path TEXT NOT NULL
|
||||
file_path TEXT NOT NULL,
|
||||
sport TEXT NOT NULL DEFAULT 'other',
|
||||
sub_sport TEXT
|
||||
);
|
||||
`);
|
||||
// Migrate existing installs that pre-date the sport columns
|
||||
for (const stmt of [
|
||||
"ALTER TABLE recordings ADD COLUMN sport TEXT NOT NULL DEFAULT 'other'",
|
||||
'ALTER TABLE recordings ADD COLUMN sub_sport TEXT',
|
||||
]) {
|
||||
try { await db.execAsync(stmt); } catch { /* column already exists */ }
|
||||
}
|
||||
}
|
||||
return db;
|
||||
}
|
||||
@@ -23,8 +32,8 @@ async function getDb(): Promise<SQLite.SQLiteDatabase> {
|
||||
export async function insertRecording(rec: SavedRecording): Promise<void> {
|
||||
const d = await getDb();
|
||||
await d.runAsync(
|
||||
'INSERT INTO recordings (id, title, date, duration_seconds, distance_meters, file_path) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
[rec.id, rec.title, rec.date, rec.durationSeconds, rec.distanceMeters, rec.filePath],
|
||||
'INSERT INTO recordings (id, title, date, duration_seconds, distance_meters, file_path, sport, sub_sport) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[rec.id, rec.title, rec.date, rec.durationSeconds, rec.distanceMeters, rec.filePath, rec.sport, rec.subSport ?? null],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,9 +47,19 @@ export async function listRecordings(): Promise<SavedRecording[]> {
|
||||
durationSeconds: r.duration_seconds,
|
||||
distanceMeters: r.distance_meters,
|
||||
filePath: r.file_path,
|
||||
sport: r.sport ?? 'other',
|
||||
subSport: r.sub_sport ?? null,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function updateRecording(id: string, fields: { title: string; sport: string; subSport: string | null }): Promise<void> {
|
||||
const d = await getDb();
|
||||
await d.runAsync(
|
||||
'UPDATE recordings SET title = ?, sport = ?, sub_sport = ? WHERE id = ?',
|
||||
[fields.title, fields.sport, fields.subSport ?? null, id],
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteRecording(id: string): Promise<void> {
|
||||
const d = await getDb();
|
||||
await d.runAsync('DELETE FROM recordings WHERE id = ?', [id]);
|
||||
|
||||
@@ -55,6 +55,27 @@ function buildExtensions(pt: TrackPoint): string {
|
||||
</extensions>`;
|
||||
}
|
||||
|
||||
export async function parseGpxFile(fileUri: string): Promise<TrackPoint[]> {
|
||||
const content = await new File(fileUri).text();
|
||||
const points: TrackPoint[] = [];
|
||||
const re = /<trkpt\s+lat="([^"]+)"\s+lon="([^"]+)">([\s\S]*?)<\/trkpt>/g;
|
||||
let m;
|
||||
while ((m = re.exec(content)) !== null) {
|
||||
const lat = parseFloat(m[1]);
|
||||
const lon = parseFloat(m[2]);
|
||||
const inner = m[3];
|
||||
const ele = parseFloat(inner.match(/<ele>([\d.-]+)<\/ele>/)?.[1] ?? '0');
|
||||
const timeStr = inner.match(/<time>([^<]+)<\/time>/)?.[1] ?? '';
|
||||
const hr = parseInt(inner.match(/<gpxtpx:hr>(\d+)<\/gpxtpx:hr>/)?.[1] ?? '') || undefined;
|
||||
const power = parseInt(inner.match(/<gpxtpx:power>(\d+)<\/gpxtpx:power>/)?.[1] ?? '') || undefined;
|
||||
const cad = parseInt(inner.match(/<gpxtpx:cad>(\d+)<\/gpxtpx:cad>/)?.[1] ?? '') || undefined;
|
||||
if (!isNaN(lat) && !isNaN(lon)) {
|
||||
points.push({ lat, lon, ele, time: new Date(timeStr), hr, power, cad });
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
function escapeXml(s: string): string {
|
||||
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import { OfflineManager, type OfflinePackStatus } from '@maplibre/maplibre-react-native';
|
||||
|
||||
type LngLatBounds = [number, number, number, number]; // [west, south, east, north]
|
||||
|
||||
// Vector style URL — only vector styles support offline packs
|
||||
export const OFFLINE_STYLE_URL = 'https://tiles.openfreemap.org/styles/liberty';
|
||||
|
||||
// Zoom levels: 6 (region overview) → 16 (street detail, good for cycling)
|
||||
const MIN_ZOOM = 6;
|
||||
const MAX_ZOOM = 16;
|
||||
|
||||
export interface OfflineRegion {
|
||||
id: string;
|
||||
name: string;
|
||||
bounds: LngLatBounds;
|
||||
createdAt: string;
|
||||
completedTiles: number;
|
||||
totalSizeBytes: number;
|
||||
state: 'active' | 'inactive' | 'complete';
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
// ── Download ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Download a region and return a Promise that resolves only when the pack
|
||||
* reaches state 'complete'. Transient tile-fetch errors (e.g. "stream was
|
||||
* reset: CANCEL") are silently ignored — MapLibre retries them internally
|
||||
* and they do not indicate a failed download.
|
||||
*/
|
||||
export function downloadRegion(
|
||||
name: string,
|
||||
bounds: LngLatBounds,
|
||||
onProgress: (pct: number, tilesDown: number, sizeBytes: number) => void,
|
||||
): Promise<string> {
|
||||
OfflineManager.setProgressEventThrottle(500);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let packId: string;
|
||||
|
||||
OfflineManager.createPack(
|
||||
{
|
||||
mapStyle: OFFLINE_STYLE_URL,
|
||||
bounds,
|
||||
minZoom: MIN_ZOOM,
|
||||
maxZoom: MAX_ZOOM,
|
||||
metadata: { name, createdAt: new Date().toISOString() },
|
||||
},
|
||||
(pack, status: OfflinePackStatus) => {
|
||||
packId = pack.id;
|
||||
onProgress(status.percentage, status.completedTileCount, status.completedTileSize);
|
||||
if (status.state === 'complete') {
|
||||
resolve(packId);
|
||||
}
|
||||
},
|
||||
(_pack, _error) => {
|
||||
// Transient tile-level errors — MapLibre retries these automatically.
|
||||
// Do not reject: the overall download is still in progress.
|
||||
},
|
||||
).catch(reject); // only rejects on createPack failure (e.g. bad style URL)
|
||||
});
|
||||
}
|
||||
|
||||
// ── List ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function listRegions(): Promise<OfflineRegion[]> {
|
||||
const packs = await OfflineManager.getPacks();
|
||||
const regions: OfflineRegion[] = [];
|
||||
|
||||
for (const pack of packs) {
|
||||
const status = await pack.status();
|
||||
const meta = pack.metadata as { name?: string; createdAt?: string };
|
||||
regions.push({
|
||||
id: pack.id,
|
||||
name: meta.name ?? 'Unnamed region',
|
||||
bounds: pack.bounds,
|
||||
createdAt: meta.createdAt ?? '',
|
||||
completedTiles: status.completedTileCount,
|
||||
totalSizeBytes: status.completedTileSize,
|
||||
state: status.state,
|
||||
percentage: status.percentage,
|
||||
});
|
||||
}
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
// ── Delete ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function deleteRegion(id: string): Promise<void> {
|
||||
await OfflineManager.deletePack(id);
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
/** Expand a [w,s,e,n] bounds by `km` kilometres in every direction. */
|
||||
export function expandBounds(bounds: LngLatBounds, km: number): LngLatBounds {
|
||||
const latDelta = km / 111;
|
||||
const lonDelta = km / (111 * Math.cos((bounds[1] + bounds[3]) / 2 * Math.PI / 180));
|
||||
return [
|
||||
bounds[0] - lonDelta,
|
||||
bounds[1] - latDelta,
|
||||
bounds[2] + lonDelta,
|
||||
bounds[3] + latDelta,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// Mirror of bincio_activity sport definitions — keep in sync with
|
||||
// bincio_activity/site/src/lib/types.ts and bincio/extract/sport.py
|
||||
|
||||
export type Sport =
|
||||
| 'cycling' | 'running' | 'hiking'
|
||||
| 'walking' | 'swimming' | 'skiing' | 'other';
|
||||
|
||||
export type SubSport =
|
||||
| 'road' | 'mountain' | 'gravel' | 'indoor' // cycling
|
||||
| 'trail' | 'track' // running (+ indoor shared)
|
||||
| 'open_water' | 'pool' // swimming
|
||||
| 'nordic' | 'alpine'; // skiing
|
||||
|
||||
export const SPORT_ICONS: Record<Sport, string> = {
|
||||
cycling: '🚴',
|
||||
running: '🏃',
|
||||
hiking: '🥾',
|
||||
walking: '🚶',
|
||||
swimming: '🏊',
|
||||
skiing: '⛷️',
|
||||
other: '⚡',
|
||||
};
|
||||
|
||||
export const SPORT_LABELS: Record<Sport, string> = {
|
||||
cycling: 'Cycling',
|
||||
running: 'Running',
|
||||
hiking: 'Hiking',
|
||||
walking: 'Walking',
|
||||
swimming: 'Swimming',
|
||||
skiing: 'Skiing',
|
||||
other: 'Other',
|
||||
};
|
||||
|
||||
export const SUB_SPORT_LABELS: Record<SubSport, string> = {
|
||||
road: 'Road',
|
||||
mountain: 'MTB',
|
||||
gravel: 'Gravel',
|
||||
indoor: 'Indoor',
|
||||
trail: 'Trail',
|
||||
track: 'Track',
|
||||
nordic: 'Nordic',
|
||||
alpine: 'Alpine',
|
||||
open_water: 'Open Water',
|
||||
pool: 'Pool',
|
||||
};
|
||||
|
||||
export const SPORT_SUBTYPES: Partial<Record<Sport, SubSport[]>> = {
|
||||
cycling: ['road', 'mountain', 'gravel', 'indoor'],
|
||||
running: ['trail', 'track', 'indoor'],
|
||||
swimming: ['open_water', 'pool'],
|
||||
skiing: ['nordic', 'alpine'],
|
||||
};
|
||||
|
||||
export const ALL_SPORTS: Sport[] = [
|
||||
'cycling', 'running', 'hiking', 'walking', 'swimming', 'skiing', 'other',
|
||||
];
|
||||
@@ -35,12 +35,15 @@ export interface SavedRecording {
|
||||
durationSeconds: number;
|
||||
distanceMeters: number;
|
||||
filePath: string;
|
||||
sport: string;
|
||||
subSport: string | null;
|
||||
}
|
||||
|
||||
export type RootStackParamList = {
|
||||
Tabs: undefined;
|
||||
PostRecording: undefined;
|
||||
SensorPairing: undefined;
|
||||
ActivityDetail: { recording: SavedRecording };
|
||||
};
|
||||
|
||||
export type TabParamList = {
|
||||
|
||||