diff --git "a/java/Java/Markdown\350\256\276\350\256\241\346\226\207\346\241\243.md" "b/java/Java/Markdown\350\256\276\350\256\241\346\226\207\346\241\243.md" new file mode 100644 index 000000000..ad1e061c7 --- /dev/null +++ "b/java/Java/Markdown\350\256\276\350\256\241\346\226\207\346\241\243.md" @@ -0,0 +1,18 @@ +# 获取短链接接口流程 +1. 取出参数longLink +2. 判断是否为空: +3. 如果为空,直接返回空 +4. 否则: 在内存map中判断是否存在key为longLink的值 +5. 如果存在,返回map中key为longLink对应的value +6. 否则: 将longLink生成唯一的hash编码值:long型编码 +7. 将long型编码通过base62,通过求余拼接成最终结果字符串String +8. 将String存入map中,并做为接口返回值 + +# 获取长链接接口流程 +1. 取出参数shortLink +2. 判断是否为空: +3. 如果为空,直接返回空 +4. 否则: 在内存map中遍历寻找value为shortLink的值 +5. 如果存在:直接返回key +6. 否则: 返回空 + diff --git a/java/Java/sequoia/.gitignore b/java/Java/sequoia/.gitignore new file mode 100644 index 000000000..549e00a2a --- /dev/null +++ b/java/Java/sequoia/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/java/Java/sequoia/.mvn/wrapper/maven-wrapper.jar b/java/Java/sequoia/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 000000000..cb28b0e37 Binary files /dev/null and b/java/Java/sequoia/.mvn/wrapper/maven-wrapper.jar differ diff --git a/java/Java/sequoia/.mvn/wrapper/maven-wrapper.properties b/java/Java/sequoia/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 000000000..5f0536eb7 --- /dev/null +++ b/java/Java/sequoia/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/java/Java/sequoia/mvnw b/java/Java/sequoia/mvnw new file mode 100755 index 000000000..66df28542 --- /dev/null +++ b/java/Java/sequoia/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/java/Java/sequoia/mvnw.cmd b/java/Java/sequoia/mvnw.cmd new file mode 100644 index 000000000..95ba6f54a --- /dev/null +++ b/java/Java/sequoia/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/java/Java/sequoia/pom.xml b/java/Java/sequoia/pom.xml new file mode 100644 index 000000000..8c679c20e --- /dev/null +++ b/java/Java/sequoia/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.6 + + + com.example + sequoia + 0.0.1-SNAPSHOT + demo + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + + com.google.guava + guava + 31.1-jre + + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + junit + junit + 4.13.2 + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/java/Java/sequoia/src/main/java/com/example/sequoia/DemoApplication.java b/java/Java/sequoia/src/main/java/com/example/sequoia/DemoApplication.java new file mode 100644 index 000000000..4319bdb82 --- /dev/null +++ b/java/Java/sequoia/src/main/java/com/example/sequoia/DemoApplication.java @@ -0,0 +1,13 @@ +package com.example.sequoia; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootApplication +@EnableSwagger2 +public class DemoApplication { + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } +} diff --git a/java/Java/sequoia/src/main/java/com/example/sequoia/config/SwaggerConfig.java b/java/Java/sequoia/src/main/java/com/example/sequoia/config/SwaggerConfig.java new file mode 100644 index 000000000..ffbd6c621 --- /dev/null +++ b/java/Java/sequoia/src/main/java/com/example/sequoia/config/SwaggerConfig.java @@ -0,0 +1,38 @@ +package com.example.sequoia.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import static springfox.documentation.builders.PathSelectors.regex; + +/** + * @author xurui + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .paths(regex("/api/.*")) // 只为/api路径下的接口生成文档 + .build() + .apiInfo(apiInfo()); + } + + private ApiInfo apiInfo() { + return new ApiInfo( + "短链接服务", + "短链接服务swagger文档", + "1.0", + "urn:tos", + "徐锐", + "My Organization", + "My License Type" + ); + } +} diff --git a/java/Java/sequoia/src/main/java/com/example/sequoia/controller/Domain.java b/java/Java/sequoia/src/main/java/com/example/sequoia/controller/Domain.java new file mode 100644 index 000000000..8c072328a --- /dev/null +++ b/java/Java/sequoia/src/main/java/com/example/sequoia/controller/Domain.java @@ -0,0 +1,33 @@ +package com.example.sequoia.controller; + +import com.example.sequoia.service.DomainService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author xurui + */ +@RestController +@RequestMapping("/api") +public class Domain { + private DomainService service; + + @RequestMapping(value = "/shortLink") + @ApiOperation(value = "获取长链接对应的短链接", response = String.class, httpMethod = "GET") + public String shortLink(String longLink) { + return service.getShortLink(longLink); + } + + @RequestMapping(value = "/longLink") + @ApiOperation(value = "获取短链接对应的长链接", response = String.class, httpMethod = "GET") + public String longLink(String shortLink) { + return service.getLongLink(shortLink); + } + + @Autowired + public void setService(DomainService service) { + this.service = service; + } +} diff --git a/java/Java/sequoia/src/main/java/com/example/sequoia/service/Base62Utils.java b/java/Java/sequoia/src/main/java/com/example/sequoia/service/Base62Utils.java new file mode 100644 index 000000000..51af5e82d --- /dev/null +++ b/java/Java/sequoia/src/main/java/com/example/sequoia/service/Base62Utils.java @@ -0,0 +1,31 @@ +package com.example.sequoia.service; + +/** + * 短链接 - 工具类 + * @author xurui + */ +public class Base62Utils { + private static final int RESULT_MAX_LENGTH = 8; + private static final int SCALE = 62; + private static final char[] BASE_62_ARRAY = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + }; + + /** + * 将long类型编码成Base62字符串 + * @param num:长链接生成的hash编码 + * @return 最终生成的短链接 + */ + public static String encodeToBase62String(long num) { + StringBuilder sb = new StringBuilder(); + while (num > 0 && sb.length() < RESULT_MAX_LENGTH) { + sb.insert(0, BASE_62_ARRAY[(int) (num % SCALE)]); + num /= SCALE; + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/java/Java/sequoia/src/main/java/com/example/sequoia/service/DomainService.java b/java/Java/sequoia/src/main/java/com/example/sequoia/service/DomainService.java new file mode 100644 index 000000000..14ec7ee4c --- /dev/null +++ b/java/Java/sequoia/src/main/java/com/example/sequoia/service/DomainService.java @@ -0,0 +1,72 @@ +package com.example.sequoia.service; + +import com.google.common.hash.Hashing; +import org.springframework.stereotype.Service; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +/** + * @author xurui + */ +@Service +public class DomainService { + + /** + * 长链接对应的短链接map + * key:长链接 + * value:长链接 + */ + private final Map urlMap = new HashMap<>(); + + /** + * 获取长链接对应的短链接 + * @param longLink:长链接 + * @return 短链接 + */ + public String getShortLink(String longLink) { + if (null == longLink || longLink.length() == 0) { + return ""; + } + //在内存中找,找不到再创建新的 + String shortUrl = urlMap.get(longLink); + if (null != shortUrl) { + return shortUrl; + } + shortUrl = generateShortUrl(longLink); + //存入map + if (null != shortUrl) { + urlMap.put(longLink, shortUrl); + } + return shortUrl; + } + + /** + * 获取短链接对应的长链接 + * @param shortLink:短链接 + * @return 长链接 + */ + public String getLongLink(String shortLink) { + if (null == shortLink || shortLink.length() == 0) { + return ""; + } + for (Map.Entry entry : urlMap.entrySet()) { + if (entry.getValue().equals(shortLink)) { + return entry.getKey(); + } + } + return ""; + } + + /** + * 将长链接专成短链接 + * @param longLink:长链接 + * @return 短链接 + */ + public String generateShortUrl(String longLink) { + long longLinkHash = Hashing.murmur3_32_fixed().hashString(longLink, StandardCharsets.UTF_8).padToLong(); + return Base62Utils.encodeToBase62String(Math.abs(longLinkHash)); + } + +} diff --git a/java/Java/sequoia/src/main/resources/application.properties b/java/Java/sequoia/src/main/resources/application.properties new file mode 100644 index 000000000..2109a440d --- /dev/null +++ b/java/Java/sequoia/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=demo diff --git a/java/Java/sequoia/src/test/java/com/example/sequoia/DemoApplicationTests.java b/java/Java/sequoia/src/test/java/com/example/sequoia/DemoApplicationTests.java new file mode 100644 index 000000000..3c8c6a748 --- /dev/null +++ b/java/Java/sequoia/src/test/java/com/example/sequoia/DemoApplicationTests.java @@ -0,0 +1,35 @@ +package com.example.sequoia; + +import com.example.sequoia.controller.Domain; +import com.example.sequoia.service.DomainService; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void apiTest() { + Domain domain = new Domain(); + domain.setService(new DomainService()); + + Assertions.assertEquals(domain.shortLink(""), ""); + Assertions.assertEquals(domain.longLink(""), ""); + + String longUrl = "https://www.baidu.com"; + String encodeUrl = "Ee79ti"; + + String shortLink1 = domain.shortLink(longUrl); + Assertions.assertEquals(shortLink1, encodeUrl); + + String shortLink2 = domain.shortLink(longUrl); + Assertions.assertEquals(shortLink2, encodeUrl); + + String longLink1 = domain.longLink(encodeUrl); + Assertions.assertEquals(longLink1, longUrl); + + String longLink2 = domain.longLink("ABCDEFG"); + Assertions.assertEquals(longLink2, ""); + } +} diff --git "a/java/Java/\345\215\225\345\205\203\346\265\213\350\257\225\350\246\206\347\233\226\346\210\252\345\233\276.jpg" "b/java/Java/\345\215\225\345\205\203\346\265\213\350\257\225\350\246\206\347\233\226\346\210\252\345\233\276.jpg" new file mode 100644 index 000000000..8d5ea5f86 Binary files /dev/null and "b/java/Java/\345\215\225\345\205\203\346\265\213\350\257\225\350\246\206\347\233\226\346\210\252\345\233\276.jpg" differ diff --git "a/java/Java/\350\216\267\345\217\226\351\225\277\351\223\276\346\216\245\347\232\204\347\237\255\351\223\276\346\216\245\346\265\201\347\250\213\345\233\276.jpg" "b/java/Java/\350\216\267\345\217\226\351\225\277\351\223\276\346\216\245\347\232\204\347\237\255\351\223\276\346\216\245\346\265\201\347\250\213\345\233\276.jpg" new file mode 100644 index 000000000..32113e1d6 Binary files /dev/null and "b/java/Java/\350\216\267\345\217\226\351\225\277\351\223\276\346\216\245\347\232\204\347\237\255\351\223\276\346\216\245\346\265\201\347\250\213\345\233\276.jpg" differ diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/project.pbxproj b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.pbxproj new file mode 100644 index 000000000..41b91d09b --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.pbxproj @@ -0,0 +1,699 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 5B10D62F2BC4FE560096C0D5 /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B10D62E2BC4FE560096C0D5 /* ActivityIndicator.swift */; }; + 5B615DBD2BC3B0A800DD4086 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B615DBC2BC3B0A800DD4086 /* ImageCache.swift */; }; + 5B615DBF2BC3B44E00DD4086 /* ImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B615DBE2BC3B44E00DD4086 /* ImageLoader.swift */; }; + 5B615DC12BC3C09500DD4086 /* AsyncImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B615DC02BC3C09500DD4086 /* AsyncImage.swift */; }; + 5B615DC32BC3EECA00DD4086 /* EnvironmentValues+ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B615DC22BC3EECA00DD4086 /* EnvironmentValues+ImageCache.swift */; }; + 5B6E90912BBE75940089F037 /* AppleNetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6E90902BBE75940089F037 /* AppleNetData.swift */; }; + 5B6E90942BBE782C0089F037 /* DataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6E90932BBE782C0089F037 /* DataManager.swift */; }; + 5B6E90962BBE79D40089F037 /* AppleNetResultData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6E90952BBE79D40089F037 /* AppleNetResultData.swift */; }; + 5B7188592BC63283007C63FC /* Refresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7188582BC63283007C63FC /* Refresh.swift */; }; + 5B71885F2BC634BC007C63FC /* Footer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B71885E2BC634BC007C63FC /* Footer.swift */; }; + 5B7188612BC634EB007C63FC /* FooterKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7188602BC634EB007C63FC /* FooterKey.swift */; }; + 5B7188632BC6351C007C63FC /* List+Refresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7188622BC6351C007C63FC /* List+Refresh.swift */; }; + 5B7188652BC63533007C63FC /* Modifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7188642BC63533007C63FC /* Modifier.swift */; }; + 5B7188672BC63583007C63FC /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7188662BC63583007C63FC /* Utilities.swift */; }; + 5B9526572BC80B84003FD723 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B9526552BC80B84003FD723 /* Header.swift */; }; + 5B9526582BC80B84003FD723 /* HeaderKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B9526562BC80B84003FD723 /* HeaderKey.swift */; }; + 5BA7C2F92BBD699600B405B6 /* SequoiaApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C2F82BBD699600B405B6 /* SequoiaApp.swift */; }; + 5BA7C2FB2BBD699600B405B6 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C2FA2BBD699600B405B6 /* ContentView.swift */; }; + 5BA7C2FD2BBD699700B405B6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5BA7C2FC2BBD699700B405B6 /* Assets.xcassets */; }; + 5BA7C3002BBD699700B405B6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5BA7C2FF2BBD699700B405B6 /* Preview Assets.xcassets */; }; + 5BA7C30A2BBD699800B405B6 /* SequoiaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C3092BBD699800B405B6 /* SequoiaTests.swift */; }; + 5BA7C3142BBD699800B405B6 /* SequoiaUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C3132BBD699800B405B6 /* SequoiaUITests.swift */; }; + 5BA7C3162BBD699800B405B6 /* SequoiaUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C3152BBD699800B405B6 /* SequoiaUITestsLaunchTests.swift */; }; + 5BA7C3232BBD6B9400B405B6 /* SequoiaListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C3222BBD6B9400B405B6 /* SequoiaListView.swift */; }; + 5BA7C32C2BBD6DDB00B405B6 /* AppleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C32B2BBD6DDB00B405B6 /* AppleData.swift */; }; + 5BA7C32E2BBD8AE200B405B6 /* SequoialRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C32D2BBD8AE200B405B6 /* SequoialRow.swift */; }; + 5BA7C3302BBD94ED00B405B6 /* AppleResultData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7C32F2BBD94ED00B405B6 /* AppleResultData.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 5BA7C3062BBD699800B405B6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 5BA7C2ED2BBD699600B405B6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5BA7C2F42BBD699600B405B6; + remoteInfo = Sequoia; + }; + 5BA7C3102BBD699800B405B6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 5BA7C2ED2BBD699600B405B6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5BA7C2F42BBD699600B405B6; + remoteInfo = Sequoia; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 5B10D62E2BC4FE560096C0D5 /* ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = ""; }; + 5B615DBC2BC3B0A800DD4086 /* ImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCache.swift; sourceTree = ""; }; + 5B615DBE2BC3B44E00DD4086 /* ImageLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLoader.swift; sourceTree = ""; }; + 5B615DC02BC3C09500DD4086 /* AsyncImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncImage.swift; sourceTree = ""; }; + 5B615DC22BC3EECA00DD4086 /* EnvironmentValues+ImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EnvironmentValues+ImageCache.swift"; sourceTree = ""; }; + 5B6E90902BBE75940089F037 /* AppleNetData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleNetData.swift; sourceTree = ""; }; + 5B6E90932BBE782C0089F037 /* DataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataManager.swift; sourceTree = ""; }; + 5B6E90952BBE79D40089F037 /* AppleNetResultData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleNetResultData.swift; sourceTree = ""; }; + 5B7188582BC63283007C63FC /* Refresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Refresh.swift; sourceTree = ""; }; + 5B71885E2BC634BC007C63FC /* Footer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Footer.swift; sourceTree = ""; }; + 5B7188602BC634EB007C63FC /* FooterKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterKey.swift; sourceTree = ""; }; + 5B7188622BC6351C007C63FC /* List+Refresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "List+Refresh.swift"; sourceTree = ""; }; + 5B7188642BC63533007C63FC /* Modifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modifier.swift; sourceTree = ""; }; + 5B7188662BC63583007C63FC /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = ""; }; + 5B9526552BC80B84003FD723 /* Header.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; + 5B9526562BC80B84003FD723 /* HeaderKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderKey.swift; sourceTree = ""; }; + 5BA7C2F52BBD699600B405B6 /* Sequoia.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sequoia.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5BA7C2F82BBD699600B405B6 /* SequoiaApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoiaApp.swift; sourceTree = ""; }; + 5BA7C2FA2BBD699600B405B6 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 5BA7C2FC2BBD699700B405B6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 5BA7C2FF2BBD699700B405B6 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 5BA7C3052BBD699800B405B6 /* SequoiaTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SequoiaTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5BA7C3092BBD699800B405B6 /* SequoiaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoiaTests.swift; sourceTree = ""; }; + 5BA7C30F2BBD699800B405B6 /* SequoiaUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SequoiaUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5BA7C3132BBD699800B405B6 /* SequoiaUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoiaUITests.swift; sourceTree = ""; }; + 5BA7C3152BBD699800B405B6 /* SequoiaUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoiaUITestsLaunchTests.swift; sourceTree = ""; }; + 5BA7C3222BBD6B9400B405B6 /* SequoiaListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoiaListView.swift; sourceTree = ""; }; + 5BA7C32B2BBD6DDB00B405B6 /* AppleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleData.swift; sourceTree = ""; }; + 5BA7C32D2BBD8AE200B405B6 /* SequoialRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequoialRow.swift; sourceTree = ""; }; + 5BA7C32F2BBD94ED00B405B6 /* AppleResultData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleResultData.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5BA7C2F22BBD699600B405B6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C3022BBD699800B405B6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C30C2BBD699800B405B6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 5B6E90922BBE78200089F037 /* Manager */ = { + isa = PBXGroup; + children = ( + 5B6E90932BBE782C0089F037 /* DataManager.swift */, + 5B615DBC2BC3B0A800DD4086 /* ImageCache.swift */, + 5B615DBE2BC3B44E00DD4086 /* ImageLoader.swift */, + 5B615DC02BC3C09500DD4086 /* AsyncImage.swift */, + 5B615DC22BC3EECA00DD4086 /* EnvironmentValues+ImageCache.swift */, + ); + path = Manager; + sourceTree = ""; + }; + 5B7188552BC62E84007C63FC /* refresh */ = { + isa = PBXGroup; + children = ( + 5B7188582BC63283007C63FC /* Refresh.swift */, + 5B9526552BC80B84003FD723 /* Header.swift */, + 5B9526562BC80B84003FD723 /* HeaderKey.swift */, + 5B71885E2BC634BC007C63FC /* Footer.swift */, + 5B7188602BC634EB007C63FC /* FooterKey.swift */, + 5B7188622BC6351C007C63FC /* List+Refresh.swift */, + 5B7188642BC63533007C63FC /* Modifier.swift */, + 5B7188662BC63583007C63FC /* Utilities.swift */, + ); + path = refresh; + sourceTree = ""; + }; + 5BA7C2EC2BBD699600B405B6 = { + isa = PBXGroup; + children = ( + 5BA7C2F72BBD699600B405B6 /* Sequoia */, + 5BA7C3082BBD699800B405B6 /* SequoiaTests */, + 5BA7C3122BBD699800B405B6 /* SequoiaUITests */, + 5BA7C2F62BBD699600B405B6 /* Products */, + ); + sourceTree = ""; + }; + 5BA7C2F62BBD699600B405B6 /* Products */ = { + isa = PBXGroup; + children = ( + 5BA7C2F52BBD699600B405B6 /* Sequoia.app */, + 5BA7C3052BBD699800B405B6 /* SequoiaTests.xctest */, + 5BA7C30F2BBD699800B405B6 /* SequoiaUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 5BA7C2F72BBD699600B405B6 /* Sequoia */ = { + isa = PBXGroup; + children = ( + 5BA7C2F82BBD699600B405B6 /* SequoiaApp.swift */, + 5BA7C2FA2BBD699600B405B6 /* ContentView.swift */, + 5B6E90922BBE78200089F037 /* Manager */, + 5BA7C3252BBD6CE300B405B6 /* Model */, + 5BA7C3242BBD6CDB00B405B6 /* Views */, + 5BA7C2FC2BBD699700B405B6 /* Assets.xcassets */, + 5BA7C2FE2BBD699700B405B6 /* Preview Content */, + ); + path = Sequoia; + sourceTree = ""; + }; + 5BA7C2FE2BBD699700B405B6 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 5BA7C2FF2BBD699700B405B6 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 5BA7C3082BBD699800B405B6 /* SequoiaTests */ = { + isa = PBXGroup; + children = ( + 5BA7C3092BBD699800B405B6 /* SequoiaTests.swift */, + ); + path = SequoiaTests; + sourceTree = ""; + }; + 5BA7C3122BBD699800B405B6 /* SequoiaUITests */ = { + isa = PBXGroup; + children = ( + 5BA7C3132BBD699800B405B6 /* SequoiaUITests.swift */, + 5BA7C3152BBD699800B405B6 /* SequoiaUITestsLaunchTests.swift */, + ); + path = SequoiaUITests; + sourceTree = ""; + }; + 5BA7C3242BBD6CDB00B405B6 /* Views */ = { + isa = PBXGroup; + children = ( + 5BA7C3222BBD6B9400B405B6 /* SequoiaListView.swift */, + 5BA7C32D2BBD8AE200B405B6 /* SequoialRow.swift */, + 5B10D62E2BC4FE560096C0D5 /* ActivityIndicator.swift */, + 5B7188552BC62E84007C63FC /* refresh */, + ); + path = Views; + sourceTree = ""; + }; + 5BA7C3252BBD6CE300B405B6 /* Model */ = { + isa = PBXGroup; + children = ( + 5BA7C32B2BBD6DDB00B405B6 /* AppleData.swift */, + 5B6E90902BBE75940089F037 /* AppleNetData.swift */, + 5BA7C32F2BBD94ED00B405B6 /* AppleResultData.swift */, + 5B6E90952BBE79D40089F037 /* AppleNetResultData.swift */, + ); + path = Model; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 5BA7C2F42BBD699600B405B6 /* Sequoia */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5BA7C3192BBD699800B405B6 /* Build configuration list for PBXNativeTarget "Sequoia" */; + buildPhases = ( + 5BA7C2F12BBD699600B405B6 /* Sources */, + 5BA7C2F22BBD699600B405B6 /* Frameworks */, + 5BA7C2F32BBD699600B405B6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Sequoia; + productName = Sequoia; + productReference = 5BA7C2F52BBD699600B405B6 /* Sequoia.app */; + productType = "com.apple.product-type.application"; + }; + 5BA7C3042BBD699800B405B6 /* SequoiaTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5BA7C31C2BBD699800B405B6 /* Build configuration list for PBXNativeTarget "SequoiaTests" */; + buildPhases = ( + 5BA7C3012BBD699800B405B6 /* Sources */, + 5BA7C3022BBD699800B405B6 /* Frameworks */, + 5BA7C3032BBD699800B405B6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 5BA7C3072BBD699800B405B6 /* PBXTargetDependency */, + ); + name = SequoiaTests; + productName = SequoiaTests; + productReference = 5BA7C3052BBD699800B405B6 /* SequoiaTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 5BA7C30E2BBD699800B405B6 /* SequoiaUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5BA7C31F2BBD699800B405B6 /* Build configuration list for PBXNativeTarget "SequoiaUITests" */; + buildPhases = ( + 5BA7C30B2BBD699800B405B6 /* Sources */, + 5BA7C30C2BBD699800B405B6 /* Frameworks */, + 5BA7C30D2BBD699800B405B6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 5BA7C3112BBD699800B405B6 /* PBXTargetDependency */, + ); + name = SequoiaUITests; + productName = SequoiaUITests; + productReference = 5BA7C30F2BBD699800B405B6 /* SequoiaUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5BA7C2ED2BBD699600B405B6 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1500; + LastUpgradeCheck = 1500; + TargetAttributes = { + 5BA7C2F42BBD699600B405B6 = { + CreatedOnToolsVersion = 15.0.1; + }; + 5BA7C3042BBD699800B405B6 = { + CreatedOnToolsVersion = 15.0.1; + TestTargetID = 5BA7C2F42BBD699600B405B6; + }; + 5BA7C30E2BBD699800B405B6 = { + CreatedOnToolsVersion = 15.0.1; + TestTargetID = 5BA7C2F42BBD699600B405B6; + }; + }; + }; + buildConfigurationList = 5BA7C2F02BBD699600B405B6 /* Build configuration list for PBXProject "Sequoia" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 5BA7C2EC2BBD699600B405B6; + productRefGroup = 5BA7C2F62BBD699600B405B6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5BA7C2F42BBD699600B405B6 /* Sequoia */, + 5BA7C3042BBD699800B405B6 /* SequoiaTests */, + 5BA7C30E2BBD699800B405B6 /* SequoiaUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5BA7C2F32BBD699600B405B6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5BA7C3002BBD699700B405B6 /* Preview Assets.xcassets in Resources */, + 5BA7C2FD2BBD699700B405B6 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C3032BBD699800B405B6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C30D2BBD699800B405B6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5BA7C2F12BBD699600B405B6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5B71885F2BC634BC007C63FC /* Footer.swift in Sources */, + 5B7188672BC63583007C63FC /* Utilities.swift in Sources */, + 5B9526582BC80B84003FD723 /* HeaderKey.swift in Sources */, + 5B615DBD2BC3B0A800DD4086 /* ImageCache.swift in Sources */, + 5B6E90912BBE75940089F037 /* AppleNetData.swift in Sources */, + 5BA7C32C2BBD6DDB00B405B6 /* AppleData.swift in Sources */, + 5BA7C2FB2BBD699600B405B6 /* ContentView.swift in Sources */, + 5B10D62F2BC4FE560096C0D5 /* ActivityIndicator.swift in Sources */, + 5B615DC12BC3C09500DD4086 /* AsyncImage.swift in Sources */, + 5BA7C3302BBD94ED00B405B6 /* AppleResultData.swift in Sources */, + 5B615DBF2BC3B44E00DD4086 /* ImageLoader.swift in Sources */, + 5B9526572BC80B84003FD723 /* Header.swift in Sources */, + 5B6E90962BBE79D40089F037 /* AppleNetResultData.swift in Sources */, + 5B7188612BC634EB007C63FC /* FooterKey.swift in Sources */, + 5BA7C3232BBD6B9400B405B6 /* SequoiaListView.swift in Sources */, + 5BA7C2F92BBD699600B405B6 /* SequoiaApp.swift in Sources */, + 5B7188632BC6351C007C63FC /* List+Refresh.swift in Sources */, + 5B6E90942BBE782C0089F037 /* DataManager.swift in Sources */, + 5B7188592BC63283007C63FC /* Refresh.swift in Sources */, + 5BA7C32E2BBD8AE200B405B6 /* SequoialRow.swift in Sources */, + 5B615DC32BC3EECA00DD4086 /* EnvironmentValues+ImageCache.swift in Sources */, + 5B7188652BC63533007C63FC /* Modifier.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C3012BBD699800B405B6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5BA7C30A2BBD699800B405B6 /* SequoiaTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BA7C30B2BBD699800B405B6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5BA7C3162BBD699800B405B6 /* SequoiaUITestsLaunchTests.swift in Sources */, + 5BA7C3142BBD699800B405B6 /* SequoiaUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 5BA7C3072BBD699800B405B6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5BA7C2F42BBD699600B405B6 /* Sequoia */; + targetProxy = 5BA7C3062BBD699800B405B6 /* PBXContainerItemProxy */; + }; + 5BA7C3112BBD699800B405B6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5BA7C2F42BBD699600B405B6 /* Sequoia */; + targetProxy = 5BA7C3102BBD699800B405B6 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 5BA7C3172BBD699800B405B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 5BA7C3182BBD699800B405B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5BA7C31A2BBD699800B405B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Sequoia/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.Sequoia; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5BA7C31B2BBD699800B405B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Sequoia/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.Sequoia; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5BA7C31D2BBD699800B405B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.SequoiaTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sequoia.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Sequoia"; + }; + name = Debug; + }; + 5BA7C31E2BBD699800B405B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.SequoiaTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sequoia.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Sequoia"; + }; + name = Release; + }; + 5BA7C3202BBD699800B405B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.SequoiaUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Sequoia; + }; + name = Debug; + }; + 5BA7C3212BBD699800B405B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = Mucang.SequoiaUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Sequoia; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5BA7C2F02BBD699600B405B6 /* Build configuration list for PBXProject "Sequoia" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5BA7C3172BBD699800B405B6 /* Debug */, + 5BA7C3182BBD699800B405B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5BA7C3192BBD699800B405B6 /* Build configuration list for PBXNativeTarget "Sequoia" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5BA7C31A2BBD699800B405B6 /* Debug */, + 5BA7C31B2BBD699800B405B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5BA7C31C2BBD699800B405B6 /* Build configuration list for PBXNativeTarget "SequoiaTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5BA7C31D2BBD699800B405B6 /* Debug */, + 5BA7C31E2BBD699800B405B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5BA7C31F2BBD699800B405B6 /* Build configuration list for PBXNativeTarget "SequoiaUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5BA7C3202BBD699800B405B6 /* Debug */, + 5BA7C3212BBD699800B405B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5BA7C2ED2BBD699600B405B6 /* Project object */; +} diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcuserdata/xurui.xcuserdatad/UserInterfaceState.xcuserstate b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcuserdata/xurui.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 000000000..4a7a09968 Binary files /dev/null and b/swift/iOS/Sequoia/Sequoia.xcodeproj/project.xcworkspace/xcuserdata/xurui.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 000000000..bc048ce5f --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcschemes/xcschememanagement.plist b/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 000000000..e70e46bb1 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia.xcodeproj/xcuserdata/xurui.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Sequoia.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AccentColor.colorset/Contents.json b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AppIcon.appiconset/Contents.json b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..13613e3ee --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Assets.xcassets/Contents.json b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swift/iOS/Sequoia/Sequoia/ContentView.swift b/swift/iOS/Sequoia/Sequoia/ContentView.swift new file mode 100644 index 000000000..f823c82c3 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/ContentView.swift @@ -0,0 +1,18 @@ +// +// ContentView.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + SequoiaListView() + } +} + +#Preview { + ContentView() +} diff --git a/swift/iOS/Sequoia/Sequoia/Manager/AsyncImage.swift b/swift/iOS/Sequoia/Sequoia/Manager/AsyncImage.swift new file mode 100644 index 000000000..abbd49e19 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Manager/AsyncImage.swift @@ -0,0 +1,35 @@ +// +// AsyncImage.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +struct AsyncImage: View { + @StateObject private var loader: ImageLoader + private let placeholder: Placeholder + private let image: (UIImage) -> Image + + init(url: URL, @ViewBuilder placeholder: () -> Placeholder, + @ViewBuilder image: @escaping (UIImage) -> Image = Image.init(uiImage:)) { + self.placeholder = placeholder() + self.image = image + _loader = StateObject(wrappedValue: ImageLoader(url: url, cache: Environment(\.imageCache).wrappedValue)) + } + + var body: some View { + content.onAppear(perform: loader.load) + } + + private var content: some View { + Group { + if loader.image != nil { + image(loader.image!) + } else { + placeholder + } + } + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Manager/DataManager.swift b/swift/iOS/Sequoia/Sequoia/Manager/DataManager.swift new file mode 100644 index 000000000..9e5589be2 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Manager/DataManager.swift @@ -0,0 +1,56 @@ +// +// DataManager.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation + +@Observable +class DataManager { + static let instance : DataManager = DataManager(); + + public var appleDatas: AppleResultData = AppleResultData() + + init() { + getDataFromNet(loadingMore: false) + } + + func loadNetData(appleNetDatas: AppleNetResultData) { + //转换成UI用的数据 + var appleDatas = AppleResultData() + appleDatas.resultCount = appleNetDatas.resultCount + appleDatas.results = [] + for netData in appleNetDatas.results { + var appleData: AppleData = AppleData() + appleData.id = netData.trackId + appleData.trackId = netData.trackId + appleData.artworkUrl60 = netData.artworkUrl60 + appleData.trackName = netData.trackName + appleData.description = netData.description + appleDatas.results.append(appleData) + } + self.appleDatas = appleDatas + } + + func getDataFromNet(loadingMore: Bool) { + //这里的翻页试了一下,怎么传page都不行,只能直接把limit取大了,最多只有100 + let limit = loadingMore ? 100 : 50 + let urlString = "https://itunes.apple.com/search?entity=software&limit=\(limit)&term=chat" + let url = URL(string: urlString)! + URLSession.shared.dataTask(with: url){(data, response, error) in + if data == nil { + print("data == nil") + return + } + do { + let appleNetDatas = try JSONDecoder().decode(AppleNetResultData.self, from: data!) + self.loadNetData(appleNetDatas: appleNetDatas) + } + catch { + print(error) + } + }.resume() + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Manager/EnvironmentValues+ImageCache.swift b/swift/iOS/Sequoia/Sequoia/Manager/EnvironmentValues+ImageCache.swift new file mode 100644 index 000000000..25ef30406 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Manager/EnvironmentValues+ImageCache.swift @@ -0,0 +1,19 @@ +// +// EnvironmentValues+ImageCache.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +struct ImageCacheKey: EnvironmentKey { + static let defaultValue: ImageCache = TemporarImageCache() +} + +extension EnvironmentValues { + var imageCache: ImageCache { + get { self[ImageCacheKey.self] } + set { self[ImageCacheKey.self] = newValue } + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Manager/ImageCache.swift b/swift/iOS/Sequoia/Sequoia/Manager/ImageCache.swift new file mode 100644 index 000000000..5f24d5874 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Manager/ImageCache.swift @@ -0,0 +1,33 @@ +// +// ImageCache.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import UIKit +import Foundation + +protocol ImageCache { + subscript(_ url: URL) -> UIImage? { get set } +} + +struct TemporarImageCache: ImageCache { + private let cache: NSCache = { + let cache = NSCache() + cache.countLimit = 100 + cache.totalCostLimit = 1024 * 1024 * 100 + return cache + }() + + subscript(url: URL) -> UIImage? { + get { + cache.object(forKey: url as NSURL) + } + + set { + let keyUrl: NSURL = url as NSURL + newValue == nil ? cache.removeObject(forKey: keyUrl) : cache.setObject(newValue!, forKey: keyUrl) + } + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Manager/ImageLoader.swift b/swift/iOS/Sequoia/Sequoia/Manager/ImageLoader.swift new file mode 100644 index 000000000..ceab04833 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Manager/ImageLoader.swift @@ -0,0 +1,75 @@ +// +// ImageLoader.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Combine +import UIKit + +class ImageLoader: ObservableObject { + @Published var image: UIImage? + + private(set) var isLoading = false + private let url: URL + private var cache: ImageCache? + private var cancellable: AnyCancellable? + + private static let imageProcessingQueue = DispatchQueue(label: "image-loader") + + init(image: UIImage? = nil, isLoading: Bool = false, url: URL, cache: ImageCache? = nil, cancellable: AnyCancellable? = nil) { + self.image = image + self.isLoading = isLoading + self.url = url + self.cache = cache + self.cancellable = cancellable + } + + init(url: URL, cache: ImageCache? = nil) { + self.url = url + self.cache = cache + } + + deinit { + cancel() + } + public func cancel() { + cancellable?.cancel() + } + + public func load() { + guard !isLoading else { + return + } + + if let image = cache?[url] { + self.image = image + return + } + + cancellable = URLSession.shared.dataTaskPublisher(for: url) + .map { UIImage(data: $0.data) } + .replaceError(with: nil) + .handleEvents(receiveSubscription: { [weak self] _ in self?.onStart() }, + receiveOutput: { [weak self] in self?.cache($0) }, + receiveCompletion: { [weak self] _ in self?.onFinish() }, + receiveCancel: { [weak self] in self?.onFinish() }) + .subscribe(on: Self.imageProcessingQueue) + .receive(on: DispatchQueue.main) + .sink { [weak self] in self?.image = $0 } + } + + private func onStart() { + isLoading = true + } + + private func onFinish() { + isLoading = false + } + + private func cache(_ image: UIImage?) { + image.map { cache?[url] = $0 } + } + +} diff --git a/swift/iOS/Sequoia/Sequoia/Model/AppleData.swift b/swift/iOS/Sequoia/Sequoia/Model/AppleData.swift new file mode 100644 index 000000000..7c94dcd4b --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Model/AppleData.swift @@ -0,0 +1,22 @@ +// +// AppleData.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation + +struct AppleData: Hashable, Codable, Identifiable { + //id + var id: Int = 0 + var trackId: Int = 0 + //图标url + var artworkUrl60: String = "" + //标题: 最多展示2行 + var trackName: String = "" + //内容:最多展示2行 + var description: String = "" + //是否喜爱 + var isFavorite: Bool = false +} diff --git a/swift/iOS/Sequoia/Sequoia/Model/AppleNetData.swift b/swift/iOS/Sequoia/Sequoia/Model/AppleNetData.swift new file mode 100644 index 000000000..4f59645c3 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Model/AppleNetData.swift @@ -0,0 +1,19 @@ +// +// AppleNetData.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation + +struct AppleNetData: Hashable, Codable { + //id + var trackId: Int = 0 + //图标url + var artworkUrl60: String = "" + //标题: 最多展示2行 + var trackName: String = "" + //内容:最多展示2行 + var description: String = "" +} diff --git a/swift/iOS/Sequoia/Sequoia/Model/AppleNetResultData.swift b/swift/iOS/Sequoia/Sequoia/Model/AppleNetResultData.swift new file mode 100644 index 000000000..3bd5618c1 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Model/AppleNetResultData.swift @@ -0,0 +1,13 @@ +// +// AppleNetResultData.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation + +struct AppleNetResultData: Decodable { + var resultCount: Int = 0 + var results: [AppleNetData] = [] +} diff --git a/swift/iOS/Sequoia/Sequoia/Model/AppleResultData.swift b/swift/iOS/Sequoia/Sequoia/Model/AppleResultData.swift new file mode 100644 index 000000000..3d935d7f3 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Model/AppleResultData.swift @@ -0,0 +1,13 @@ +// +// AppleResultData.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation + +struct AppleResultData: Decodable { + var resultCount: Int = 0 + var results: [AppleData] = [] +} diff --git a/swift/iOS/Sequoia/Sequoia/Preview Content/Preview Assets.xcassets/Contents.json b/swift/iOS/Sequoia/Sequoia/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swift/iOS/Sequoia/Sequoia/SequoiaApp.swift b/swift/iOS/Sequoia/Sequoia/SequoiaApp.swift new file mode 100644 index 000000000..ecb97d4a7 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/SequoiaApp.swift @@ -0,0 +1,19 @@ +// +// SequoiaApp.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +@main +struct SequoiaApp: App { + @State private var modelData = DataManager.instance + var body: some Scene { + WindowGroup { + ContentView() + .environment(modelData) + } + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Views/ActivityIndicator.swift b/swift/iOS/Sequoia/Sequoia/Views/ActivityIndicator.swift new file mode 100644 index 000000000..b9df58ad8 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Views/ActivityIndicator.swift @@ -0,0 +1,21 @@ +// +// ActivityIndicator.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import Foundation +import SwiftUI + +struct ActivityIndicator: UIViewRepresentable { + let style: UIActivityIndicatorView.Style + + func makeUIView(context: Context) -> UIActivityIndicatorView { + return UIActivityIndicatorView(style: style) + } + + func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) { + uiView.startAnimating() + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Views/SequoiaListView.swift b/swift/iOS/Sequoia/Sequoia/Views/SequoiaListView.swift new file mode 100644 index 000000000..381a0344d --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Views/SequoiaListView.swift @@ -0,0 +1,109 @@ +// +// SequoiaListView.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +struct SequoiaListView: View { + @Environment(DataManager.self) var managerData + + @State private var footerRefreshing: Bool = false + @State private var noMore: Bool = false + + var body: some View { + contentView() + } + + private func contentView() -> some View { + if managerData.appleDatas.results.count == 0 { + return AnyView(Text("正在请求数据...")) + } else { + return AnyView(Group(content: { + getSplitView() + RefreshFooter(refreshing: $footerRefreshing, action: { + self.loadMore() + }) { + if self.noMore { + Text("No more data.") + .foregroundColor(.secondary) + .padding() + } else { + refreshingView() + } + } + .noMore(noMore) + .preload(offset: 50) + })) + } + } + + private func getSplitView() -> some View { + let bgColor = UIColor(red: 244.0/256.0, green: 244.0/256.0, blue: 247.0/256.0, alpha: 1) + return NavigationSplitView { + List { + ForEach(managerData.appleDatas.results) { appleData in + SequoialRow(appleData: appleData) + .listRowInsets(EdgeInsets(top: 5, leading: 15, bottom: 5, trailing: 15)) + } + + RefreshFooter(refreshing: $footerRefreshing, action: { + self.loadMore() + }) { + if self.noMore { + Text("No more data.") + .foregroundColor(.secondary) + .padding() + } else { + loadingMoreView() + } + } + .noMore(noMore) + .preload(offset: 50) + .background(Color(bgColor)) + .listRowSeparator(.hidden) + } + .enableRefresh() + .refreshable(action: { + self.reload() + }) + .navigationTitle("App") + .listStyle(.plain) + .background(Color(bgColor)) + } detail: { + Text("App") + } + } + + private func reload() { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + DataManager.instance.getDataFromNet(loadingMore: false) + self.noMore = false + } + } + + private func loadMore() { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + DataManager.instance.getDataFromNet(loadingMore: true) + self.footerRefreshing = false + self.noMore = true + } + } + + private func refreshingView() -> some View { + return ActivityIndicator(style: .large) + } + + private func loadingMoreView() -> some View { + return HStack { + ActivityIndicator(style: .large) + Text(" Loading...") + } + } +} + +#Preview { + SequoiaListView() +} diff --git a/swift/iOS/Sequoia/Sequoia/Views/SequoialRow.swift b/swift/iOS/Sequoia/Sequoia/Views/SequoialRow.swift new file mode 100644 index 000000000..98d663317 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Views/SequoialRow.swift @@ -0,0 +1,83 @@ +// +// SequoialRow.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI +import UIKit + +struct SequoialRow: View { + @Environment(DataManager.self) var managerData + //数据 + var appleData: AppleData + + //所在列表中的序号 + var appleDataIndex: Int { + managerData.appleDatas.results.firstIndex(where: { $0.id == appleData.id })! + } + + @State private var image: UIImage? + + var body: some View { + HStack { + //应用程序图标:60*60 + let imageUrl = URL(string: appleData.artworkUrl60) + AsyncImage(url: imageUrl ?? URL(fileURLWithPath: ""), + placeholder: { + ActivityIndicator(style: .medium) + }, + image: { Image(uiImage: $0).resizable() }) + .frame(width: 60, height: 60) + .cornerRadius(15) + + //应用程序名称+描述 + VStack (alignment: .leading, content: { + Text(appleData.trackName) + .lineLimit(1) + .frame(alignment: .leading) + .font(.headline) + Text(appleData.description) + .lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/) + .font(.subheadline) + }) + + Spacer() + + //爱心按钮 + Button { + favoriteAction() + } label: { + if appleData.isFavorite { + Image(systemName: "heart.fill") + .foregroundStyle(.red) + } else { + Image(systemName: "heart") + .foregroundStyle(.gray) + } + } + } + .padding(EdgeInsets(top: 15, leading: 15, bottom: 15, trailing: 15)) + .background(Color.white) + .listRowBackground(Color(UIColor(red: 244.0/256.0, green: 244.0/256.0, blue: 247.0/256.0, alpha: 1))) + .cornerRadius(15) + .listRowSeparator(.hidden) + } + + //收藏 + func favoriteAction() { + @Bindable var managerData = managerData + managerData.appleDatas.results[appleDataIndex].isFavorite = !managerData.appleDatas.results[appleDataIndex].isFavorite + } +} + +#Preview { + return Group { + let appleData1: AppleData = AppleData(id: 1, trackId: 1, artworkUrl60: "https://is1-ssl.mzstatic.com/image/thumb/Purple122/v4/81/b6/25/81b6255c-1972-7ce6-24a2-148a710ce65c/logo_chat_2023q4_color-0-1x_U007emarketing-0-0-0-6-0-0-0-85-220-0.png/60x60bb.jpg", trackName: "sdf", description: "描述文字里是江东父老考上吉林") + SequoialRow(appleData: appleData1) + + let appleData2: AppleData = AppleData(id: 3, trackId: 3, artworkUrl60: "https://is1-ssl.mzstatic.com/image/thumb/Purple122/v4/73/04/7b/73047bfb-9146-03d6-b4f6-94d33a8471e5/AppIcon-0-1x_U007emarketing-0-4-0-sRGB-0-85-220.png/60x60bb.jpg", trackName: "bbbbb", description: "dfsdasdfasdfasdfwewefafsfdsf") + SequoialRow(appleData: appleData2) + } +} diff --git a/swift/iOS/Sequoia/Sequoia/Views/refresh/Footer.swift b/swift/iOS/Sequoia/Sequoia/Views/refresh/Footer.swift new file mode 100644 index 000000000..414917b56 --- /dev/null +++ b/swift/iOS/Sequoia/Sequoia/Views/refresh/Footer.swift @@ -0,0 +1,84 @@ +// +// Footer.swift +// Sequoia +// +// Created by 徐锐 on 2024/4/11. +// + +import SwiftUI + +@available(iOS 13.0, macOS 10.15, *) +extension Refresh { + + public struct Footer