Revert "feat: improve white label scripts on Windows (#7755)"

This reverts commit a5eb2cdd9a.
This commit is contained in:
Lucas.Xu 2025-04-16 11:09:56 +08:00
parent 7f5faedccf
commit c73186306e
19 changed files with 34 additions and 352 deletions

View file

@ -27,7 +27,7 @@ class ChatAIAvatar extends StatelessWidget {
child: const CircleAvatar(
backgroundColor: Colors.transparent,
child: FlowySvg(
FlowySvgs.app_logo_s,
FlowySvgs.flowy_logo_s,
size: Size.square(16),
blendMode: null,
),

View file

@ -46,7 +46,7 @@ class ChatWelcomePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const FlowySvg(
FlowySvgs.app_logo_xl,
FlowySvgs.flowy_logo_xl,
size: Size.square(32),
blendMode: null,
),

View file

@ -12,7 +12,7 @@ class AFLogo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlowySvg(
FlowySvgs.app_logo_xl,
FlowySvgs.flowy_logo_xl,
blendMode: null,
size: size,
);

View file

@ -115,7 +115,7 @@ class Body extends StatelessWidget {
return Container(
alignment: Alignment.center,
child: UniversalPlatform.isMobile
? const FlowySvg(FlowySvgs.app_logo_xl, blendMode: null)
? const FlowySvg(FlowySvgs.flowy_logo_xl, blendMode: null)
: const _DesktopSplashBody(),
);
}

View file

@ -57,7 +57,7 @@ class _MobileWorkspaceStartScreenState
children: [
const Spacer(),
const FlowySvg(
FlowySvgs.app_logo_xl,
FlowySvgs.flowy_logo_xl,
size: Size.square(64),
blendMode: null,
),

View file

@ -1,12 +1,8 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:local_notifier/local_notifier.dart';
/// The app name used in the local notification.
///
/// DO NOT Use i18n here, because the i18n plugin is not ready
/// before the local notification is initialized.
const _localNotifierAppName = 'AppFlowy';
/// Manages Local Notifications
///
/// Currently supports:
@ -16,11 +12,7 @@ const _localNotifierAppName = 'AppFlowy';
///
class NotificationService {
static Future<void> initialize() async {
await localNotifier.setup(
appName: _localNotifierAppName,
// Don't create a shortcut on Windows, because the setup.exe will create a shortcut
shortcutPolicy: ShortcutPolicy.requireNoCreate,
);
await localNotifier.setup(appName: LocaleKeys.appName.tr());
}
}

View file

@ -14,8 +14,6 @@ class DesktopAppearance extends BaseAppearance {
) {
assert(codeFontFamily.isNotEmpty);
fontFamily = fontFamily.isEmpty ? defaultFontFamily : fontFamily;
final isLight = brightness == Brightness.light;
final theme = isLight ? appTheme.lightTheme : appTheme.darkTheme;

View file

@ -50,8 +50,8 @@ class SidebarTopMenu extends StatelessWidget {
}
final svgData = Theme.of(context).brightness == Brightness.dark
? FlowySvgs.app_logo_with_text_dark_xl
: FlowySvgs.app_logo_with_text_light_xl;
? FlowySvgs.flowy_logo_dark_mode_xl
: FlowySvgs.flowy_logo_text_xl;
return Padding(
padding: const EdgeInsets.only(top: 12.0, left: 8),

View file

@ -254,6 +254,9 @@ flutter:
uses-material-design: true
fonts:
- family: FlowyIconData
fonts:
- asset: assets/fonts/FlowyIconData.ttf
- family: Poppins
fonts:
- asset: assets/google_fonts/Poppins/Poppins-ExtraLight.ttf
@ -279,9 +282,6 @@ flutter:
- asset: assets/google_fonts/Roboto_Mono/RobotoMono-Regular.ttf
- asset: assets/google_fonts/Roboto_Mono/RobotoMono-Italic.ttf
style: italic
# White-label font configuration will be added here
# BEGIN: WHITE_LABEL_FONT
# END: WHITE_LABEL_FONT
# To add assets to your application, add an assets section, like this:
assets:
@ -298,7 +298,6 @@ flutter:
- assets/images/login/
- assets/translations/
- assets/icons/icons.json
- assets/fonts/
# The following assets will be excluded in release.
# BEGIN: EXCLUDE_IN_RELEASE

View file

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -1,72 +0,0 @@
#!/bin/bash
show_usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --company-name Set the custom company name"
echo " --help Show this help message"
echo ""
echo "Example:"
echo " $0 --company-name \"MyCompany Ltd.\""
}
CUSTOM_COMPANY_NAME=""
CODE_FILE="appflowy_flutter/lib/workspace/application/notification/notification_service.dart"
while [[ $# -gt 0 ]]; do
case $1 in
--company-name)
CUSTOM_COMPANY_NAME="$2"
shift 2
;;
--help)
show_usage
exit 0
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
if [ -z "$CUSTOM_COMPANY_NAME" ]; then
echo "Error: Company name is required"
show_usage
exit 1
fi
if [ ! -f "$CODE_FILE" ]; then
echo "Error: Code file not found at $CODE_FILE"
exit 1
fi
echo "Replacing '_localNotifierAppName' value with '$CUSTOM_COMPANY_NAME' in code file..."
if sed --version >/dev/null 2>&1; then
SED_INPLACE="-i"
else
SED_INPLACE="-i ''"
fi
echo "Processing code file..."
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# First, escape any special characters in the company name
ESCAPED_COMPANY_NAME=$(echo "$CUSTOM_COMPANY_NAME" | sed 's/[\/&]/\\&/g')
# Replace the _localNotifierAppName value with the custom company name
sed $SED_INPLACE "s/const _localNotifierAppName = 'AppFlowy'/const _localNotifierAppName = '$ESCAPED_COMPANY_NAME'/" "$CODE_FILE"
if [ $? -ne 0 ]; then
echo "Error: Failed to process $CODE_FILE with sed"
exit 1
fi
else
# For Unix-like systems
sed $SED_INPLACE "s/const _localNotifierAppName = 'AppFlowy'/const _localNotifierAppName = '$CUSTOM_COMPANY_NAME'/" "$CODE_FILE"
if [ $? -ne 0 ]; then
echo "Error: Failed to process $CODE_FILE with sed"
exit 1
fi
fi
echo "Replacement complete!"

View file

@ -1,198 +0,0 @@
#!/bin/bash
show_usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --font-path Set the path to the folder containing font files (.ttf or .otf files)"
echo " --font-family Set the name of the font family"
echo " --help Show this help message"
echo ""
echo "Example:"
echo " $0 --font-path \"/path/to/fonts\" --font-family \"CustomFont\""
}
FONT_PATH=""
FONT_FAMILY=""
TARGET_FONT_DIR="appflowy_flutter/assets/fonts/"
PUBSPEC_FILE="appflowy_flutter/pubspec.yaml"
BASE_APPEARANCE_FILE="appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart"
while [[ $# -gt 0 ]]; do
case $1 in
--font-path)
FONT_PATH="$2"
shift 2
;;
--font-family)
FONT_FAMILY="$2"
shift 2
;;
--help)
show_usage
exit 0
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Validate required arguments
if [ -z "$FONT_PATH" ]; then
echo "Error: Font path is required"
show_usage
exit 1
fi
if [ -z "$FONT_FAMILY" ]; then
echo "Error: Font family name is required"
show_usage
exit 1
fi
# Check if source directory exists
if [ ! -d "$FONT_PATH" ]; then
echo "Error: Font directory not found at $FONT_PATH"
exit 1
fi
# Create target directory if it doesn't exist
mkdir -p "$TARGET_FONT_DIR"
# Clean existing fonts in target directory
echo "Cleaning existing fonts in $TARGET_FONT_DIR..."
rm -rf "$TARGET_FONT_DIR"/*
# Copy font files to target directory
echo "Copying font files from $FONT_PATH to $TARGET_FONT_DIR..."
found_fonts=false
for ext in ttf otf; do
if ls "$FONT_PATH"/*."$ext" >/dev/null 2>&1; then
cp "$FONT_PATH"/*."$ext" "$TARGET_FONT_DIR"/ 2>/dev/null && found_fonts=true
fi
done
if [ "$found_fonts" = false ]; then
echo "Error: No font files (.ttf or .otf) found in source directory"
exit 1
fi
# Generate font configuration for pubspec.yaml
echo "Generating font configuration..."
# Create temporary file for font configuration
TEMP_FILE=$(mktemp)
{
echo " # BEGIN: WHITE_LABEL_FONT"
echo " - family: $FONT_FAMILY"
echo " fonts:"
# Generate entries for each font file
for font_file in "$TARGET_FONT_DIR"/*; do
filename=$(basename "$font_file")
echo " - asset: assets/fonts/$filename"
# Try to detect font weight from filename
if [[ $filename =~ (Thin|ExtraLight|Light|Regular|Medium|SemiBold|Bold|ExtraBold|Black) ]]; then
case ${BASH_REMATCH[1]} in
"Thin") echo " weight: 100";;
"ExtraLight") echo " weight: 200";;
"Light") echo " weight: 300";;
"Regular") echo " weight: 400";;
"Medium") echo " weight: 500";;
"SemiBold") echo " weight: 600";;
"Bold") echo " weight: 700";;
"ExtraBold") echo " weight: 800";;
"Black") echo " weight: 900";;
esac
fi
# Try to detect italic style from filename
if [[ $filename =~ Italic ]]; then
echo " style: italic"
fi
done
echo " # END: WHITE_LABEL_FONT"
} > "$TEMP_FILE"
# Update pubspec.yaml
echo "Updating pubspec.yaml..."
if [ -f "$PUBSPEC_FILE" ]; then
# Create a backup of the original file
cp "$PUBSPEC_FILE" "${PUBSPEC_FILE}.bak"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows-specific handling
# First, remove existing white label font configuration
awk '/# BEGIN: WHITE_LABEL_FONT/,/# END: WHITE_LABEL_FONT/{ next } /# White-label font configuration will be added here/{ print; system("cat '"$TEMP_FILE"'"); next } 1' "$PUBSPEC_FILE" > "${PUBSPEC_FILE}.tmp"
if [ $? -eq 0 ]; then
mv "${PUBSPEC_FILE}.tmp" "$PUBSPEC_FILE"
rm -f "${PUBSPEC_FILE}.bak"
else
echo "Error: Failed to update pubspec.yaml"
mv "${PUBSPEC_FILE}.bak" "$PUBSPEC_FILE"
rm -f "${PUBSPEC_FILE}.tmp"
rm -f "$TEMP_FILE"
exit 1
fi
else
# Unix-like systems handling
if sed --version >/dev/null 2>&1; then
SED_INPLACE="-i"
else
SED_INPLACE="-i ''"
fi
# Remove existing white label font configuration
sed $SED_INPLACE '/# BEGIN: WHITE_LABEL_FONT/,/# END: WHITE_LABEL_FONT/d' "$PUBSPEC_FILE"
# Add new font configuration
sed $SED_INPLACE "/# White-label font configuration will be added here/r $TEMP_FILE" "$PUBSPEC_FILE"
if [ $? -ne 0 ]; then
echo "Error: Failed to update pubspec.yaml"
mv "${PUBSPEC_FILE}.bak" "$PUBSPEC_FILE"
rm -f "$TEMP_FILE"
exit 1
fi
rm -f "${PUBSPEC_FILE}.bak"
fi
else
echo "Error: pubspec.yaml not found at $PUBSPEC_FILE"
rm -f "$TEMP_FILE"
exit 1
fi
# Update base_appearance.dart
echo "Updating base_appearance.dart..."
if [ -f "$BASE_APPEARANCE_FILE" ]; then
# Create a backup of the original file
cp "$BASE_APPEARANCE_FILE" "${BASE_APPEARANCE_FILE}.bak"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows-specific handling
sed -i "s/const defaultFontFamily = '.*'/const defaultFontFamily = '$FONT_FAMILY'/" "$BASE_APPEARANCE_FILE"
else
# Unix-like systems handling
sed -i '' "s/const defaultFontFamily = '.*'/const defaultFontFamily = '$FONT_FAMILY'/" "$BASE_APPEARANCE_FILE"
fi
if [ $? -ne 0 ]; then
echo "Error: Failed to update base_appearance.dart"
mv "${BASE_APPEARANCE_FILE}.bak" "$BASE_APPEARANCE_FILE"
exit 1
fi
rm -f "${BASE_APPEARANCE_FILE}.bak"
else
echo "Error: base_appearance.dart not found at $BASE_APPEARANCE_FILE"
exit 1
fi
# Cleanup
rm -f "$TEMP_FILE"
echo "Font white labeling completed successfully!"

View file

@ -3,16 +3,16 @@
show_usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --icon-path Set the path to the folder containing application icons (.svg files)"
echo " --icon-path Set the path to the application icon (.svg file)"
echo " --help Show this help message"
echo ""
echo "Example:"
echo " $0 --icon-path \"/path/to/icons_folder\""
echo " $0 --icon-path \"/path/to/new/icon.svg\""
}
NEW_ICON_PATH=""
ICON_DIR="resources/flowy_icons"
ICON_NAME_NEED_REPLACE=("app_logo.svg" "ai_chat_logo.svg" "app_logo_with_text_light.svg" "app_logo_with_text_dark.svg")
ICON_NAME_NEED_REPLACE=("flowy_logo.svg" "flowy_ai_chat_logo.svg" "flowy_logo_dark_mode.svg" "flowy_logo_text.svg")
while [[ $# -gt 0 ]]; do
case $1 in
@ -38,17 +38,12 @@ if [ -z "$NEW_ICON_PATH" ]; then
exit 1
fi
if [ ! -d "$NEW_ICON_PATH" ]; then
echo "Error: New icon directory not found at $NEW_ICON_PATH"
exit 1
fi
if [ ! -d "$ICON_DIR" ]; then
echo "Error: Icon directory not found at $ICON_DIR"
exit 1
fi
echo "Replacing icons..."
echo "Replacing icon..."
echo "Processing icon files..."
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
@ -57,18 +52,13 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
echo "Checking subdirectory: $(basename "$subdir")"
for file in "${subdir}"*.svg; do
if [ -f "$file" ] && [[ " ${ICON_NAME_NEED_REPLACE[@]} " =~ " $(basename "$file") " ]]; then
new_icon="${NEW_ICON_PATH}/$(basename "$file")"
if [ -f "$new_icon" ]; then
echo "Updating: $(basename "$subdir")/$(basename "$file")"
cp "$new_icon" "$file"
if [ $? -eq 0 ]; then
echo "Successfully replaced $(basename "$file") in $(basename "$subdir") with new icon"
else
echo "Error: Failed to replace $(basename "$file") in $(basename "$subdir")"
exit 1
fi
echo "Updating: $(basename "$subdir")/$(basename "$file")"
cp "$NEW_ICON_PATH" "$file"
if [ $? -eq 0 ]; then
echo "Successfully replaced $(basename "$file") in $(basename "$subdir") with new icon"
else
echo "Warning: New icon file $(basename "$file") not found in $NEW_ICON_PATH"
echo "Error: Failed to replace $(basename "$file") in $(basename "$subdir")"
exit 1
fi
fi
done
@ -77,18 +67,15 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
else
for file in $(find "$ICON_DIR" -name "*.svg" -type f); do
if [[ " ${ICON_NAME_NEED_REPLACE[@]} " =~ " $(basename "$file") " ]]; then
new_icon="${NEW_ICON_PATH}/$(basename "$file")"
if [ -f "$new_icon" ]; then
echo "Updating: $(basename "$file")"
cp "$new_icon" "$file"
if [ $? -eq 0 ]; then
echo "Successfully replaced $(basename "$file") with new icon"
else
echo "Error: Failed to replace $(basename "$file")"
exit 1
fi
echo "Updating: $(basename "$file")"
cp "$NEW_ICON_PATH" "$file"
if [ $? -eq 0 ]; then
echo "Successfully replaced $(basename "$file") with new icon"
else
echo "Warning: New icon file $(basename "$file") not found in $NEW_ICON_PATH"
echo "Error: Failed to replace $(basename "$file")"
exit 1
fi
fi
done

View file

@ -7,8 +7,6 @@ COMPANY_NAME="AppFlowy Inc."
COPYRIGHT="Copyright © 2025 AppFlowy Inc."
ICON_PATH=""
WINDOWS_ICON_PATH=""
FONT_PATH=""
FONT_FAMILY=""
PLATFORMS=("windows" "linux" "macos" "ios" "android")
show_usage() {
@ -20,8 +18,6 @@ show_usage() {
echo " --copyright Set the copyright information"
echo " --icon-path Set the path to the application icon (.svg)"
echo " --windows-icon-path Set the path to the windows application icon (.ico)"
echo " --font-path Set the path to the folder containing font files (.ttf or .otf files)"
echo " --font-family Set the name of the font family"
echo " --platforms Comma-separated list of platforms to white label (windows,linux,macos,ios,android)"
echo " --help Show this help message"
echo ""
@ -30,8 +26,7 @@ show_usage() {
echo " --company-name \"MyCompany Ltd.\" --copyright \"Copyright © 2025 MyCompany Ltd.\" \\"
echo " --platforms \"windows,linux,macos\" \\"
echo " --windows-icon-path \"./assets/icons/mycompany.ico\" \\"
echo " --icon-path \"./assets/icons/\" \\"
echo " --font-path \"./assets/fonts/\" --font-family \"CustomFont\""
echo " --icon-path \"./assets/icons/mycompany.svg\""
}
while [[ $# -gt 0 ]]; do
@ -60,14 +55,6 @@ while [[ $# -gt 0 ]]; do
WINDOWS_ICON_PATH="$2"
shift 2
;;
--font-path)
FONT_PATH="$2"
shift 2
;;
--font-family)
FONT_FAMILY="$2"
shift 2
;;
--platforms)
IFS=',' read -ra PLATFORMS <<< "$2"
shift 2
@ -90,8 +77,8 @@ if [ -z "$APP_NAME" ] || [ -z "$APP_IDENTIFIER" ] || [ -z "$COMPANY_NAME" ] || [
exit 1
fi
if [ ! -d "$ICON_PATH" ]; then
echo "Error: Icon directory not found at $ICON_PATH"
if [ ! -f "$ICON_PATH" ]; then
echo "Error: Icon file not found at $ICON_PATH"
exit 1
fi
@ -124,17 +111,6 @@ bash "scripts/white_label/i18n_white_label.sh" --company-name "$COMPANY_NAME"
echo -e "\033[32mRunning icon white label script...\033[0m"
bash "scripts/white_label/icon_white_label.sh" --icon-path "$ICON_PATH"
echo -e "\033[32mRunning code white label script...\033[0m"
bash "scripts/white_label/code_white_label.sh" --company-name "$COMPANY_NAME"
# Run font white label script if font parameters are provided
if [ ! -z "$FONT_PATH" ] && [ ! -z "$FONT_FAMILY" ]; then
echo -e "\033[32mRunning font white label script...\033[0m"
bash "scripts/white_label/font_white_label.sh" \
--font-path "$FONT_PATH" \
--font-family "$FONT_FAMILY"
fi
for platform in "${PLATFORMS[@]}"; do
run_platform_script "$platform"
done