Skip to content

Commit

Permalink
feat: add collapsing-toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
hellohublot committed Jul 23, 2024
1 parent 6a032da commit b77ef9e
Show file tree
Hide file tree
Showing 50 changed files with 3,765 additions and 38 deletions.
15 changes: 13 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'so.onekey.app.wallet'
compileSdk rootProject.ext.compileSdkVersion

defaultConfig {
Expand All @@ -20,11 +22,20 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.majorVersion
}
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'androidx.core:core-ktx:1.10.1'
implementation "androidx.appcompat:appcompat:1.0.0"
implementation 'com.google.android.material:material:1.6.1'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
}
6 changes: 3 additions & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onekey.tabpage">
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
</manifest>
Binary file not shown.
Binary file not shown.
27 changes: 0 additions & 27 deletions android/src/main/java/com/onekey/tabpage/SelectedLabelPackage.java

This file was deleted.

19 changes: 19 additions & 0 deletions android/src/main/java/so/onekey/app/wallet/TabViewPackage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package so.onekey.app.wallet

import com.facebook.react.uimanager.ViewManager
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import so.onekey.app.wallet.viewManager.homePage.HomePageManager
import so.onekey.app.wallet.selectedLabel.SelectedLabelViewManager

class TabViewPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
emptyList()

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
listOf(
HomePageManager(),
SelectedLabelViewManager()
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package so.onekey.app.wallet.extensions

import com.facebook.react.bridge.ReadableMap

fun ReadableMap.getIntOrNull(key: String): Int? {
return if (hasKey(key)) getInt(key) else null
}

fun ReadableMap.getStringOrNull(key: String): String? {
return if (hasKey(key)) getString(key) else null
}

fun ReadableMap.getBooleanOrNull(key: String): Boolean? {
return if (hasKey(key)) getBoolean(key) else null
}
30 changes: 30 additions & 0 deletions android/src/main/java/so/onekey/app/wallet/extensions/ViewExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package so.onekey.app.wallet.extensions

import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import so.onekey.app.wallet.utils.Utils

private fun getApp() = Utils.getApp()
private fun getTopActivity() = Utils.getTopActivity()

fun Int.string(): String {
// 国际化方案问题,MyApplication Context 没有改变 Locale。
return getTopActivity()?.getString(this) ?: getApp().getString(this)
}

@ColorInt
fun String.color(): Int? {
return try {
(getTopActivity()?.resources ?: getApp().resources)
.getIdentifier(
this, "color", getApp().packageName
).color()
} catch (e: Exception) {
null
}
}

@ColorInt
fun Int.color(): Int {
return ContextCompat.getColor(getApp(), this)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onekey.tabpage;
package so.onekey.app.wallet.selectedLabel;

import android.content.Context;
import android.graphics.Typeface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onekey.tabpage;
package so.onekey.app.wallet.selectedLabel;

import android.graphics.Typeface;
import androidx.annotation.NonNull;
Expand Down
93 changes: 93 additions & 0 deletions android/src/main/java/so/onekey/app/wallet/utils/HexUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package so.onekey.app.wallet.utils;

import java.math.BigInteger;
import java.util.Collections;

/**
* @author liyan
*/
public class HexUtils {

public static byte[] hexString2Bytes(String hex) {
if (hex == null) return new byte[0];
return String2Bytes(hex, 16);
}

private static byte[] String2Bytes(String str, int digit) {
byte[] bArray = new BigInteger("10" + str, digit).toByteArray();

byte[] ret = new byte[bArray.length - 1];
for (int i = 0; i < ret.length; i++) {
ret[i] = bArray[i + 1];
}

return ret;
}


public static String stringToHexString(String s) {
if (s == null) return "";
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = s.charAt(i);
String s4 = Integer.toHexString(ch);
str = str + s4;
}
return str;
}

/**
* 将字节数组转换成十六进制的字符串
*
* @param bt 字节数组
* @param start 起始下标
* @param end 终止下标
*/
public static String byteArr2HexStr(byte[] bt, int start, int end) {
return byteArr2HexStr(bt, start, end, "");
}

/**
* 将字节数组转换成十六进制的字符串
*
* @param bt 字节数组
*/
public static String byteArr2HexStr(byte[] bt) {
if (bt == null) return "";
if (bt.length == 0) return "";
return byteArr2HexStr(bt, 0, bt.length, "");
}

/**
* 将字节数组转换成十六进制的字符串
*
* @param bt 字节数组
* @param start 起始下标
* @param end 终止下标
* @param sep 每个字节之间的分割字符串
*/
public static String byteArr2HexStr(byte[] bt, int start, int end, String sep) {
if (bt == null || bt.length < end || start < 0 || start >= end) {
throw new RuntimeException("param format error");
}

StringBuffer sb = new StringBuffer();
for (int i = start; i < end; i++) {
sb.append(byte2HexStr(bt[i])).append(sep);
}
return sb.toString();
}

/**
* 将byte转换成对应的十六进制字符串(如:byte值0x3D转换成字符串"3D")
*
* @return 返回字符串长度一定为2
*/
public static String byte2HexStr(byte b) {
int i = (b & 0xF0) >> 4;
int j = (b & 0x0F);
char c = (char) (i > 9 ? 'A' + i % 10 : '0' + i);
char d = (char) (j > 9 ? 'A' + j % 10 : '0' + j);
return "" + c + d;
}
}
Loading

0 comments on commit b77ef9e

Please sign in to comment.