diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 6d751a2..a7089eb 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
android {
- namespace = "com.example.code_editor"
+ namespace = "com.lzxnone.code_editor"
compileSdk = 37
ndkVersion = "28.2.13676358"
@@ -21,7 +21,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId = "com.example.code_editor"
+ applicationId = "com.lzxnone.code_editor"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
@@ -43,6 +43,11 @@ android {
useLegacyPackaging = true
}
}
+
+ lint {
+ abortOnError = false
+ checkReleaseBuilds = false
+ }
}
flutter {
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 8b7ddda..e8b39c7 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -10,9 +10,9 @@
+
+
+
+
+
+
diff --git a/android/app/src/main/res/mipmap-hdpi/launcher_icon.png b/android/app/src/main/res/mipmap-hdpi/launcher_icon.png
new file mode 100644
index 0000000..fc02f81
Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/launcher_icon.png differ
diff --git a/android/app/src/main/res/mipmap-mdpi/launcher_icon.png b/android/app/src/main/res/mipmap-mdpi/launcher_icon.png
new file mode 100644
index 0000000..591d776
Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/launcher_icon.png differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png
new file mode 100644
index 0000000..8e9d685
Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png
new file mode 100644
index 0000000..df7005e
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png
new file mode 100644
index 0000000..8189718
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png differ
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..8a64165
--- /dev/null
+++ b/android/app/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #121214
+
\ No newline at end of file
diff --git a/assets/icon/app_icon.png b/assets/icon/app_icon.png
new file mode 100644
index 0000000..bf01766
Binary files /dev/null and b/assets/icon/app_icon.png differ
diff --git a/assets/icon/app_icon_foreground.png b/assets/icon/app_icon_foreground.png
new file mode 100644
index 0000000..16ff4db
Binary files /dev/null and b/assets/icon/app_icon_foreground.png differ
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 166d242..697c369 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
@@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -427,7 +427,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -484,7 +484,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -547,7 +547,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -569,7 +569,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
index d36b1fa..d0d98aa 100644
--- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -1,122 +1 @@
-{
- "images" : [
- {
- "size" : "20x20",
- "idiom" : "iphone",
- "filename" : "Icon-App-20x20@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "20x20",
- "idiom" : "iphone",
- "filename" : "Icon-App-20x20@3x.png",
- "scale" : "3x"
- },
- {
- "size" : "29x29",
- "idiom" : "iphone",
- "filename" : "Icon-App-29x29@1x.png",
- "scale" : "1x"
- },
- {
- "size" : "29x29",
- "idiom" : "iphone",
- "filename" : "Icon-App-29x29@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "29x29",
- "idiom" : "iphone",
- "filename" : "Icon-App-29x29@3x.png",
- "scale" : "3x"
- },
- {
- "size" : "40x40",
- "idiom" : "iphone",
- "filename" : "Icon-App-40x40@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "40x40",
- "idiom" : "iphone",
- "filename" : "Icon-App-40x40@3x.png",
- "scale" : "3x"
- },
- {
- "size" : "60x60",
- "idiom" : "iphone",
- "filename" : "Icon-App-60x60@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "60x60",
- "idiom" : "iphone",
- "filename" : "Icon-App-60x60@3x.png",
- "scale" : "3x"
- },
- {
- "size" : "20x20",
- "idiom" : "ipad",
- "filename" : "Icon-App-20x20@1x.png",
- "scale" : "1x"
- },
- {
- "size" : "20x20",
- "idiom" : "ipad",
- "filename" : "Icon-App-20x20@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "29x29",
- "idiom" : "ipad",
- "filename" : "Icon-App-29x29@1x.png",
- "scale" : "1x"
- },
- {
- "size" : "29x29",
- "idiom" : "ipad",
- "filename" : "Icon-App-29x29@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "40x40",
- "idiom" : "ipad",
- "filename" : "Icon-App-40x40@1x.png",
- "scale" : "1x"
- },
- {
- "size" : "40x40",
- "idiom" : "ipad",
- "filename" : "Icon-App-40x40@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "76x76",
- "idiom" : "ipad",
- "filename" : "Icon-App-76x76@1x.png",
- "scale" : "1x"
- },
- {
- "size" : "76x76",
- "idiom" : "ipad",
- "filename" : "Icon-App-76x76@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "83.5x83.5",
- "idiom" : "ipad",
- "filename" : "Icon-App-83.5x83.5@2x.png",
- "scale" : "2x"
- },
- {
- "size" : "1024x1024",
- "idiom" : "ios-marketing",
- "filename" : "Icon-App-1024x1024@1x.png",
- "scale" : "1x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-}
+{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
\ No newline at end of file
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
index dc9ada4..3f22069 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
index 7353c41..1d148b7 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
index 797d452..a33ce94 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
index 6ed2d93..5848bf1 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
index 4cd7b00..0a3f698 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
index fe73094..41a7262 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
index 321773c..d0b2cb5 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
index 797d452..a33ce94 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
index 502f463..e0d0ac0 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
index 0ec3034..b12f05e 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png
new file mode 100644
index 0000000..efc0ed5
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png
new file mode 100644
index 0000000..ea38296
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png
new file mode 100644
index 0000000..fba76fe
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png
new file mode 100644
index 0000000..566cb0e
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
index 0ec3034..b12f05e 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
index e9f5fea..65217e4 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png
new file mode 100644
index 0000000..fc02f81
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png
new file mode 100644
index 0000000..df7005e
Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
index 84ac32a..428071c 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
index 8953cba..bd15b7b 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ
diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
index 0467bf1..b236556 100644
Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 228e884..cb12654 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -5,7 +5,7 @@
CFBundleDevelopmentRegion
$(DEVELOPMENT_LANGUAGE)
CFBundleDisplayName
- Code Editor
+ LN 代码编辑器
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 86cfa99..a3b60c4 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "Built-in language keywords and document lexical heuristic extraction",
"lspCompletionTitle": "Backend Language Server",
"lspCompletionSubtitle": "Request real semantic types and function parameters from background compilers",
+ "codeCompletionSwitchTitle": "Code Completion",
+ "codeCompletionSwitchSubtitle": "Real-time function, variable, and syntax suggestions while typing",
+ "codeDiagnosticsSwitchTitle": "Code Correction",
+ "codeDiagnosticsSwitchSubtitle": "Real-time syntax checking, error squiggles, and quick fixes",
"internalEngineTitle": "Runtime & Code Intelligence Engine (Ubuntu)",
"internalEngineStatusReady": "Engine Ready",
"internalEngineStatusNotReady": "Engine Not Started",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "Marking as resolved would commit them as normal content.",
"gitConflictMarkAnyway": "Mark anyway",
"gitConflictGoResolve": "Resolve first",
+ "gitConflictAllResolvedBadge": "All Resolved",
+ "gitConflictUnresolvedBadge": "{count} Unresolved",
+ "@gitConflictUnresolvedBadge": {
+ "placeholders": {
+ "count": {
+ "type": "int"
+ }
+ }
+ },
+ "gitConflictResetToInitial": "Reset to Initial State",
+ "gitConflictReloadFromDisk": "Reload from Disk",
+ "gitConflictResolvedCommit": "Resolved · Save & Commit",
+ "gitConflictMoreOptions": "More Options",
+ "gitConflictAcceptCurrentShort": "Current",
+ "gitConflictAcceptIncomingShort": "Incoming",
+ "gitConflictAcceptBothShort": "Both",
+ "gitConflictCompareShort": "Compare",
+ "gitConflictSaveAndMarkShort": "Save & Finish",
+ "gitConflictMalformedBanner": "Malformed or nested conflict markers detected. Auto-resolution is disabled. Please edit manually.",
+ "gitConflictMalformedBadge": "Malformed",
+ "gitConflictCompareTitle": "Compare Conflict #{index}",
+ "@gitConflictCompareTitle": {
+ "placeholders": {
+ "index": {
+ "type": "int"
+ }
+ }
+ },
+ "gitConflictBothEmpty": "Both sides are empty",
+ "gitConflictCurrentWithLabel": "Current: {label}",
+ "@gitConflictCurrentWithLabel": {
+ "placeholders": {
+ "label": {
+ "type": "String"
+ }
+ }
+ },
+ "gitConflictIncomingWithLabel": "Incoming: {label}",
+ "@gitConflictIncomingWithLabel": {
+ "placeholders": {
+ "label": {
+ "type": "String"
+ }
+ }
+ },
"gitRemoteBranches": "Remote Branches",
"gitLocalBranches": "Local Branches",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 18dc249..5f9f9c1 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -2648,6 +2648,30 @@ abstract class AppLocalizations {
/// **'向后台编译器守护进程请求真实语义类型与函数参数补全'**
String get lspCompletionSubtitle;
+ /// No description provided for @codeCompletionSwitchTitle.
+ ///
+ /// In zh, this message translates to:
+ /// **'代码补全'**
+ String get codeCompletionSwitchTitle;
+
+ /// No description provided for @codeCompletionSwitchSubtitle.
+ ///
+ /// In zh, this message translates to:
+ /// **'输入时实时提示函数、变量与语法补全'**
+ String get codeCompletionSwitchSubtitle;
+
+ /// No description provided for @codeDiagnosticsSwitchTitle.
+ ///
+ /// In zh, this message translates to:
+ /// **'代码纠错'**
+ String get codeDiagnosticsSwitchTitle;
+
+ /// No description provided for @codeDiagnosticsSwitchSubtitle.
+ ///
+ /// In zh, this message translates to:
+ /// **'实时语法检查、错误波浪线提示与修复建议'**
+ String get codeDiagnosticsSwitchSubtitle;
+
/// No description provided for @internalEngineTitle.
///
/// In zh, this message translates to:
@@ -4162,6 +4186,108 @@ abstract class AppLocalizations {
/// **'去处理'**
String get gitConflictGoResolve;
+ /// No description provided for @gitConflictAllResolvedBadge.
+ ///
+ /// In zh, this message translates to:
+ /// **'已全部解决'**
+ String get gitConflictAllResolvedBadge;
+
+ /// No description provided for @gitConflictUnresolvedBadge.
+ ///
+ /// In zh, this message translates to:
+ /// **'{count} 未解决'**
+ String gitConflictUnresolvedBadge(int count);
+
+ /// No description provided for @gitConflictResetToInitial.
+ ///
+ /// In zh, this message translates to:
+ /// **'重置为初始冲突状态'**
+ String get gitConflictResetToInitial;
+
+ /// No description provided for @gitConflictReloadFromDisk.
+ ///
+ /// In zh, this message translates to:
+ /// **'重新从磁盘读取'**
+ String get gitConflictReloadFromDisk;
+
+ /// No description provided for @gitConflictResolvedCommit.
+ ///
+ /// In zh, this message translates to:
+ /// **'冲突已解决 · 保存并提交'**
+ String get gitConflictResolvedCommit;
+
+ /// No description provided for @gitConflictMoreOptions.
+ ///
+ /// In zh, this message translates to:
+ /// **'更多操作'**
+ String get gitConflictMoreOptions;
+
+ /// No description provided for @gitConflictAcceptCurrentShort.
+ ///
+ /// In zh, this message translates to:
+ /// **'当前'**
+ String get gitConflictAcceptCurrentShort;
+
+ /// No description provided for @gitConflictAcceptIncomingShort.
+ ///
+ /// In zh, this message translates to:
+ /// **'传入'**
+ String get gitConflictAcceptIncomingShort;
+
+ /// No description provided for @gitConflictAcceptBothShort.
+ ///
+ /// In zh, this message translates to:
+ /// **'双方'**
+ String get gitConflictAcceptBothShort;
+
+ /// No description provided for @gitConflictCompareShort.
+ ///
+ /// In zh, this message translates to:
+ /// **'对比'**
+ String get gitConflictCompareShort;
+
+ /// No description provided for @gitConflictSaveAndMarkShort.
+ ///
+ /// In zh, this message translates to:
+ /// **'保存并完成'**
+ String get gitConflictSaveAndMarkShort;
+
+ /// No description provided for @gitConflictMalformedBanner.
+ ///
+ /// In zh, this message translates to:
+ /// **'检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑'**
+ String get gitConflictMalformedBanner;
+
+ /// No description provided for @gitConflictMalformedBadge.
+ ///
+ /// In zh, this message translates to:
+ /// **'标记异常'**
+ String get gitConflictMalformedBadge;
+
+ /// No description provided for @gitConflictCompareTitle.
+ ///
+ /// In zh, this message translates to:
+ /// **'冲突对比 · 第 {index} 处'**
+ String gitConflictCompareTitle(int index);
+
+ /// No description provided for @gitConflictBothEmpty.
+ ///
+ /// In zh, this message translates to:
+ /// **'两端内容均为空'**
+ String get gitConflictBothEmpty;
+
+ /// No description provided for @gitConflictCurrentWithLabel.
+ ///
+ /// In zh, this message translates to:
+ /// **'当前侧: {label}'**
+ String gitConflictCurrentWithLabel(String label);
+
+ /// No description provided for @gitConflictIncomingWithLabel.
+ ///
+ /// In zh, this message translates to:
+ /// **'传入侧: {label}'**
+ String gitConflictIncomingWithLabel(String label);
+
/// No description provided for @gitRemoteBranches.
///
/// In zh, this message translates to:
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index c35e574..0e924e0 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -1600,6 +1600,20 @@ class AppLocalizationsEn extends AppLocalizations {
String get lspCompletionSubtitle =>
'Request real semantic types and function parameters from background compilers';
+ @override
+ String get codeCompletionSwitchTitle => 'Code Completion';
+
+ @override
+ String get codeCompletionSwitchSubtitle =>
+ 'Real-time function, variable, and syntax suggestions while typing';
+
+ @override
+ String get codeDiagnosticsSwitchTitle => 'Code Correction';
+
+ @override
+ String get codeDiagnosticsSwitchSubtitle =>
+ 'Real-time syntax checking, error squiggles, and quick fixes';
+
@override
String get internalEngineTitle =>
'Runtime & Code Intelligence Engine (Ubuntu)';
@@ -2473,6 +2487,66 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get gitConflictGoResolve => 'Resolve first';
+ @override
+ String get gitConflictAllResolvedBadge => 'All Resolved';
+
+ @override
+ String gitConflictUnresolvedBadge(int count) {
+ return '$count Unresolved';
+ }
+
+ @override
+ String get gitConflictResetToInitial => 'Reset to Initial State';
+
+ @override
+ String get gitConflictReloadFromDisk => 'Reload from Disk';
+
+ @override
+ String get gitConflictResolvedCommit => 'Resolved · Save & Commit';
+
+ @override
+ String get gitConflictMoreOptions => 'More Options';
+
+ @override
+ String get gitConflictAcceptCurrentShort => 'Current';
+
+ @override
+ String get gitConflictAcceptIncomingShort => 'Incoming';
+
+ @override
+ String get gitConflictAcceptBothShort => 'Both';
+
+ @override
+ String get gitConflictCompareShort => 'Compare';
+
+ @override
+ String get gitConflictSaveAndMarkShort => 'Save & Finish';
+
+ @override
+ String get gitConflictMalformedBanner =>
+ 'Malformed or nested conflict markers detected. Auto-resolution is disabled. Please edit manually.';
+
+ @override
+ String get gitConflictMalformedBadge => 'Malformed';
+
+ @override
+ String gitConflictCompareTitle(int index) {
+ return 'Compare Conflict #$index';
+ }
+
+ @override
+ String get gitConflictBothEmpty => 'Both sides are empty';
+
+ @override
+ String gitConflictCurrentWithLabel(String label) {
+ return 'Current: $label';
+ }
+
+ @override
+ String gitConflictIncomingWithLabel(String label) {
+ return 'Incoming: $label';
+ }
+
@override
String get gitRemoteBranches => 'Remote Branches';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index c426228..717499a 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -1549,6 +1549,18 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get lspCompletionSubtitle => '向后台编译器守护进程请求真实语义类型与函数参数补全';
+ @override
+ String get codeCompletionSwitchTitle => '代码补全';
+
+ @override
+ String get codeCompletionSwitchSubtitle => '输入时实时提示函数、变量与语法补全';
+
+ @override
+ String get codeDiagnosticsSwitchTitle => '代码纠错';
+
+ @override
+ String get codeDiagnosticsSwitchSubtitle => '实时语法检查、错误波浪线提示与修复建议';
+
@override
String get internalEngineTitle => '代码运行与智能补全引擎 (Ubuntu)';
@@ -2399,6 +2411,65 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get gitConflictGoResolve => '去处理';
+ @override
+ String get gitConflictAllResolvedBadge => '已全部解决';
+
+ @override
+ String gitConflictUnresolvedBadge(int count) {
+ return '$count 未解决';
+ }
+
+ @override
+ String get gitConflictResetToInitial => '重置为初始冲突状态';
+
+ @override
+ String get gitConflictReloadFromDisk => '重新从磁盘读取';
+
+ @override
+ String get gitConflictResolvedCommit => '冲突已解决 · 保存并提交';
+
+ @override
+ String get gitConflictMoreOptions => '更多操作';
+
+ @override
+ String get gitConflictAcceptCurrentShort => '当前';
+
+ @override
+ String get gitConflictAcceptIncomingShort => '传入';
+
+ @override
+ String get gitConflictAcceptBothShort => '双方';
+
+ @override
+ String get gitConflictCompareShort => '对比';
+
+ @override
+ String get gitConflictSaveAndMarkShort => '保存并完成';
+
+ @override
+ String get gitConflictMalformedBanner => '检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑';
+
+ @override
+ String get gitConflictMalformedBadge => '标记异常';
+
+ @override
+ String gitConflictCompareTitle(int index) {
+ return '冲突对比 · 第 $index 处';
+ }
+
+ @override
+ String get gitConflictBothEmpty => '两端内容均为空';
+
+ @override
+ String gitConflictCurrentWithLabel(String label) {
+ return '当前侧: $label';
+ }
+
+ @override
+ String gitConflictIncomingWithLabel(String label) {
+ return '传入侧: $label';
+ }
+
@override
String get gitRemoteBranches => '远端分支';
diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb
index 0d5ed55..4e51d36 100644
--- a/lib/l10n/app_zh.arb
+++ b/lib/l10n/app_zh.arb
@@ -844,6 +844,10 @@
"localCompletionSubtitle": "包含语言内置关键字与当前文档词法启发式提取",
"lspCompletionTitle": "后端语言服务补全",
"lspCompletionSubtitle": "向后台编译器守护进程请求真实语义类型与函数参数补全",
+ "codeCompletionSwitchTitle": "代码补全",
+ "codeCompletionSwitchSubtitle": "输入时实时提示函数、变量与语法补全",
+ "codeDiagnosticsSwitchTitle": "代码纠错",
+ "codeDiagnosticsSwitchSubtitle": "实时语法检查、错误波浪线提示与修复建议",
"internalEngineTitle": "代码运行与智能补全引擎 (Ubuntu)",
"internalEngineStatusReady": "引擎已就绪",
"internalEngineStatusNotReady": "引擎未启动",
@@ -1413,6 +1417,51 @@
"gitConflictMarkWithMarkersHint": "标记为已解决会把它们当作正常内容提交进仓库。建议先处理干净。",
"gitConflictMarkAnyway": "仍然标记",
"gitConflictGoResolve": "去处理",
+ "gitConflictAllResolvedBadge": "已全部解决",
+ "gitConflictUnresolvedBadge": "{count} 未解决",
+ "@gitConflictUnresolvedBadge": {
+ "placeholders": {
+ "count": {
+ "type": "int"
+ }
+ }
+ },
+ "gitConflictResetToInitial": "重置为初始冲突状态",
+ "gitConflictReloadFromDisk": "重新从磁盘读取",
+ "gitConflictResolvedCommit": "冲突已解决 · 保存并提交",
+ "gitConflictMoreOptions": "更多操作",
+ "gitConflictAcceptCurrentShort": "当前",
+ "gitConflictAcceptIncomingShort": "传入",
+ "gitConflictAcceptBothShort": "双方",
+ "gitConflictCompareShort": "对比",
+ "gitConflictSaveAndMarkShort": "保存并完成",
+ "gitConflictMalformedBanner": "检测到冲突标记嵌套或不完整,自动解析已禁用,请点击下方手动编辑",
+ "gitConflictMalformedBadge": "标记异常",
+ "gitConflictCompareTitle": "冲突对比 · 第 {index} 处",
+ "@gitConflictCompareTitle": {
+ "placeholders": {
+ "index": {
+ "type": "int"
+ }
+ }
+ },
+ "gitConflictBothEmpty": "两端内容均为空",
+ "gitConflictCurrentWithLabel": "当前侧: {label}",
+ "@gitConflictCurrentWithLabel": {
+ "placeholders": {
+ "label": {
+ "type": "String"
+ }
+ }
+ },
+ "gitConflictIncomingWithLabel": "传入侧: {label}",
+ "@gitConflictIncomingWithLabel": {
+ "placeholders": {
+ "label": {
+ "type": "String"
+ }
+ }
+ },
"gitRemoteBranches": "远端分支",
"gitLocalBranches": "本地分支",
diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart
index 0aade96..5fea564 100644
--- a/lib/providers/settings_provider.dart
+++ b/lib/providers/settings_provider.dart
@@ -46,7 +46,9 @@ class SettingsProvider extends ChangeNotifier {
static const String _keyShowHiddenFiles = 'show_hidden_files'; //显示隐藏文件
//代码补全
- static const String _keyEnableLspCompletion = 'enable_lsp_completion'; //LSP智能代码补全启用
+ static const String _keyEnableLspCompletion = 'enable_lsp_completion'; //LSP智能代码补全总开关
+ static const String _keyEnableCodeCompletion = 'enable_code_completion'; //代码补全子开关
+ static const String _keyEnableCodeDiagnostics = 'enable_code_diagnostics'; //代码纠错子开关
//语言
static const String _keyAppLocale = 'app_locale';
@@ -83,6 +85,8 @@ class SettingsProvider extends ChangeNotifier {
VirtualKeyboardConfig _terminalKeyboardConfig = VirtualKeyboardConfig.defaultTerminalConfiguration();
bool _showHiddenFiles = true;
bool _enableLspCompletion = true;
+ bool _enableCodeCompletion = true;
+ bool _enableCodeDiagnostics = true;
ContainerRuntimeMode _containerRuntimeMode = ContainerRuntimeMode.auto;
bool _hasPromptedRootRequest = false;
Locale? _locale;
@@ -91,6 +95,8 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除')
bool get enableLocalCompletion => false;
bool get enableLspCompletion => _enableLspCompletion;
+ bool get enableCodeCompletion => _enableCodeCompletion;
+ bool get enableCodeDiagnostics => _enableCodeDiagnostics;
ContainerRuntimeMode get containerRuntimeMode => _containerRuntimeMode;
bool get hasPromptedRootRequest => _hasPromptedRootRequest;
@@ -323,6 +329,14 @@ class SettingsProvider extends ChangeNotifier {
if (savedEnableLspCompletion != null) {
_enableLspCompletion = savedEnableLspCompletion;
}
+ final savedEnableCodeCompletion = prefs.getBool(_keyEnableCodeCompletion);
+ if (savedEnableCodeCompletion != null) {
+ _enableCodeCompletion = savedEnableCodeCompletion;
+ }
+ final savedEnableCodeDiagnostics = prefs.getBool(_keyEnableCodeDiagnostics);
+ if (savedEnableCodeDiagnostics != null) {
+ _enableCodeDiagnostics = savedEnableCodeDiagnostics;
+ }
//设置语言
final savedLocale = prefs.getString(_keyAppLocale);
@@ -549,7 +563,7 @@ class SettingsProvider extends ChangeNotifier {
@Deprecated('本地补全已完全移除')
Future setEnableLocalCompletion(bool enable) async {}
- /// 设置是否启用LSP后端代码补全
+ /// 设置是否启用LSP后端代码补全(总开关)
Future setEnableLspCompletion(bool enable) async {
if (_enableLspCompletion == enable) return;
_enableLspCompletion = enable;
@@ -559,4 +573,26 @@ class SettingsProvider extends ChangeNotifier {
await prefs.setBool(_keyEnableLspCompletion, enable);
} catch (_) {}
}
+
+ /// 设置是否启用代码补全子功能
+ Future setEnableCodeCompletion(bool enable) async {
+ if (_enableCodeCompletion == enable) return;
+ _enableCodeCompletion = enable;
+ notifyListeners();
+ try {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setBool(_keyEnableCodeCompletion, enable);
+ } catch (_) {}
+ }
+
+ /// 设置是否启用代码纠错子功能
+ Future setEnableCodeDiagnostics(bool enable) async {
+ if (_enableCodeDiagnostics == enable) return;
+ _enableCodeDiagnostics = enable;
+ notifyListeners();
+ try {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setBool(_keyEnableCodeDiagnostics, enable);
+ } catch (_) {}
+ }
}
diff --git a/lib/services/distro_manager.dart b/lib/services/distro_manager.dart
index c849af8..dfdc5a9 100644
--- a/lib/services/distro_manager.dart
+++ b/lib/services/distro_manager.dart
@@ -391,7 +391,7 @@ class DistroManager {
}
}
- static const MethodChannel _nativeChannel = MethodChannel('com.example.code_editor/native');
+ static const MethodChannel _nativeChannel = MethodChannel('com.lzxnone.code_editor/native');
String? _cachedProotPath;
String? _cachedNativeDir;
diff --git a/lib/views/code_completion_management_view.dart b/lib/views/code_completion_management_view.dart
index 5cecb9a..192209a 100644
--- a/lib/views/code_completion_management_view.dart
+++ b/lib/views/code_completion_management_view.dart
@@ -290,6 +290,8 @@ class _CodeCompletionManagementViewState
if (settings == null) return const SizedBox.shrink();
final colorScheme = theme.colorScheme;
+ final isMasterEnabled = settings.enableLspCompletion;
+
return Card(
elevation: 0,
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.35),
@@ -312,12 +314,51 @@ class _CodeCompletionManagementViewState
),
),
),
+ // 语言服务总开关
SwitchListTile(
+ key: const ValueKey('lsp_master_switch'),
secondary: const Icon(Icons.hub_outlined),
title: Text(l10n.lspCompletionTitle),
- value: settings.enableLspCompletion,
+ subtitle: Text(l10n.lspCompletionSubtitle),
+ value: isMasterEnabled,
onChanged: (val) => settings.setEnableLspCompletion(val),
),
+ Divider(
+ height: 1,
+ indent: 16,
+ endIndent: 16,
+ color: colorScheme.outlineVariant.withValues(alpha: 0.4),
+ ),
+ // 分开关 1:代码补全
+ SwitchListTile(
+ key: const ValueKey('code_completion_sub_switch'),
+ contentPadding: const EdgeInsets.only(left: 32, right: 16),
+ secondary: Icon(
+ Icons.auto_awesome_outlined,
+ color: isMasterEnabled ? null : colorScheme.onSurface.withValues(alpha: 0.38),
+ ),
+ title: Text(l10n.codeCompletionSwitchTitle),
+ subtitle: Text(l10n.codeCompletionSwitchSubtitle),
+ value: settings.enableCodeCompletion,
+ onChanged: isMasterEnabled
+ ? (val) => settings.setEnableCodeCompletion(val)
+ : null,
+ ),
+ // 分开关 2:代码纠错
+ SwitchListTile(
+ key: const ValueKey('code_diagnostics_sub_switch'),
+ contentPadding: const EdgeInsets.only(left: 32, right: 16),
+ secondary: Icon(
+ Icons.spellcheck_rounded,
+ color: isMasterEnabled ? null : colorScheme.onSurface.withValues(alpha: 0.38),
+ ),
+ title: Text(l10n.codeDiagnosticsSwitchTitle),
+ subtitle: Text(l10n.codeDiagnosticsSwitchSubtitle),
+ value: settings.enableCodeDiagnostics,
+ onChanged: isMasterEnabled
+ ? (val) => settings.setEnableCodeDiagnostics(val)
+ : null,
+ ),
],
),
),
diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart
index 7ce79f6..49b13d2 100644
--- a/lib/views/main_view.dart
+++ b/lib/views/main_view.dart
@@ -38,6 +38,16 @@ import 'package:provider/provider.dart';
class MainView extends StatefulWidget {
const MainView({super.key});
+ /// 全局主页面 Scaffold Key,用于从任何弹窗、底部面板或子页面关闭主界面抽屉侧边栏
+ static final GlobalKey scaffoldKey = GlobalKey();
+
+ /// 方便调用的关闭主界面侧边栏抽屉辅助方法
+ static void closeDrawerIfOpen() {
+ if (scaffoldKey.currentState?.isDrawerOpen ?? false) {
+ scaffoldKey.currentState?.closeDrawer();
+ }
+ }
+
/// 清除指定语言或全部语言的防打扰提示记录(卸载组件后恢复提示资格并重置当前文件检查)
static void clearPromptedLanguage(String? languageId) {
_MainViewState.clearPromptedLanguage(languageId);
@@ -653,6 +663,7 @@ class _MainViewState extends State {
}
},
child: Scaffold(
+ key: MainView.scaffoldKey,
appBar: CodeEditorAppBar(
filePath: currentFile,
rootPath: rootPath,
diff --git a/lib/widgets/code_editor_widget.dart b/lib/widgets/code_editor_widget.dart
index 3726f1d..03dc4bc 100644
--- a/lib/widgets/code_editor_widget.dart
+++ b/lib/widgets/code_editor_widget.dart
@@ -1020,6 +1020,13 @@ class _CodeEditorWidgetState extends State {
required TextSpan textSpan,
required TextStyle style,
}) {
+ try {
+ final settings = _getSettingsProvider(context);
+ if (!settings.enableLspCompletion || !settings.enableCodeDiagnostics) {
+ return textSpan;
+ }
+ } catch (_) {}
+
return _diagnosticController.buildDiagnosticSpans(
context: context,
filePath: _currentLoadedPath ?? widget.filePath,
@@ -1218,6 +1225,8 @@ class _CodeEditorWidgetState extends State {
bool showLineNumbers = true;
bool pinLineNumbers = true;
bool enableLspCompletion = true;
+ bool enableCodeCompletion = true;
+ bool enableCodeDiagnostics = true;
try {
final settings = _getSettingsProvider(context, listen: true);
activeTheme = settings.editorTheme;
@@ -1229,6 +1238,8 @@ class _CodeEditorWidgetState extends State {
keyboardConfig = settings.virtualKeyboardConfig;
activeEditorFont = settings.editorFont;
enableLspCompletion = settings.enableLspCompletion;
+ enableCodeCompletion = settings.enableCodeCompletion;
+ enableCodeDiagnostics = settings.enableCodeDiagnostics;
if (_currentIndentSize != null && _currentIndentSize != settings.indentSize) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _loadFileContent();
@@ -1236,6 +1247,9 @@ class _CodeEditorWidgetState extends State {
}
} catch (_) {}
+ final bool effectiveCompletion = enableLspCompletion && enableCodeCompletion;
+ final bool effectiveDiagnostics = enableLspCompletion && enableCodeDiagnostics;
+
final double displayFontSize = _activeZoomFontSize ?? activeFontSize;
return Container(
@@ -1262,7 +1276,7 @@ class _CodeEditorWidgetState extends State {
final promptsBuilder = SmartCodeAutocompletePromptsBuilder(
controller: controller,
filePath: _currentLoadedPath ?? widget.filePath,
- enableLspCompletion: enableLspCompletion,
+ enableLspCompletion: effectiveCompletion,
);
return EditorOverlayScope(
key: ValueKey(_currentLoadedPath),
@@ -1316,6 +1330,7 @@ class _CodeEditorWidgetState extends State {
controller: editingController,
notifier: notifier,
lineDecorationBuilder: (lineIndex) {
+ if (!effectiveDiagnostics) return null;
final filePath = _currentLoadedPath ?? widget.filePath;
if (filePath == null) return null;
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(filePath, lineIndex);
@@ -1406,7 +1421,7 @@ class _CodeEditorWidgetState extends State {
),
),
),
- if (_currentCursorLine >= 0 && (_currentLoadedPath ?? widget.filePath) != null) ...[
+ if (effectiveDiagnostics && _currentCursorLine >= 0 && (_currentLoadedPath ?? widget.filePath) != null) ...[
Builder(
builder: (ctx) {
final diags = LspDiagnosticsStore.instance.getDiagnosticsForLine(
diff --git a/lib/widgets/git/conflict_view_model.dart b/lib/widgets/git/conflict_view_model.dart
index 04fb3b1..290adff 100644
--- a/lib/widgets/git/conflict_view_model.dart
+++ b/lib/widgets/git/conflict_view_model.dart
@@ -68,6 +68,18 @@ class ConflictLine {
role == ConflictLineRole.oursContent ||
role == ConflictLineRole.baseContent ||
role == ConflictLineRole.theirsContent;
+
+ bool get isOurs =>
+ role == ConflictLineRole.oursHeader ||
+ role == ConflictLineRole.oursContent;
+
+ bool get isTheirs =>
+ role == ConflictLineRole.theirsHeader ||
+ role == ConflictLineRole.theirsContent;
+
+ bool get isBase =>
+ role == ConflictLineRole.baseHeader ||
+ role == ConflictLineRole.baseContent;
}
/// 把冲突文件内容摊平成可渲染的行序列
diff --git a/lib/widgets/git/git_conflict_panel.dart b/lib/widgets/git/git_conflict_panel.dart
index b64a4c3..ca74e63 100644
--- a/lib/widgets/git/git_conflict_panel.dart
+++ b/lib/widgets/git/git_conflict_panel.dart
@@ -7,6 +7,7 @@ import '../../providers/git_provider.dart';
import '../../providers/tab_provider.dart';
import '../../utils/dialog_utils.dart';
import '../../utils/git_error_mapper.dart';
+import '../../views/main_view.dart';
import 'git_conflict_resolve_page.dart';
/// 冲突解决面板(底部弹出)
@@ -518,9 +519,6 @@ class _ConflictFileTile extends StatelessWidget {
await provider.refreshConflictState();
if (!context.mounted) return;
- // 先收起面板与抽屉,再压入解决页 —— 否则返回时层级会错乱
- Navigator.of(context).maybePop();
-
await Navigator.of(context).push(
GitConflictResolvePage.route(file: file, gitProvider: provider),
);
@@ -539,11 +537,9 @@ class _ConflictFileTile extends StatelessWidget {
await tabProvider.openFile(file.absolutePath);
if (!context.mounted) return;
- // 先收起 bottom sheet 面板,再显式关闭抽屉。
- // 这里不能用连续两次 maybePop():抽屉是 Scaffold 管理的路由,
- // 用 closeDrawer() 才是项目内一致且可靠的做法(见 file_item_widget)。
- Navigator.of(context).maybePop();
- Scaffold.maybeOf(context)?.closeDrawer();
+ // 先收起 bottom sheet 冲突面板,再关闭侧边栏抽屉,直达主代码编辑区
+ Navigator.of(context).pop();
+ MainView.closeDrawerIfOpen();
}
Future _takeSide(
diff --git a/lib/widgets/git/git_conflict_resolve_page.dart b/lib/widgets/git/git_conflict_resolve_page.dart
index 1d3f5f3..26f3ed4 100644
--- a/lib/widgets/git/git_conflict_resolve_page.dart
+++ b/lib/widgets/git/git_conflict_resolve_page.dart
@@ -1,5 +1,6 @@
import 'dart:math' as math;
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as p;
import 'package:provider/provider.dart';
@@ -13,43 +14,46 @@ import '../../providers/settings_provider.dart';
import '../../providers/tab_provider.dart';
import '../../services/file_service.dart';
import '../../utils/dialog_utils.dart';
+import '../../utils/file_icon_utils.dart';
import '../../utils/git_conflict_parser.dart';
+import '../../utils/git_diff_helper.dart';
import '../../utils/syntax_highlight_helper.dart';
+import '../../views/main_view.dart';
import 'conflict_view_model.dart';
-/// 冲突解决页(VS Code 内联冲突风格)
+/// Git 冲突解决页面(VS Code 风格重制版)
///
-/// 视觉与交互参照 VS Code 的内联冲突视图:
-/// - 冲突标记行渲染成**整行色带标题**:`<<<<<<< HEAD (Current Change)` 绿、
-/// `>>>>>>> theirs (Incoming Change)` 蓝、`|||||||` 基线段灰
-/// - 每段内容带**整段底色**(当前侧绿、传入侧蓝)
-/// - 标记行上叠加一行**内联操作**:Accept Current / Accept Incoming /
-/// Accept Both / Compare
-/// - 底部常驻「保存并标记为已解决」
-///
-/// 实现说明:这是**独立页面**,刻意不复用 `git_diff_page.dart` 的代码。
-/// 只读行渲染器 + 固定行号栏 + 全向滚动 + 双指缩放均按该类页面的既有做法
-/// 自行实现,保证缩放手感、行号对齐、横向滚动行为与本 App 其余部分一致。
-///
-/// **不使用 `CodeEditor`**:它来自 `re_editor`,只支持行级着色,
-/// 无法表达"标记行变标题带 + 内容行整段底色"这种行级装饰。
+/// 视觉与交互完全对齐 VS Code 内联冲突(Inline Merge Conflict)规范,
+/// 页面全局主题与代码区主题严格继承并遵循 `GitDiffPage` 规范:
+/// - AppBar:遵循应用标准 Material 3 配色,展示文件图标、路径、冲突徽标与导航工具栏
+/// - CodeLens 悬浮操作胶囊:在冲突块顶部提供「采用当前」、「采用传入」、「保留双方」、「对比查看」
+/// - 视觉分块:当前侧(绿)、分隔线(居中)、传入侧(蓝)、基线侧(灰)带语义色带与软背景
+/// - 高度与对齐:行号区与代码区高度严格同步,彻底根除行号错位与渲染截断 Bug
+/// - 纯手势体验:支持基于原生指针跟踪的平滑单指平移、双指中心锚定缩放、浮动字号气泡与惯性滑动
+/// - 高级功能:支持「对比查看 (Compare Changes)」差异弹窗、重置回初始冲突、批量采用
class GitConflictResolvePage extends StatefulWidget {
const GitConflictResolvePage({
super.key,
required this.file,
required this.gitProvider,
+ this.initialContent,
});
final GitConflictedFile file;
final GitProvider gitProvider;
+ final String? initialContent;
static Route route({
required GitConflictedFile file,
required GitProvider gitProvider,
+ String? initialContent,
}) {
return MaterialPageRoute(
- builder: (_) =>
- GitConflictResolvePage(file: file, gitProvider: gitProvider),
+ builder: (_) => GitConflictResolvePage(
+ file: file,
+ gitProvider: gitProvider,
+ initialContent: initialContent,
+ ),
);
}
@@ -61,30 +65,48 @@ class _GitConflictResolvePageState extends State {
bool _isLoading = true;
String? _errorMessage;
- /// 当前文件内容(\n 规范化,与解析行号一致)
+ /// 进入页面时从磁盘读取的初始冲突内容(用于重置)
+ String _initialContent = '';
+
+ /// 当前工作内容(\n 规范化)
String _content = '';
GitConflictParseResult _parsed = GitConflictParseResult.none;
List _lines = const [];
- // 滚动分工照抄差异页:垂直 / 水平 / 行号各自独立控制器
+ // 当前定位冲突块索引
+ int _currentBlockIndex = 0;
+
+ // 垂直 / 水平 / 行号独立滚动控制器(分工与 GitDiffPage 一致)
late final ScrollController _vController;
late final ScrollController _hController;
late final ScrollController _gutterController;
bool _syncing = false;
- double? _committedFontSize;
+ // 缩放字号状态
+ double? _splitFontSize;
double? _activeZoomFontSize;
+ // 双指平滑缩放手势跟踪状态(对标 GitDiffPage)
final Map _pointers = {};
int? _pointer1;
int? _pointer2;
double? _initialDistance;
double? _initialFontSize;
+ Offset? _initialLocalFocal;
+ Offset? _currentLocalFocal;
+ double _focalLineContinuous = 0.0;
+ double _focalCharContinuous = 0.0;
bool _isPinching = false;
Offset? _lastPanPos;
- bool _showZoomBadge = false;
+ VelocityTracker? _velocityTracker;
- final Map _highlightCache = {};
+ // 用户正在与 CodeLens 栏交互(左右拖动查看操作按钮,避免触发主代码区单指平移)
+ bool _isInteractingWithCodeLens = false;
+
+ // 语法高亮缓存 (key: '$fontSize-${editorTheme.id}-$code')
+ final Map _highlightSpanCache = {};
+
+ static const double _codeLensBarHeight = 32.0;
@override
void initState() {
@@ -92,13 +114,26 @@ class _GitConflictResolvePageState extends State {
_vController = ScrollController();
_hController = ScrollController();
_gutterController = ScrollController();
+
_vController.addListener(_onVerticalScrolled);
- _load();
+ _gutterController.addListener(_onGutterScrolled);
+
+ if (widget.initialContent != null) {
+ final normalized = widget.initialContent!.replaceAll('\r\n', '\n');
+ _initialContent = normalized;
+ _content = normalized;
+ _parsed = GitConflictParser.parse(normalized);
+ _lines = ConflictLineBuilder.build(normalized, _parsed);
+ _isLoading = false;
+ } else {
+ _loadFromDisk(isInitial: true);
+ }
}
@override
void dispose() {
_vController.removeListener(_onVerticalScrolled);
+ _gutterController.removeListener(_onGutterScrolled);
_vController.dispose();
_hController.dispose();
_gutterController.dispose();
@@ -110,63 +145,50 @@ class _GitConflictResolvePageState extends State {
_syncing = true;
_gutterController.jumpTo(
_vController.offset.clamp(
- _gutterController.position.minScrollExtent,
+ 0.0,
_gutterController.position.maxScrollExtent,
),
);
_syncing = false;
}
- double get _baseFontSize {
- try {
- return context.read().fontSize;
- } catch (_) {
- return 13.0;
- }
+ void _onGutterScrolled() {
+ if (_syncing || !_vController.hasClients) return;
+ _syncing = true;
+ _vController.jumpTo(
+ _gutterController.offset.clamp(
+ 0.0,
+ _vController.position.maxScrollExtent,
+ ),
+ );
+ _syncing = false;
}
- double get _effectiveFontSize =>
- _activeZoomFontSize ?? _committedFontSize ?? _baseFontSize;
+ // ---------------------------- 数据加载与冲突操作 ----------------------------
- double get _rowHeight => (_effectiveFontSize * 1.45 + 4.0).roundToDouble();
-
- EditorTheme get _editorTheme {
- try {
- return context.read().editorTheme;
- } catch (_) {
- return EditorTheme.atomOneDark;
- }
- }
-
- AppFontItem get _editorFont {
- try {
- return context.read().editorFont;
- } catch (_) {
- return AppFonts.editorJetBrainsMono;
- }
- }
-
- // ---------------------------- 数据 ----------------------------
-
- Future _load() async {
+ Future _loadFromDisk({bool isInitial = false}) async {
setState(() {
_isLoading = true;
_errorMessage = null;
});
try {
- // 必须读磁盘:冲突时 Git 已把标记写进文件,内存标签页内容可能已过期
final raw = await FileService.instance.readFileContent(
widget.file.absolutePath,
);
final normalized = raw.replaceAll('\r\n', '\n');
final parsed = GitConflictParser.parse(normalized);
+ final lines = ConflictLineBuilder.build(normalized, parsed);
if (!mounted) return;
setState(() {
+ if (isInitial || _initialContent.isEmpty) {
+ _initialContent = normalized;
+ }
_content = normalized;
_parsed = parsed;
- _lines = ConflictLineBuilder.build(normalized, parsed);
+ _lines = lines;
+ _currentBlockIndex = parsed.blocks.isNotEmpty ? 0 : 0;
_isLoading = false;
});
} catch (e) {
@@ -178,8 +200,9 @@ class _GitConflictResolvePageState extends State {
}
}
- /// 取某块某一段的文本(按该段在**本文件中的绝对行号**切分)
+ /// 获取某冲突块某角色的文本
String _segmentText(int blockIndex, ConflictLineRole side) {
+ if (blockIndex < 0 || blockIndex >= _parsed.blocks.length) return '';
final lines = _content.split('\n');
final block = _parsed.blocks[blockIndex];
final seg = switch (side) {
@@ -194,7 +217,7 @@ class _GitConflictResolvePageState extends State {
return lines.sublist(start, end).join('\n');
}
- /// 用 [replacement] 替换某块并立即写回磁盘
+ /// 替换指定冲突块并同步到磁盘
Future _applyBlock(int blockIndex, String replacement) async {
final newContent = GitConflictParser.replaceBlock(
content: _content,
@@ -213,15 +236,18 @@ class _GitConflictResolvePageState extends State {
}
if (!mounted) return;
- // 替换后行号整体移动:重新解析比维护偏移量可靠得多
final parsed = GitConflictParser.parse(newContent);
setState(() {
_content = newContent;
_parsed = parsed;
_lines = ConflictLineBuilder.build(newContent, parsed);
+ if (_currentBlockIndex >= parsed.blocks.length) {
+ _currentBlockIndex = math.max(0, parsed.blocks.length - 1);
+ }
});
}
+ /// 采用当前侧更改
Future _acceptCurrent(int blockIndex) async {
await _applyBlock(
blockIndex,
@@ -229,6 +255,7 @@ class _GitConflictResolvePageState extends State {
);
}
+ /// 采用传入侧更改
Future _acceptIncoming(int blockIndex) async {
await _applyBlock(
blockIndex,
@@ -236,6 +263,7 @@ class _GitConflictResolvePageState extends State {
);
}
+ /// 保留两段更改
Future _acceptBoth(int blockIndex) async {
final current = _segmentText(blockIndex, ConflictLineRole.oursContent);
final incoming = _segmentText(blockIndex, ConflictLineRole.theirsContent);
@@ -243,47 +271,115 @@ class _GitConflictResolvePageState extends State {
await _applyBlock(blockIndex, combined);
}
- Future _scrollToBlock(int blockIndex) async {
- if (blockIndex < 0 || blockIndex >= _parsed.blocks.length) return;
- if (!_vController.hasClients) return;
- final target = (_parsed.blocks[blockIndex].startLine * _rowHeight - 60)
- .clamp(0.0, _vController.position.maxScrollExtent);
- await _vController.animateTo(
- target,
- duration: const Duration(milliseconds: 220),
- curve: Curves.easeOut,
+ /// 全部采用当前更改
+ Future _acceptAllCurrent() async {
+ if (_parsed.blocks.isEmpty) return;
+ for (var i = _parsed.blocks.length - 1; i >= 0; i--) {
+ await _acceptCurrent(i);
+ }
+ }
+
+ /// 全部采用传入更改
+ Future _acceptAllIncoming() async {
+ if (_parsed.blocks.isEmpty) return;
+ for (var i = _parsed.blocks.length - 1; i >= 0; i--) {
+ await _acceptIncoming(i);
+ }
+ }
+
+ /// 重置为初始冲突状态
+ Future _resetToInitial() async {
+ if (_initialContent.isEmpty) return;
+ try {
+ await FileService.instance.saveFile(
+ widget.file.absolutePath,
+ _initialContent,
+ );
+ } catch (e) {
+ if (!mounted) return;
+ DialogUtils.showToast(context, e.toString(), type: ToastType.error);
+ return;
+ }
+ if (!mounted) return;
+
+ final parsed = GitConflictParser.parse(_initialContent);
+ setState(() {
+ _content = _initialContent;
+ _parsed = parsed;
+ _lines = ConflictLineBuilder.build(_initialContent, parsed);
+ _currentBlockIndex = 0;
+ });
+ DialogUtils.showToast(
+ context,
+ '已重置为初始冲突标记状态',
+ type: ToastType.info,
);
}
- int _nearestBlock(int direction) {
- if (!_vController.hasClients || _parsed.blocks.isEmpty) return 0;
- final currentLine = (_vController.offset / _rowHeight).floor();
- if (direction > 0) {
- for (var i = 0; i < _parsed.blocks.length; i++) {
- if (_parsed.blocks[i].startLine > currentLine) return i;
- }
- return _parsed.blocks.length - 1;
+ /// 计算指定冲突块或行的垂直像素位置(行号与代码行绝对像素级同步)
+ double _calculateLineTopOffset(int lineIndex, double baseRowHeight) {
+ double offset = 0.0;
+ for (int i = 0; i < lineIndex && i < _lines.length; i++) {
+ offset += _getLineHeight(_lines[i], baseRowHeight);
}
- for (var i = _parsed.blocks.length - 1; i >= 0; i--) {
- if (_parsed.blocks[i].startLine < currentLine) return i;
- }
- return 0;
+ return offset;
}
- /// Compare / 手动编辑:交给完整编辑器(带语法高亮、折叠、LSP)
+ /// 平滑滚动到指定冲突块
+ Future _scrollToBlock(
+ int blockIndex,
+ double baseRowHeight,
+ ) async {
+ if (blockIndex < 0 || blockIndex >= _parsed.blocks.length) return;
+ if (!_vController.hasClients) return;
+
+ setState(() => _currentBlockIndex = blockIndex);
+
+ final targetLine = _parsed.blocks[blockIndex].startLine;
+ final targetY = _calculateLineTopOffset(targetLine, baseRowHeight);
+ final maxScroll = _vController.position.maxScrollExtent;
+ final clamped = (targetY - 40.0).clamp(0.0, maxScroll);
+
+ await _vController.animateTo(
+ clamped,
+ duration: const Duration(milliseconds: 250),
+ curve: Curves.easeOutCubic,
+ );
+ }
+
+ void _navigateToNextBlock(double baseRowHeight) {
+ if (_parsed.blocks.isEmpty) return;
+ final nextIndex = (_currentBlockIndex + 1) % _parsed.blocks.length;
+ _scrollToBlock(nextIndex, baseRowHeight);
+ }
+
+ void _navigateToPrevBlock(double baseRowHeight) {
+ if (_parsed.blocks.isEmpty) return;
+ final prevIndex =
+ (_currentBlockIndex - 1 + _parsed.blocks.length) % _parsed.blocks.length;
+ _scrollToBlock(prevIndex, baseRowHeight);
+ }
+
+ /// 在完整编辑器中打开并手动编辑
Future _openInEditor() async {
final tabProvider = context.read();
await tabProvider.reloadTabFromDisk(widget.file.absolutePath);
await tabProvider.openFile(widget.file.absolutePath);
if (!mounted) return;
- Navigator.of(context).pop();
+ // 1. 一路关闭全屏冲突页及底下的下拉菜单/冲突面板,回到主页面
+ final nav = Navigator.of(context);
+ if (nav.canPop()) {
+ nav.popUntil((route) => route.isFirst);
+ }
+ // 2. 关闭主界面侧边栏抽屉,直达代码编辑区
+ MainView.closeDrawerIfOpen();
}
+ /// 保存并标记为已解决
Future _saveAndMark() async {
final l10n = AppLocalizations.of(context)!;
-
- // 防线:仍有标记时不允许静默标记 —— 那会把标记当作正常内容提交
final remaining = _parsed.blocks.length;
+
if (remaining > 0) {
final stillMark = await showDialog(
context: context,
@@ -337,118 +433,685 @@ class _GitConflictResolvePageState extends State {
}
}
- // ---------------------------- 渲染 ----------------------------
+ // ---------------------------- 比较查看 (Compare Changes) 弹窗 ----------------------------
+
+ void _showCompareDialog(
+ int blockIndex,
+ EditorTheme editorTheme,
+ AppFontItem editorFont,
+ double fontSize,
+ ) {
+ if (blockIndex < 0 || blockIndex >= _parsed.blocks.length) return;
+ final block = _parsed.blocks[blockIndex];
+ final oursText = _segmentText(blockIndex, ConflictLineRole.oursContent);
+ final theirsText = _segmentText(blockIndex, ConflictLineRole.theirsContent);
+
+ final split = GitDiffHelper.computeSplitDiff(oursText, theirsText);
+
+ showDialog(
+ context: context,
+ builder: (dialogCtx) => _ConflictCompareDialog(
+ blockIndex: blockIndex,
+ oursLabel: block.oursLabel.isNotEmpty ? block.oursLabel : '当前侧 (Current)',
+ theirsLabel: block.theirsLabel.isNotEmpty ? block.theirsLabel : '传入侧 (Incoming)',
+ oursText: oursText,
+ theirsText: theirsText,
+ splitDiff: split,
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ fontSize: fontSize,
+ onAcceptCurrent: () {
+ Navigator.of(dialogCtx).pop();
+ _acceptCurrent(blockIndex);
+ },
+ onAcceptIncoming: () {
+ Navigator.of(dialogCtx).pop();
+ _acceptIncoming(blockIndex);
+ },
+ onAcceptBoth: () {
+ Navigator.of(dialogCtx).pop();
+ _acceptBoth(blockIndex);
+ },
+ ),
+ );
+ }
+
+ // ---------------------------- 手势与平滑缩放管理 (与 GitDiffPage 规范一致) ----------------------------
+
+ void _handlePointerDown(
+ PointerDownEvent event,
+ double currentFontSize,
+ double rowH,
+ double charW,
+ ) {
+ if (_isInteractingWithCodeLens) return;
+ _pointers[event.pointer] = event.position;
+ if (_pointers.length == 1) {
+ _lastPanPos = event.position;
+ _velocityTracker = VelocityTracker.withKind(event.kind);
+ _velocityTracker?.addPosition(event.timeStamp, event.position);
+ } else if (_pointers.length >= 2 && !_isPinching) {
+ final keys = _pointers.keys.toList();
+ _pointer1 = keys[0];
+ _pointer2 = keys[1];
+
+ final p1 = _pointers[_pointer1]!;
+ final p2 = _pointers[_pointer2]!;
+
+ _initialDistance = (p1 - p2).distance;
+ _initialFontSize = _activeZoomFontSize ?? currentFontSize;
+ _activeZoomFontSize = _initialFontSize;
+
+ final globalFocal = (p1 + p2) / 2;
+ final renderBox = context.findRenderObject() as RenderBox?;
+ final localFocal =
+ renderBox != null ? renderBox.globalToLocal(globalFocal) : globalFocal;
+ _initialLocalFocal = localFocal;
+
+ final curV = _vController.hasClients ? _vController.offset : 0.0;
+ final curH = _hController.hasClients ? _hController.offset : 0.0;
+
+ _focalLineContinuous = (curV + localFocal.dy) / math.max(1.0, rowH);
+ _focalCharContinuous = curH <= 4.0 ? 0.0 : curH / math.max(1.0, charW);
+
+ _lastPanPos = null;
+ setState(() => _isPinching = true);
+ }
+ }
+
+ void _handlePointerMove(PointerMoveEvent event) {
+ if (_isInteractingWithCodeLens) return;
+ if (!_pointers.containsKey(event.pointer)) return;
+ _pointers[event.pointer] = event.position;
+
+ if (_isPinching) {
+ if (_pointer1 != null &&
+ _pointer2 != null &&
+ _pointers.containsKey(_pointer1) &&
+ _pointers.containsKey(_pointer2) &&
+ _initialDistance != null &&
+ _initialDistance! > 10.0 &&
+ _initialFontSize != null &&
+ _initialLocalFocal != null) {
+ final p1 = _pointers[_pointer1]!;
+ final p2 = _pointers[_pointer2]!;
+
+ final currentDistance = (p1 - p2).distance;
+ final rawScale = currentDistance / _initialDistance!;
+
+ final minScale = SettingsProvider.minFontSize / _initialFontSize!;
+ final maxScale = SettingsProvider.maxFontSize / _initialFontSize!;
+ final clampedScale = rawScale.clamp(minScale * 0.9, maxScale * 1.1);
+
+ final continuousFontSize =
+ ((_initialFontSize! * clampedScale) * 10).round() / 10.0;
+ final newFontSize = continuousFontSize.clamp(
+ SettingsProvider.minFontSize,
+ SettingsProvider.maxFontSize,
+ );
+
+ final newRowH = (newFontSize * 1.45 + 4.0).roundToDouble();
+ final newCharW = newFontSize * 0.60;
+
+ final currentGlobalFocal = (p1 + p2) / 2;
+ final renderBox = context.findRenderObject() as RenderBox?;
+ final currentLocalFocal = renderBox != null
+ ? renderBox.globalToLocal(currentGlobalFocal)
+ : currentGlobalFocal;
+ _currentLocalFocal = currentLocalFocal;
+
+ final targetScrollV =
+ _focalLineContinuous * newRowH - currentLocalFocal.dy;
+ final targetScrollH = _focalCharContinuous <= 0.0
+ ? 0.0
+ : _focalCharContinuous * newCharW;
+
+ _syncing = true;
+ if (_vController.hasClients) {
+ final maxV = _vController.position.maxScrollExtent;
+ final clampedV =
+ targetScrollV.clamp(0.0, math.max(maxV, targetScrollV)).toDouble();
+ _vController.jumpTo(clampedV);
+ if (_gutterController.hasClients) _gutterController.jumpTo(clampedV);
+ }
+ if (_hController.hasClients) {
+ final maxH = _hController.position.maxScrollExtent;
+ final clampedH =
+ targetScrollH.clamp(0.0, math.max(maxH, targetScrollH)).toDouble();
+ _hController.jumpTo(clampedH);
+ }
+ _syncing = false;
+
+ if (_splitFontSize != newFontSize) {
+ setState(() {
+ _splitFontSize = newFontSize;
+ _activeZoomFontSize = newFontSize;
+ });
+ }
+ }
+ } else if (_pointers.length == 1 && !_isPinching) {
+ _velocityTracker?.addPosition(event.timeStamp, event.position);
+ final curPos = event.position;
+ if (_lastPanPos != null) {
+ final delta = curPos - _lastPanPos!;
+ _syncing = true;
+ if (_vController.hasClients) {
+ final maxV = _vController.position.maxScrollExtent;
+ final newV = (_vController.offset - delta.dy).clamp(0.0, maxV);
+ _vController.jumpTo(newV);
+ if (_gutterController.hasClients) _gutterController.jumpTo(newV);
+ }
+ if (_hController.hasClients) {
+ final maxH = _hController.position.maxScrollExtent;
+ final newH = (_hController.offset - delta.dx).clamp(0.0, maxH);
+ _hController.jumpTo(newH);
+ }
+ _syncing = false;
+ }
+ _lastPanPos = curPos;
+ }
+ }
+
+ void _finishPinchZoom() {
+ final finalSize = _activeZoomFontSize;
+ if (finalSize != null) {
+ final double targetFontSize = finalSize
+ .clamp(
+ SettingsProvider.minFontSize,
+ SettingsProvider.maxFontSize,
+ )
+ .roundToDouble();
+ _splitFontSize = targetFontSize;
+ final finalH = (targetFontSize * 1.45 + 4.0).roundToDouble();
+ final finalW = targetFontSize * 0.60;
+ final currentLocalFocal = _currentLocalFocal ?? _initialLocalFocal;
+ if (currentLocalFocal != null) {
+ final targetScrollV =
+ _focalLineContinuous * finalH - currentLocalFocal.dy;
+ final targetScrollH = _focalCharContinuous <= 0.0
+ ? 0.0
+ : _focalCharContinuous * finalW;
+ _syncing = true;
+ if (_vController.hasClients) {
+ final maxV = _vController.position.maxScrollExtent;
+ final clampedV =
+ targetScrollV.clamp(0.0, math.max(maxV, targetScrollV)).toDouble();
+ _vController.jumpTo(clampedV);
+ if (_gutterController.hasClients) _gutterController.jumpTo(clampedV);
+ }
+ if (_hController.hasClients) {
+ final maxH = _hController.position.maxScrollExtent;
+ final clampedH =
+ targetScrollH.clamp(0.0, math.max(maxH, targetScrollH)).toDouble();
+ _hController.jumpTo(clampedH);
+ }
+ _syncing = false;
+ }
+ }
+ setState(() {
+ _isPinching = false;
+ _pointer1 = null;
+ _pointer2 = null;
+ _initialDistance = null;
+ _initialFontSize = null;
+ _activeZoomFontSize = null;
+ _initialLocalFocal = null;
+ _currentLocalFocal = null;
+ });
+ }
+
+ void _handlePointerUp(PointerUpEvent event) {
+ _pointers.remove(event.pointer);
+ if (_isInteractingWithCodeLens) {
+ _isInteractingWithCodeLens = false;
+ _lastPanPos = null;
+ return;
+ }
+ if (_isPinching &&
+ (_pointers.length < 2 ||
+ event.pointer == _pointer1 ||
+ event.pointer == _pointer2)) {
+ _finishPinchZoom();
+ } else if (!_isPinching && _pointers.isEmpty) {
+ if (_velocityTracker != null) {
+ final estimate = _velocityTracker!.getVelocity();
+ final velocity = estimate.pixelsPerSecond;
+ if (velocity.dy.abs() > 60 && _vController.hasClients) {
+ final maxV = _vController.position.maxScrollExtent;
+ final targetV =
+ (_vController.offset - velocity.dy * 0.22).clamp(0.0, maxV);
+ _vController.animateTo(
+ targetV,
+ duration: const Duration(milliseconds: 350),
+ curve: Curves.easeOutCubic,
+ );
+ }
+ if (velocity.dx.abs() > 60 && _hController.hasClients) {
+ final maxH = _hController.position.maxScrollExtent;
+ final targetH =
+ (_hController.offset - velocity.dx * 0.22).clamp(0.0, maxH);
+ _hController.animateTo(
+ targetH,
+ duration: const Duration(milliseconds: 350),
+ curve: Curves.easeOutCubic,
+ );
+ }
+ }
+ _lastPanPos = null;
+ }
+ }
+
+ void _handlePointerCancel(PointerCancelEvent event) {
+ _pointers.remove(event.pointer);
+ if (_isInteractingWithCodeLens) {
+ _isInteractingWithCodeLens = false;
+ _lastPanPos = null;
+ return;
+ }
+ if (_isPinching) {
+ _finishPinchZoom();
+ }
+ _lastPanPos = null;
+ }
+
+ Widget _buildZoomBadge(EditorTheme editorTheme, double fontSize) {
+ return Positioned(
+ top: 16,
+ left: 0,
+ right: 0,
+ child: Center(
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
+ decoration: BoxDecoration(
+ color: editorTheme.isDark
+ ? Colors.white.withValues(alpha: 0.85)
+ : Colors.black.withValues(alpha: 0.75),
+ borderRadius: BorderRadius.circular(16),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.2),
+ blurRadius: 6,
+ offset: const Offset(0, 2),
+ ),
+ ],
+ ),
+ child: Text(
+ '${fontSize.toStringAsFixed(1)} pt',
+ style: TextStyle(
+ color: editorTheme.isDark ? Colors.black : Colors.white,
+ fontWeight: FontWeight.bold,
+ fontSize: 13,
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ // ---------------------------- 语法高亮缓存 ----------------------------
+
+ TextSpan _getHighlightedLineSpan({
+ required String code,
+ required TextStyle baseStyle,
+ required EditorTheme editorTheme,
+ }) {
+ if (code.isEmpty) {
+ return TextSpan(text: '', style: baseStyle);
+ }
+ final key = '${baseStyle.fontSize}-${editorTheme.id}-$code';
+ final cached = _highlightSpanCache[key];
+ if (cached != null) return cached;
+
+ final span = SyntaxHighlightHelper.highlightLine(
+ code: code,
+ filePath: widget.file.relativePath,
+ baseStyle: baseStyle,
+ highlightTheme: editorTheme.highlightTheme,
+ );
+ _highlightSpanCache[key] = span;
+ return span;
+ }
+
+ // ---------------------------- 核心 UI 构建 ----------------------------
+
+ double _getLineHeight(ConflictLine line, double baseRowHeight) {
+ // 冲突块开头标记行渲染 CodeLens 操作栏 + 标记行标题,其他行按 baseRowHeight
+ if (line.role == ConflictLineRole.oursHeader) {
+ return baseRowHeight + _codeLensBarHeight;
+ }
+ return baseRowHeight;
+ }
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
+ final colorScheme = theme.colorScheme;
final l10n = AppLocalizations.of(context)!;
- final editorTheme = _editorTheme;
- final remaining = _parsed.blocks.length;
+
+ // 获取独立的代码编辑器主题与默认字号配置(对齐 GitDiffPage)
+ EditorTheme editorTheme = EditorTheme.atomOneDark;
+ double baseFontSize = 14.0;
+ AppFontItem editorFont = AppFonts.editorJetBrainsMono;
+ try {
+ final settings = context.watch();
+ editorTheme = settings.editorTheme;
+ baseFontSize = settings.fontSize;
+ editorFont = settings.editorFont;
+ } catch (_) {}
+
+ final displayFontSize =
+ _activeZoomFontSize ?? _splitFontSize ?? baseFontSize;
+ final baseRowHeight = (displayFontSize * 1.45 + 4.0).roundToDouble();
+ final remainingConflicts = _parsed.blocks.length;
+
+ final fileName = p.basename(widget.file.relativePath);
+ final dirPath = p.dirname(widget.file.relativePath);
return Scaffold(
backgroundColor: editorTheme.backgroundColor,
appBar: AppBar(
- backgroundColor: editorTheme.backgroundColor,
- foregroundColor: editorTheme.textColor,
- title: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
+ titleSpacing: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back_rounded),
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ title: Row(
children: [
- Text(
- p.basename(widget.file.relativePath),
- style: TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.w600,
- color: editorTheme.textColor,
- ),
+ Icon(
+ FileIconUtils.getIcon(name: fileName, isDirectory: false),
+ size: 18,
+ color: colorScheme.onSurfaceVariant,
),
- Text(
- widget.file.relativePath,
- style: TextStyle(
- fontSize: 10.5,
- color: editorTheme.gutterTextColor,
+ const SizedBox(width: 8),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Row(
+ children: [
+ Flexible(
+ child: Text(
+ fileName,
+ style: const TextStyle(
+ fontSize: 14.5,
+ fontWeight: FontWeight.bold,
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ // 冲突状态徽标(VS Code 风格)
+ if (!_isLoading) ...[
+ const SizedBox(width: 6),
+ Flexible(
+ child: _parsed.isMalformed
+ ? Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 1.5,
+ ),
+ decoration: BoxDecoration(
+ color: Colors.orange.withValues(alpha: 0.2),
+ borderRadius: BorderRadius.circular(10),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Icon(
+ Icons.warning_amber_rounded,
+ size: 11,
+ color: Colors.orange,
+ ),
+ const SizedBox(width: 3),
+ Flexible(
+ child: Text(
+ l10n.gitConflictMalformedBadge,
+ style: const TextStyle(
+ fontSize: 10.5,
+ fontWeight: FontWeight.bold,
+ color: Colors.orange,
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ )
+ : (remainingConflicts > 0
+ ? Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 1.5,
+ ),
+ decoration: BoxDecoration(
+ color: colorScheme.errorContainer.withValues(
+ alpha: 0.85,
+ ),
+ borderRadius: BorderRadius.circular(10),
+ ),
+ child: Text(
+ l10n.gitConflictUnresolvedBadge(remainingConflicts),
+ style: TextStyle(
+ fontSize: 10.5,
+ fontWeight: FontWeight.bold,
+ color: colorScheme.onErrorContainer,
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ )
+ : Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 1.5,
+ ),
+ decoration: BoxDecoration(
+ color: Colors.green.withValues(alpha: 0.2),
+ borderRadius: BorderRadius.circular(10),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Icon(
+ Icons.check_circle_rounded,
+ size: 11,
+ color: Colors.green,
+ ),
+ const SizedBox(width: 3),
+ Flexible(
+ child: Text(
+ l10n.gitConflictAllResolvedBadge,
+ style: const TextStyle(
+ fontSize: 10.5,
+ fontWeight: FontWeight.bold,
+ color: Colors.green,
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ )),
+ ),
+ ],
+ ],
+ ),
+ if (dirPath != '.' && dirPath.isNotEmpty)
+ Text(
+ dirPath,
+ style: TextStyle(
+ fontSize: 10.5,
+ color: colorScheme.onSurfaceVariant.withValues(
+ alpha: 0.6,
+ ),
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
),
],
),
actions: [
- if (!_isLoading && remaining > 0) ...[
- IconButton(
- tooltip: l10n.gitConflictPrev,
- icon: const Icon(Icons.keyboard_arrow_up, size: 20),
- onPressed: () => _scrollToBlock(_nearestBlock(-1)),
- ),
- IconButton(
- tooltip: l10n.gitConflictNext,
- icon: const Icon(Icons.keyboard_arrow_down, size: 20),
- onPressed: () => _scrollToBlock(_nearestBlock(1)),
- ),
- Padding(
- padding: const EdgeInsets.only(right: 10),
- child: Center(
- child: Text(
- l10n.gitConflictUnresolvedRemain(remaining),
- style: TextStyle(
- fontSize: 11,
- fontWeight: FontWeight.w600,
- color: theme.colorScheme.error,
+ // 上一处冲突
+ IconButton(
+ visualDensity: VisualDensity.compact,
+ padding: EdgeInsets.zero,
+ constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
+ splashRadius: 16,
+ iconSize: 20,
+ icon: const Icon(Icons.keyboard_arrow_up_rounded),
+ tooltip: l10n.gitConflictPrev,
+ onPressed: (!_isLoading && _parsed.blocks.isNotEmpty)
+ ? () => _navigateToPrevBlock(baseRowHeight)
+ : null,
+ ),
+ // 下一处冲突
+ IconButton(
+ visualDensity: VisualDensity.compact,
+ padding: EdgeInsets.zero,
+ constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
+ splashRadius: 16,
+ iconSize: 20,
+ icon: const Icon(Icons.keyboard_arrow_down_rounded),
+ tooltip: l10n.gitConflictNext,
+ onPressed: (!_isLoading && _parsed.blocks.isNotEmpty)
+ ? () => _navigateToNextBlock(baseRowHeight)
+ : null,
+ ),
+ // 更多操作下拉菜单
+ PopupMenuButton(
+ tooltip: l10n.gitConflictMoreOptions,
+ icon: const Icon(Icons.more_vert_rounded, size: 20),
+ onSelected: (val) {
+ switch (val) {
+ case 'all_current':
+ _acceptAllCurrent();
+ break;
+ case 'all_incoming':
+ _acceptAllIncoming();
+ break;
+ case 'reset_initial':
+ _resetToInitial();
+ break;
+ case 'reload_disk':
+ _loadFromDisk();
+ break;
+ }
+ },
+ itemBuilder: (ctx) => [
+ if (remainingConflicts > 0) ...[
+ PopupMenuItem(
+ value: 'all_current',
+ child: Row(
+ children: [
+ const Icon(
+ Icons.done_all_rounded,
+ size: 16,
+ color: Color(0xFF4CAF50),
+ ),
+ const SizedBox(width: 8),
+ Text(l10n.gitConflictAllOurs),
+ ],
),
),
+ PopupMenuItem(
+ value: 'all_incoming',
+ child: Row(
+ children: [
+ const Icon(
+ Icons.done_all_rounded,
+ size: 16,
+ color: Color(0xFF2196F3),
+ ),
+ const SizedBox(width: 8),
+ Text(l10n.gitConflictAllTheirs),
+ ],
+ ),
+ ),
+ const PopupMenuDivider(),
+ ],
+ PopupMenuItem(
+ value: 'reset_initial',
+ child: Row(
+ children: [
+ const Icon(Icons.restore_rounded, size: 16),
+ const SizedBox(width: 8),
+ Text(l10n.gitConflictResetToInitial),
+ ],
+ ),
),
+ PopupMenuItem(
+ value: 'reload_disk',
+ child: Row(
+ children: [
+ const Icon(Icons.refresh_rounded, size: 16),
+ const SizedBox(width: 8),
+ Text(l10n.gitConflictReloadFromDisk),
+ ],
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(width: 6),
+ ],
+ ),
+ body: Column(
+ children: [
+ Expanded(
+ child: _buildBody(
+ context: context,
+ theme: theme,
+ l10n: l10n,
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ displayFontSize: displayFontSize,
+ baseRowHeight: baseRowHeight,
),
- ],
+ ),
+ _buildBottomBar(context, l10n, editorTheme, remainingConflicts),
],
),
- body: _buildBody(theme, l10n, editorTheme),
);
}
- Widget _buildBody(
- ThemeData theme,
- AppLocalizations l10n,
- EditorTheme editorTheme,
- ) {
+ Widget _buildBody({
+ required BuildContext context,
+ required ThemeData theme,
+ required AppLocalizations l10n,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required double displayFontSize,
+ required double baseRowHeight,
+ }) {
if (_isLoading) {
- return Center(
- child: CircularProgressIndicator(color: theme.colorScheme.primary),
+ return Container(
+ color: editorTheme.backgroundColor,
+ width: double.infinity,
+ height: double.infinity,
+ child: const Center(child: CircularProgressIndicator()),
);
}
+
if (_errorMessage != null) {
- return Center(
- child: Padding(
- padding: const EdgeInsets.all(24),
+ return Container(
+ color: editorTheme.backgroundColor,
+ width: double.infinity,
+ height: double.infinity,
+ child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Icon(
- Icons.error_outline,
- color: theme.colorScheme.error,
- size: 32,
- ),
- const SizedBox(height: 10),
+ const Icon(Icons.error_outline, size: 44, color: Colors.red),
+ const SizedBox(height: 12),
Text(
- l10n.gitConflictLoadFailed,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: editorTheme.textColor,
- ),
- ),
- const SizedBox(height: 6),
- SelectableText(
_errorMessage!,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 11,
- color: editorTheme.gutterTextColor,
- ),
+ style: TextStyle(fontSize: 13, color: editorTheme.textColor),
),
- const SizedBox(height: 14),
- OutlinedButton(
- onPressed: _load,
- child: Text(l10n.gitRepairCheckRerun),
+ const SizedBox(height: 12),
+ FilledButton.icon(
+ onPressed: () => _loadFromDisk(),
+ icon: const Icon(Icons.refresh, size: 16),
+ label: Text(l10n.gitRefresh),
),
],
),
@@ -456,66 +1119,77 @@ class _GitConflictResolvePageState extends State {
);
}
- return Column(
- children: [
- Expanded(child: _buildEditorArea(theme, l10n, editorTheme)),
- _buildBottomBar(l10n, editorTheme),
- ],
- );
- }
-
- /// 只读行渲染区:行号栏固定 + 代码区全向滚动 + 双指缩放
- Widget _buildEditorArea(
- ThemeData theme,
- AppLocalizations l10n,
- EditorTheme editorTheme,
- ) {
- final fontSize = _effectiveFontSize;
- final rowHeight = _rowHeight;
- final charW = fontSize * 0.62;
final gutterBg =
editorTheme.gutterBackgroundColor ?? editorTheme.backgroundColor;
- final dividerColor = editorTheme.gutterTextColor.withValues(alpha: 0.25);
+ final gutterDividerColor =
+ editorTheme.gutterTextColor.withValues(alpha: 0.25);
+ final displayCharWidth = displayFontSize * 0.60;
- return Stack(
- children: [
- Positioned.fill(
- child: LayoutBuilder(
- builder: (context, constraints) {
- final viewportWidth = constraints.maxWidth;
- final digits = '${_lines.length}'.length;
- final signW = (charW + 4.0).clamp(14.0, 36.0);
- final gutterWidth = math.max(46.0, digits * charW + signW + 14.0);
- final hasCodeArea = viewportWidth > gutterWidth + 1;
- final actualGutter = hasCodeArea
- ? gutterWidth
- : math.max(0.0, viewportWidth - 1.0);
+ return LayoutBuilder(
+ builder: (ctx, constraints) {
+ final viewportWidth = constraints.maxWidth;
+ final totalLines = _lines.length;
+ final digits = totalLines > 0 ? '$totalLines'.length : 1;
+ final signW = (displayCharWidth + 4.0).clamp(14.0, 36.0);
+ final gutterWidth =
+ math.max(46.0, digits * displayCharWidth + signW + 14.0);
- int maxChars = 0;
- for (final l in _lines) {
- if (l.text.length > maxChars) maxChars = l.text.length;
- }
- final codeAvailable = math.max(
- 10.0,
- viewportWidth - gutterWidth - 1,
- );
- final maxCodeWidth = math.max(
- codeAvailable,
- maxChars * charW + 240.0,
- );
+ final bool hasCodeArea = viewportWidth > (gutterWidth + 1.0);
+ final double actualGutterWidth = hasCodeArea
+ ? gutterWidth
+ : math.max(0.0, viewportWidth - 1.0);
+ final bool hasDivider = viewportWidth >= 1.0;
- return Listener(
- behavior: HitTestBehavior.opaque,
- onPointerDown: (e) => _handlePointerDown(e, fontSize),
- onPointerMove: _handlePointerMove,
- onPointerUp: _handlePointerUp,
- onPointerCancel: _handlePointerCancel,
+ int maxChars = 0;
+ for (final l in _lines) {
+ if (l.text.length > maxChars) maxChars = l.text.length;
+ }
+ final codeContentAvailableWidth =
+ math.max(10.0, viewportWidth - gutterWidth - 1.0);
+ final maxCodeWidth = math.max(
+ codeContentAvailableWidth,
+ maxChars * displayCharWidth + 240.0,
+ );
+
+ return Listener(
+ behavior: HitTestBehavior.opaque,
+ onPointerDown: (e) => _handlePointerDown(
+ e,
+ displayFontSize,
+ baseRowHeight,
+ displayCharWidth,
+ ),
+ onPointerMove: _handlePointerMove,
+ onPointerUp: _handlePointerUp,
+ onPointerCancel: _handlePointerCancel,
+ child: Stack(
+ children: [
+ // 1. 底层常驻背景与分割线(对标 GitDiffPage)
+ Positioned.fill(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- if (actualGutter > 0)
+ if (actualGutterWidth > 0)
+ Container(width: actualGutterWidth, color: gutterBg),
+ if (hasDivider)
+ Container(width: 1.0, color: gutterDividerColor),
+ if (hasCodeArea)
+ Expanded(
+ child: Container(color: editorTheme.backgroundColor),
+ ),
+ ],
+ ),
+ ),
+
+ // 2. 主体视口内容
+ Positioned.fill(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // 行号栏(与代码区高度严格同步,彻底消除错位)
+ if (actualGutterWidth > 0)
SizedBox(
- width: actualGutter,
+ width: actualGutterWidth,
child: ClipRect(
child: OverflowBox(
alignment: Alignment.centerRight,
@@ -523,28 +1197,31 @@ class _GitConflictResolvePageState extends State {
maxWidth: gutterWidth,
child: SizedBox(
width: gutterWidth,
- child: Container(
- color: gutterBg,
- child: ListView.builder(
- controller: _gutterController,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: _lines.length,
- itemExtent: rowHeight,
- padding: const EdgeInsets.only(bottom: 240),
- itemBuilder: (ctx, i) => _buildGutterRow(
- _lines[i],
- rowHeight,
- fontSize,
- editorTheme,
- ),
- ),
+ child: ListView.builder(
+ controller: _gutterController,
+ physics: const NeverScrollableScrollPhysics(),
+ itemCount: _lines.length,
+ padding: const EdgeInsets.only(bottom: 240.0),
+ itemBuilder: (ctx, index) {
+ return _buildGutterItem(
+ line: _lines[index],
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ fontSize: displayFontSize,
+ baseRowHeight: baseRowHeight,
+ signW: signW,
+ );
+ },
),
),
),
),
),
- if (viewportWidth >= 1)
- Container(width: 1.0, color: dividerColor),
+
+ if (hasDivider)
+ Container(width: 1.0, color: gutterDividerColor),
+
+ // 代码内容区(横向滚动支撑与垂直列表同步)
if (hasCodeArea)
Expanded(
child: SingleChildScrollView(
@@ -557,87 +1234,170 @@ class _GitConflictResolvePageState extends State {
controller: _vController,
physics: const NeverScrollableScrollPhysics(),
itemCount: _lines.length,
- itemExtent: rowHeight,
- padding: const EdgeInsets.only(bottom: 240),
- itemBuilder: (ctx, i) => _buildCodeRow(
- _lines[i],
- rowHeight,
- fontSize,
- editorTheme,
- l10n,
- ),
+ padding: const EdgeInsets.only(bottom: 240.0),
+ itemBuilder: (ctx, index) {
+ return _buildCodeItem(
+ line: _lines[index],
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ fontSize: displayFontSize,
+ baseRowHeight: baseRowHeight,
+ l10n: l10n,
+ availableWidth: codeContentAvailableWidth,
+ );
+ },
),
),
),
),
],
),
- );
- },
+ ),
+
+ // 畸形冲突警告横幅
+ if (_parsed.isMalformed)
+ Positioned(
+ top: 0,
+ left: 0,
+ right: 0,
+ child: Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 12,
+ vertical: 8,
+ ),
+ decoration: BoxDecoration(
+ color: Colors.amber.shade900.withValues(alpha: 0.92),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.3),
+ blurRadius: 4,
+ offset: const Offset(0, 2),
+ ),
+ ],
+ ),
+ child: Row(
+ children: [
+ const Icon(
+ Icons.warning_amber_rounded,
+ size: 16,
+ color: Colors.white,
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ l10n.gitConflictMalformedBanner,
+ style: const TextStyle(
+ fontSize: 12,
+ color: Colors.white,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+
+ // 缩放实时字号悬浮胶囊
+ if (_isPinching && _activeZoomFontSize != null)
+ _buildZoomBadge(editorTheme, _activeZoomFontSize!),
+ ],
),
- ),
- if (_showZoomBadge) _buildZoomBadge(editorTheme, fontSize),
- ],
+ );
+ },
);
}
- /// 行号栏单行:行号 + 冲突段符号(当前侧 `+` 绿、传入侧 `~` 蓝)
- Widget _buildGutterRow(
- ConflictLine line,
- double rowHeight,
- double fontSize,
- EditorTheme editorTheme,
- ) {
- final sign = switch (line.role) {
- ConflictLineRole.oursContent => '+',
- ConflictLineRole.theirsContent => '~',
- _ => '',
- };
- final signColor = switch (line.role) {
- ConflictLineRole.oursContent => const Color(0xFF3FB950),
- ConflictLineRole.theirsContent => const Color(0xFF58A6FF),
- _ => editorTheme.gutterTextColor,
- };
- final charW = fontSize * 0.62;
- final signW = (charW + 4.0).clamp(14.0, 36.0);
+ // ---------------------------- 行号栏单元格构建 ----------------------------
+
+ Widget _buildGutterItem({
+ required ConflictLine line,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required double fontSize,
+ required double baseRowHeight,
+ required double signW,
+ }) {
+ final isDark = editorTheme.isDark;
+ final rowHeight = _getLineHeight(line, baseRowHeight);
+
+ // 冲突符号与高亮颜色(VS Code 规范)
+ String sign = '';
+ Color? signColor;
+ if (line.isOurs) {
+ sign = line.role == ConflictLineRole.oursHeader ? '!' : '+';
+ signColor = isDark ? const Color(0xFF66BB6A) : const Color(0xFF2E7D32);
+ } else if (line.isTheirs) {
+ sign = line.role == ConflictLineRole.theirsHeader ? '!' : '~';
+ signColor = isDark ? const Color(0xFF58A6FF) : const Color(0xFF1976D2);
+ } else if (line.isBase) {
+ sign = '|';
+ signColor = editorTheme.gutterTextColor;
+ }
+
+ final isOursHeader = line.role == ConflictLineRole.oursHeader;
return Container(
height: rowHeight,
- color: _rowBackground(line.role, editorTheme.isDark),
- padding: const EdgeInsets.symmetric(horizontal: 4),
- child: Row(
+ color: _getGutterBackgroundColor(line.role, isDark),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- Expanded(
- child: Text(
- '${line.lineNumber}',
- textAlign: TextAlign.right,
- style: TextStyle(
- fontSize: (fontSize - 1).clamp(
- SettingsProvider.minFontSize - 1.0,
- SettingsProvider.maxFontSize + 8.0,
- ),
- fontFamily: 'JetBrains Mono',
- height: 1.4,
- color: sign.isEmpty ? editorTheme.gutterTextColor : signColor,
+ // 若为冲突起始行,顶部预留与 CodeLens 相同的 32px 高度并居中展示合并图标
+ if (isOursHeader)
+ Container(
+ height: _codeLensBarHeight,
+ alignment: Alignment.center,
+ child: Icon(
+ Icons.call_merge_rounded,
+ size: 13,
+ color: signColor?.withValues(alpha: 0.8),
),
),
- ),
- const SizedBox(width: 4),
+ // 行号与符号展示区
SizedBox(
- width: signW,
- child: Center(
- child: Text(
- sign,
- style: TextStyle(
- fontSize: (fontSize - 1).clamp(
- SettingsProvider.minFontSize - 1.0,
- SettingsProvider.maxFontSize + 8.0,
+ height: baseRowHeight,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ '${line.lineNumber}',
+ textAlign: TextAlign.right,
+ style: TextStyle(
+ fontSize: (fontSize - 1).clamp(
+ SettingsProvider.minFontSize - 1.0,
+ SettingsProvider.maxFontSize,
+ ),
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ height: 1.4,
+ color: signColor ?? editorTheme.gutterTextColor,
+ ),
+ ),
),
- fontWeight: FontWeight.bold,
- fontFamily: 'JetBrains Mono',
- height: 1.4,
- color: signColor,
- ),
+ const SizedBox(width: 4),
+ SizedBox(
+ width: signW,
+ child: Center(
+ child: Text(
+ sign,
+ style: TextStyle(
+ fontSize: (fontSize - 1).clamp(
+ SettingsProvider.minFontSize - 1.0,
+ SettingsProvider.maxFontSize,
+ ),
+ fontWeight: FontWeight.bold,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ height: 1.4,
+ color: signColor ?? editorTheme.gutterTextColor,
+ ),
+ ),
+ ),
+ ),
+ ],
),
),
),
@@ -646,239 +1406,378 @@ class _GitConflictResolvePageState extends State {
);
}
- /// 代码区单行:按角色渲染
- Widget _buildCodeRow(
- ConflictLine line,
- double rowHeight,
- double fontSize,
- EditorTheme editorTheme,
- AppLocalizations l10n,
- ) {
- if (line.isHeader) {
- return _buildHeaderBand(line, rowHeight, fontSize, editorTheme, l10n);
- }
- if (line.role == ConflictLineRole.separator) {
- return Container(
+ // ---------------------------- 代码内容区单元格构建 ----------------------------
+
+ Widget _buildCodeItem({
+ required ConflictLine line,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required double fontSize,
+ required double baseRowHeight,
+ required AppLocalizations l10n,
+ required double availableWidth,
+ }) {
+ final isDark = editorTheme.isDark;
+ final rowHeight = _getLineHeight(line, baseRowHeight);
+
+ // 1. 冲突标记行开头:渲染 CodeLens 操作栏 + 当前侧色带标头
+ if (line.role == ConflictLineRole.oursHeader) {
+ final blockIndex = line.blockIndex ?? 0;
+ return SizedBox(
height: rowHeight,
- alignment: Alignment.centerLeft,
- padding: const EdgeInsets.only(left: 6, right: 160),
- child: Container(
- height: 3,
- color: editorTheme.gutterTextColor.withValues(alpha: 0.55),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ AnimatedBuilder(
+ animation: _hController,
+ builder: (ctx, child) {
+ final scrollX =
+ _hController.hasClients ? _hController.offset : 0.0;
+ return Padding(
+ padding: EdgeInsets.only(left: math.max(0.0, scrollX)),
+ child: child,
+ );
+ },
+ child: _ConflictCodeLensBar(
+ blockIndex: blockIndex,
+ editorTheme: editorTheme,
+ l10n: l10n,
+ availableWidth: availableWidth,
+ onTouchStart: () => _isInteractingWithCodeLens = true,
+ onTouchEnd: () => _isInteractingWithCodeLens = false,
+ onAcceptCurrent: () => _acceptCurrent(blockIndex),
+ onAcceptIncoming: () => _acceptIncoming(blockIndex),
+ onAcceptBoth: () => _acceptBoth(blockIndex),
+ onCompare: () => _showCompareDialog(
+ blockIndex,
+ editorTheme,
+ editorFont,
+ fontSize,
+ ),
+ ),
+ ),
+ _buildOursHeaderBand(
+ line: line,
+ baseRowHeight: baseRowHeight,
+ fontSize: fontSize,
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ l10n: l10n,
+ ),
+ ],
),
);
}
+ // 2. 传入侧标头色带
+ if (line.role == ConflictLineRole.theirsHeader) {
+ return _buildTheirsHeaderBand(
+ line: line,
+ baseRowHeight: baseRowHeight,
+ fontSize: fontSize,
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ l10n: l10n,
+ );
+ }
+
+ // 3. 基线侧标头色带
+ if (line.role == ConflictLineRole.baseHeader) {
+ return _buildBaseHeaderBand(
+ line: line,
+ baseRowHeight: baseRowHeight,
+ fontSize: fontSize,
+ editorTheme: editorTheme,
+ editorFont: editorFont,
+ l10n: l10n,
+ );
+ }
+
+ // 4. 分隔线 (=======)
+ if (line.role == ConflictLineRole.separator) {
+ return _buildSeparatorLine(
+ baseRowHeight: baseRowHeight,
+ editorTheme: editorTheme,
+ );
+ }
+
+ // 5. 普通上下文行或冲突内容行
final baseStyle = TextStyle(
fontSize: fontSize,
- fontFamily: _editorFont.fontFamily,
- fontFamilyFallback: _editorFont.fallback,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
height: 1.4,
color: editorTheme.textColor,
);
- return Container(
- height: rowHeight,
- color: _rowBackground(line.role, editorTheme.isDark),
- alignment: Alignment.centerLeft,
- padding: const EdgeInsets.only(left: 6.0, right: 160.0),
- child: Text.rich(
- _highlight(line.text, baseStyle, editorTheme, fontSize),
- overflow: TextOverflow.visible,
- softWrap: false,
- ),
+ final span = _getHighlightedLineSpan(
+ code: line.text,
+ baseStyle: baseStyle,
+ editorTheme: editorTheme,
);
- }
- /// 冲突标记行 → 色带标题(含内联操作)
- Widget _buildHeaderBand(
- ConflictLine line,
- double rowHeight,
- double fontSize,
- EditorTheme editorTheme,
- AppLocalizations l10n,
- ) {
- final isCurrent = line.role == ConflictLineRole.oursHeader;
- final isIncoming = line.role == ConflictLineRole.theirsHeader;
+ final contentBg = _getCodeRowBackgroundColor(line.role, isDark);
- final bandColor = isCurrent
- ? const Color(0xFF3FB950)
- : (isIncoming ? const Color(0xFF58A6FF) : const Color(0xFF8B949E));
-
- // 保留 git 原始标记文本,并补上"哪一侧"的说明
- final suffix = isCurrent
- ? ' (${l10n.gitConflictSectionOurs})'
- : (isIncoming ? ' (${l10n.gitConflictSectionTheirs})' : '');
- final blockIndex = line.blockIndex ?? 0;
+ // 左侧高亮边条色 (对标 VS Code 编辑区边缘指示色带)
+ Color? leftIndicatorColor;
+ if (line.role == ConflictLineRole.oursContent) {
+ leftIndicatorColor =
+ isDark ? const Color(0xFF66BB6A) : const Color(0xFF2E7D32);
+ } else if (line.role == ConflictLineRole.theirsContent) {
+ leftIndicatorColor =
+ isDark ? const Color(0xFF58A6FF) : const Color(0xFF1976D2);
+ } else if (line.role == ConflictLineRole.baseContent) {
+ leftIndicatorColor = editorTheme.gutterTextColor.withValues(alpha: 0.6);
+ }
return Container(
- constraints: BoxConstraints(minHeight: rowHeight),
- color: bandColor.withValues(alpha: editorTheme.isDark ? 0.30 : 0.22),
- padding: const EdgeInsets.only(left: 6, right: 8, top: 2, bottom: 2),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
+ height: baseRowHeight,
+ color: contentBg,
+ child: Stack(
children: [
- Text(
- '${line.text}$suffix',
- style: TextStyle(
- fontSize: fontSize - 0.5,
- fontFamily: _editorFont.fontFamily,
- fontFamilyFallback: _editorFont.fallback,
- height: 1.4,
- fontWeight: FontWeight.w600,
- color: bandColor,
+ if (leftIndicatorColor != null)
+ Positioned(
+ left: 0,
+ top: 0,
+ bottom: 0,
+ width: 3.0,
+ child: Container(color: leftIndicatorColor),
+ ),
+ Positioned.fill(
+ child: Container(
+ alignment: Alignment.centerLeft,
+ padding: const EdgeInsets.only(left: 8.0, right: 160.0),
+ child: Text.rich(
+ span,
+ overflow: TextOverflow.visible,
+ softWrap: false,
+ ),
),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
),
- // 基线段仅作参考,不提供操作
- if (isCurrent || isIncoming)
- _buildInlineActions(blockIndex, fontSize, editorTheme, l10n),
],
),
);
}
- /// 内联操作行(VS Code 命名固定,不随所在侧变化)
- Widget _buildInlineActions(
- int blockIndex,
- double fontSize,
- EditorTheme editorTheme,
- AppLocalizations l10n,
- ) {
- const actionColor = Color(0xFF58A6FF);
- final s = (fontSize - 1.5).clamp(9.0, 16.0);
- Widget action(String label, VoidCallback onTap, String keySuffix) {
- return InkWell(
- key: ValueKey('git_conflict_${keySuffix}_$blockIndex'),
- onTap: onTap,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
- child: Text(
- label,
+ // ---------------------------- 各侧标头色带构建 (VS Code 规范) ----------------------------
+
+ Widget _buildOursHeaderBand({
+ required ConflictLine line,
+ required double baseRowHeight,
+ required double fontSize,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required AppLocalizations l10n,
+ }) {
+ final isDark = editorTheme.isDark;
+ final greenColor =
+ isDark ? const Color(0xFF66BB6A) : const Color(0xFF2E7D32);
+
+ return Container(
+ height: baseRowHeight,
+ decoration: BoxDecoration(
+ color: greenColor.withValues(alpha: isDark ? 0.30 : 0.20),
+ border: Border(
+ top: BorderSide(color: greenColor.withValues(alpha: 0.8), width: 1.5),
+ ),
+ ),
+ padding: const EdgeInsets.only(left: 8.0, right: 16.0),
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.arrow_downward_rounded, size: 13, color: greenColor),
+ const SizedBox(width: 4),
+ Text(
+ '${line.text} · ${l10n.gitConflictSectionOurs}',
style: TextStyle(
- fontSize: s,
- color: actionColor,
- fontFamily: _editorFont.fontFamily,
- decoration: TextDecoration.underline,
- decorationColor: actionColor.withValues(alpha: 0.5),
+ fontSize: (fontSize - 1).clamp(
+ SettingsProvider.minFontSize - 1.0,
+ SettingsProvider.maxFontSize,
+ ),
+ fontWeight: FontWeight.bold,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ color: greenColor,
),
),
- ),
- );
- }
+ ],
+ ),
+ );
+ }
- Widget sep() => Padding(
- padding: const EdgeInsets.symmetric(horizontal: 2),
+ Widget _buildTheirsHeaderBand({
+ required ConflictLine line,
+ required double baseRowHeight,
+ required double fontSize,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required AppLocalizations l10n,
+ }) {
+ final isDark = editorTheme.isDark;
+ final blueColor =
+ isDark ? const Color(0xFF58A6FF) : const Color(0xFF1976D2);
+
+ return Container(
+ height: baseRowHeight,
+ decoration: BoxDecoration(
+ color: blueColor.withValues(alpha: isDark ? 0.30 : 0.20),
+ border: Border(
+ bottom: BorderSide(
+ color: blueColor.withValues(alpha: 0.8),
+ width: 1.5,
+ ),
+ ),
+ ),
+ padding: const EdgeInsets.only(left: 8.0, right: 16.0),
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.arrow_upward_rounded, size: 13, color: blueColor),
+ const SizedBox(width: 4),
+ Text(
+ '${line.text} · ${l10n.gitConflictSectionTheirs}',
+ style: TextStyle(
+ fontSize: (fontSize - 1).clamp(
+ SettingsProvider.minFontSize - 1.0,
+ SettingsProvider.maxFontSize,
+ ),
+ fontWeight: FontWeight.bold,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ color: blueColor,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildBaseHeaderBand({
+ required ConflictLine line,
+ required double baseRowHeight,
+ required double fontSize,
+ required EditorTheme editorTheme,
+ required AppFontItem editorFont,
+ required AppLocalizations l10n,
+ }) {
+ final grayColor = editorTheme.gutterTextColor;
+ final isDark = editorTheme.isDark;
+
+ return Container(
+ height: baseRowHeight,
+ color: grayColor.withValues(alpha: isDark ? 0.22 : 0.15),
+ padding: const EdgeInsets.only(left: 8.0, right: 16.0),
+ alignment: Alignment.centerLeft,
child: Text(
- '|',
+ '${line.text} · ${l10n.gitConflictSectionBaseline}',
style: TextStyle(
- fontSize: s,
- color: editorTheme.gutterTextColor.withValues(alpha: 0.7),
+ fontSize: (fontSize - 1).clamp(
+ SettingsProvider.minFontSize - 1.0,
+ SettingsProvider.maxFontSize,
+ ),
+ fontWeight: FontWeight.w600,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ color: grayColor,
),
),
);
+ }
- return Wrap(
- crossAxisAlignment: WrapCrossAlignment.center,
- children: [
- action(
- l10n.gitConflictAcceptCurrent,
- () => _acceptCurrent(blockIndex),
- 'accept_current',
- ),
- sep(),
- action(
- l10n.gitConflictAcceptIncoming,
- () => _acceptIncoming(blockIndex),
- 'accept_incoming',
- ),
- sep(),
- action(
- l10n.gitConflictAcceptBoth,
- () => _acceptBoth(blockIndex),
- 'accept_both',
- ),
- sep(),
- action(l10n.gitConflictCompare, _openInEditor, 'compare'),
- ],
+ Widget _buildSeparatorLine({
+ required double baseRowHeight,
+ required EditorTheme editorTheme,
+ }) {
+ final isDark = editorTheme.isDark;
+ return Container(
+ height: baseRowHeight,
+ color: isDark ? const Color(0xFF1E2227) : const Color(0xFFF1F5F9),
+ alignment: Alignment.centerLeft,
+ padding: const EdgeInsets.only(left: 8.0, right: 160.0),
+ child: Row(
+ children: [
+ Expanded(
+ child: Container(
+ height: 1.0,
+ color: editorTheme.gutterTextColor.withValues(alpha: 0.4),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8.0),
+ child: Text(
+ '=======',
+ style: TextStyle(
+ fontSize: 11,
+ fontFamily: 'JetBrains Mono',
+ fontWeight: FontWeight.bold,
+ color: editorTheme.gutterTextColor.withValues(alpha: 0.6),
+ ),
+ ),
+ ),
+ Expanded(
+ child: Container(
+ height: 1.0,
+ color: editorTheme.gutterTextColor.withValues(alpha: 0.4),
+ ),
+ ),
+ ],
+ ),
);
}
- TextSpan _highlight(
- String code,
- TextStyle baseStyle,
- EditorTheme editorTheme,
- double fontSize,
- ) {
- if (code.isEmpty) return TextSpan(text: '', style: baseStyle);
- final key = '$fontSize-${editorTheme.id}-$code';
- final cached = _highlightCache[key];
- if (cached != null) return cached;
- final span = SyntaxHighlightHelper.highlightLine(
- code: code,
- filePath: widget.file.relativePath,
- baseStyle: baseStyle,
- highlightTheme: editorTheme.highlightTheme,
- );
- _highlightCache[key] = span;
- return span;
- }
+ // ---------------------------- 色彩映射辅助 ----------------------------
- /// 整段底色:当前侧绿、传入侧蓝、基线灰(与 VS Code 一致)
- Color? _rowBackground(ConflictLineRole role, bool isDark) {
+ Color? _getGutterBackgroundColor(ConflictLineRole role, bool isDark) {
return switch (role) {
- ConflictLineRole.oursContent => const Color(
- 0xFF3FB950,
- ).withValues(alpha: isDark ? 0.18 : 0.13),
- ConflictLineRole.theirsContent => const Color(
- 0xFF58A6FF,
- ).withValues(alpha: isDark ? 0.18 : 0.13),
- ConflictLineRole.baseContent => const Color(
- 0xFF8B949E,
- ).withValues(alpha: isDark ? 0.10 : 0.08),
+ ConflictLineRole.oursHeader ||
+ ConflictLineRole.oursContent =>
+ Colors.green.withValues(alpha: isDark ? 0.16 : 0.09),
+ ConflictLineRole.theirsHeader ||
+ ConflictLineRole.theirsContent =>
+ Colors.blue.withValues(alpha: isDark ? 0.16 : 0.09),
+ ConflictLineRole.baseHeader ||
+ ConflictLineRole.baseContent =>
+ Colors.grey.withValues(alpha: isDark ? 0.12 : 0.06),
+ ConflictLineRole.separator =>
+ isDark ? const Color(0xFF1E2227) : const Color(0xFFF1F5F9),
+ ConflictLineRole.context => null,
+ };
+ }
+
+ Color? _getCodeRowBackgroundColor(ConflictLineRole role, bool isDark) {
+ return switch (role) {
+ ConflictLineRole.oursContent =>
+ Colors.green.withValues(alpha: isDark ? 0.14 : 0.08),
+ ConflictLineRole.theirsContent =>
+ Colors.blue.withValues(alpha: isDark ? 0.14 : 0.08),
+ ConflictLineRole.baseContent =>
+ Colors.grey.withValues(alpha: isDark ? 0.10 : 0.05),
_ => null,
};
}
- Widget _buildZoomBadge(EditorTheme editorTheme, double fontSize) {
- return Positioned(
- left: 0,
- right: 0,
- bottom: 12,
- child: Center(
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
- decoration: BoxDecoration(
- color: editorTheme.backgroundColor.withValues(alpha: 0.94),
- borderRadius: BorderRadius.circular(8),
- border: Border.all(
- color: editorTheme.gutterTextColor.withValues(alpha: 0.35),
- ),
- ),
- child: Text(
- '${fontSize.toStringAsFixed(1)}pt',
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.bold,
- color: editorTheme.textColor,
- ),
- ),
- ),
- ),
- );
- }
+ // ---------------------------- 底部操作栏 ----------------------------
+
+ Widget _buildBottomBar(
+ BuildContext context,
+ AppLocalizations l10n,
+ EditorTheme editorTheme,
+ int remainingConflicts,
+ ) {
+ final theme = Theme.of(context);
+ final isDone = !_parsed.isMalformed &&
+ remainingConflicts == 0 &&
+ !GitConflictParser.containsMarkers(_content);
- Widget _buildBottomBar(AppLocalizations l10n, EditorTheme editorTheme) {
return Container(
- padding: const EdgeInsets.fromLTRB(10, 8, 10, 8),
+ padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0),
decoration: BoxDecoration(
- color: editorTheme.gutterBackgroundColor ?? editorTheme.backgroundColor,
+ color: theme.colorScheme.surface,
border: Border(
top: BorderSide(
- color: editorTheme.gutterTextColor.withValues(alpha: 0.3),
+ color: theme.colorScheme.outlineVariant.withValues(alpha: 0.5),
+ width: 1.0,
),
),
),
@@ -886,10 +1785,15 @@ class _GitConflictResolvePageState extends State {
top: false,
child: Row(
children: [
- Expanded(
+ // 手动编辑
+ Flexible(
+ flex: 2,
child: OutlinedButton.icon(
key: const ValueKey('git_conflict_edit_manually'),
onPressed: _openInEditor,
+ style: OutlinedButton.styleFrom(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ ),
icon: const Icon(Icons.edit_outlined, size: 15),
label: Text(
l10n.gitConflictEditManually,
@@ -900,15 +1804,29 @@ class _GitConflictResolvePageState extends State {
),
),
const SizedBox(width: 8),
- Expanded(
- flex: 2,
+ // 保存并标记已解决
+ Flexible(
+ flex: 3,
child: FilledButton.icon(
key: const ValueKey('git_conflict_save_and_mark'),
onPressed: _saveAndMark,
- icon: const Icon(Icons.check, size: 16),
+ style: FilledButton.styleFrom(
+ backgroundColor: isDone ? Colors.green : null,
+ foregroundColor: isDone ? Colors.white : null,
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ ),
+ icon: Icon(
+ isDone ? Icons.check_circle_rounded : Icons.check_rounded,
+ size: 16,
+ ),
label: Text(
- l10n.gitConflictSaveAndMark,
- style: const TextStyle(fontSize: 12),
+ isDone
+ ? l10n.gitConflictResolvedCommit
+ : l10n.gitConflictSaveAndMarkShort,
+ style: const TextStyle(
+ fontSize: 12,
+ fontWeight: FontWeight.bold,
+ ),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -919,108 +1837,500 @@ class _GitConflictResolvePageState extends State {
),
);
}
+}
- // ---------------------------- 手势(Listener 原生指针跟踪) ----------------------------
+// ==============================================================================
+// 冲突操作 CodeLens 悬浮胶囊栏(支持水平手势自由拖动,彻底杜绝 RenderFlex 溢出)
+// ==============================================================================
- void _handlePointerDown(PointerDownEvent event, double fontSize) {
- _pointers[event.pointer] = event.position;
- if (_pointers.length >= 2 && !_isPinching) {
- final keys = _pointers.keys.toList();
- _pointer1 = keys[0];
- _pointer2 = keys[1];
- final p1 = _pointers[_pointer1]!;
- final p2 = _pointers[_pointer2]!;
- _initialDistance = (p1 - p2).distance;
- _initialFontSize = fontSize;
- _isPinching = true;
- _lastPanPos = null;
- setState(() => _showZoomBadge = true);
- } else if (_pointers.length == 1) {
- _lastPanPos = event.position;
- }
+class _ConflictCodeLensBar extends StatefulWidget {
+ const _ConflictCodeLensBar({
+ required this.blockIndex,
+ required this.editorTheme,
+ required this.l10n,
+ required this.availableWidth,
+ required this.onAcceptCurrent,
+ required this.onAcceptIncoming,
+ required this.onAcceptBoth,
+ required this.onCompare,
+ this.onTouchStart,
+ this.onTouchEnd,
+ });
+
+ final int blockIndex;
+ final EditorTheme editorTheme;
+ final AppLocalizations l10n;
+ final double availableWidth;
+ final VoidCallback onAcceptCurrent;
+ final VoidCallback onAcceptIncoming;
+ final VoidCallback onAcceptBoth;
+ final VoidCallback onCompare;
+ final VoidCallback? onTouchStart;
+ final VoidCallback? onTouchEnd;
+
+ @override
+ State<_ConflictCodeLensBar> createState() => _ConflictCodeLensBarState();
+}
+
+class _ConflictCodeLensBarState extends State<_ConflictCodeLensBar> {
+ late final ScrollController _scrollController;
+
+ @override
+ void initState() {
+ super.initState();
+ _scrollController = ScrollController();
}
- void _handlePointerMove(PointerMoveEvent event) {
- if (!_pointers.containsKey(event.pointer)) return;
- _pointers[event.pointer] = event.position;
+ @override
+ void dispose() {
+ _scrollController.dispose();
+ super.dispose();
+ }
- if (_isPinching && _pointer1 != null && _pointer2 != null) {
- final p1 = _pointers[_pointer1];
- final p2 = _pointers[_pointer2];
- if (p1 == null || p2 == null || _initialDistance == null) return;
- if (_initialDistance! <= 0) return;
+ @override
+ Widget build(BuildContext context) {
+ final isDark = widget.editorTheme.isDark;
+ final barBg = isDark ? const Color(0xFF1E2227) : const Color(0xFFF3F4F6);
+ final borderColor = widget.editorTheme.gutterTextColor.withValues(alpha: 0.2);
- final ratio = (p1 - p2).distance / _initialDistance!;
- final base = _initialFontSize ?? _baseFontSize;
- final target = (base * ratio).clamp(
- SettingsProvider.minFontSize.toDouble(),
- SettingsProvider.maxFontSize.toDouble(),
- );
-
- final oldRowHeight = _rowHeight;
- setState(() => _activeZoomFontSize = target);
- final newRowHeight = _rowHeight;
-
- // 以双指中心为锚点,避免缩放时内容跳动
- if (_vController.hasClients && oldRowHeight > 0) {
- final focalDy = ((p1 + p2) / 2).dy;
- final lineUnderFocal = (focalDy + _vController.offset) / oldRowHeight;
- final desired = lineUnderFocal * newRowHeight - focalDy;
- _vController.jumpTo(
- desired.clamp(
- _vController.position.minScrollExtent,
- _vController.position.maxScrollExtent,
+ return Container(
+ height: 32.0,
+ width: math.max(100.0, widget.availableWidth),
+ decoration: BoxDecoration(
+ color: barBg,
+ border: Border(
+ top: BorderSide(color: borderColor, width: 1.0),
+ bottom: BorderSide(color: borderColor, width: 0.5),
+ ),
+ ),
+ child: Listener(
+ behavior: HitTestBehavior.opaque,
+ onPointerDown: (_) => widget.onTouchStart?.call(),
+ onPointerUp: (_) => widget.onTouchEnd?.call(),
+ onPointerCancel: (_) => widget.onTouchEnd?.call(),
+ child: ScrollConfiguration(
+ behavior: ScrollConfiguration.of(context).copyWith(
+ dragDevices: {
+ PointerDeviceKind.touch,
+ PointerDeviceKind.mouse,
+ PointerDeviceKind.trackpad,
+ PointerDeviceKind.stylus,
+ },
),
- );
- }
- return;
- }
-
- // 单指平移:垂直 + 水平
- if (_lastPanPos != null && !_isPinching) {
- final delta = event.position - _lastPanPos!;
- _lastPanPos = event.position;
- if (_vController.hasClients) {
- _vController.jumpTo(
- (_vController.offset - delta.dy).clamp(
- _vController.position.minScrollExtent,
- _vController.position.maxScrollExtent,
+ child: SingleChildScrollView(
+ controller: _scrollController,
+ scrollDirection: Axis.horizontal,
+ physics: const BouncingScrollPhysics(),
+ padding: const EdgeInsets.symmetric(horizontal: 6.0),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _buildChip(
+ key: ValueKey('conflict_accept_current_${widget.blockIndex}'),
+ label: widget.l10n.gitConflictAcceptCurrentShort,
+ icon: Icons.check_rounded,
+ color: isDark ? const Color(0xFF66BB6A) : const Color(0xFF2E7D32),
+ onTap: widget.onAcceptCurrent,
+ tooltip: widget.l10n.gitConflictAcceptCurrent,
+ ),
+ const SizedBox(width: 6),
+ _buildChip(
+ key: ValueKey('conflict_accept_incoming_${widget.blockIndex}'),
+ label: widget.l10n.gitConflictAcceptIncomingShort,
+ icon: Icons.check_rounded,
+ color: isDark ? const Color(0xFF58A6FF) : const Color(0xFF1976D2),
+ onTap: widget.onAcceptIncoming,
+ tooltip: widget.l10n.gitConflictAcceptIncoming,
+ ),
+ const SizedBox(width: 6),
+ _buildChip(
+ key: ValueKey('conflict_accept_both_${widget.blockIndex}'),
+ label: widget.l10n.gitConflictAcceptBothShort,
+ icon: Icons.call_merge_rounded,
+ color: isDark ? const Color(0xFFCE93D8) : const Color(0xFF7B1FA2),
+ onTap: widget.onAcceptBoth,
+ tooltip: widget.l10n.gitConflictAcceptBoth,
+ ),
+ const SizedBox(width: 6),
+ _buildChip(
+ key: ValueKey('conflict_compare_${widget.blockIndex}'),
+ label: widget.l10n.gitConflictCompareShort,
+ icon: Icons.difference_outlined,
+ color: isDark ? const Color(0xFFFFB74D) : const Color(0xFFE65100),
+ onTap: widget.onCompare,
+ tooltip: widget.l10n.gitConflictCompare,
+ ),
+ ],
+ ),
),
- );
- }
- if (_hController.hasClients) {
- _hController.jumpTo(
- (_hController.offset - delta.dx).clamp(
- _hController.position.minScrollExtent,
- _hController.position.maxScrollExtent,
+ ),
+ ),
+ );
+ }
+
+ Widget _buildChip({
+ Key? key,
+ required String label,
+ required IconData icon,
+ required Color color,
+ required VoidCallback onTap,
+ required String tooltip,
+ }) {
+ return Tooltip(
+ message: tooltip,
+ child: Material(
+ key: key,
+ color: Colors.transparent,
+ child: InkWell(
+ borderRadius: BorderRadius.circular(6),
+ onTap: onTap,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
+ decoration: BoxDecoration(
+ color: color.withValues(alpha: 0.12),
+ borderRadius: BorderRadius.circular(6),
+ border: Border.all(
+ color: color.withValues(alpha: 0.35),
+ width: 0.8,
+ ),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(icon, size: 12.5, color: color),
+ const SizedBox(width: 4),
+ Text(
+ label,
+ style: TextStyle(
+ fontSize: 11,
+ fontWeight: FontWeight.w600,
+ color: color,
+ ),
+ ),
+ ],
+ ),
),
- );
- }
- }
- }
-
- void _handlePointerUp(PointerUpEvent event) {
- _pointers.remove(event.pointer);
- if (_pointers.length < 2 && _isPinching) _finishPinch();
- if (_pointers.isEmpty) _lastPanPos = null;
- }
-
- void _handlePointerCancel(PointerCancelEvent event) {
- _pointers.remove(event.pointer);
- if (_pointers.length < 2 && _isPinching) _finishPinch();
- if (_pointers.isEmpty) _lastPanPos = null;
- }
-
- void _finishPinch() {
- _isPinching = false;
- _pointer1 = null;
- _pointer2 = null;
- _initialDistance = null;
- final zoomed = _activeZoomFontSize;
- setState(() {
- if (zoomed != null) _committedFontSize = zoomed;
- _activeZoomFontSize = null;
- _showZoomBadge = false;
- });
+ ),
+ ),
+ );
}
}
+
+// ==============================================================================
+// 冲突比较查看弹窗 (Compare Changes Modal Dialog)
+// ==============================================================================
+
+class _ConflictCompareDialog extends StatelessWidget {
+ const _ConflictCompareDialog({
+ required this.blockIndex,
+ required this.oursLabel,
+ required this.theirsLabel,
+ required this.oursText,
+ required this.theirsText,
+ required this.splitDiff,
+ required this.editorTheme,
+ required this.editorFont,
+ required this.fontSize,
+ required this.onAcceptCurrent,
+ required this.onAcceptIncoming,
+ required this.onAcceptBoth,
+ });
+
+ final int blockIndex;
+ final String oursLabel;
+ final String theirsLabel;
+ final String oursText;
+ final String theirsText;
+ final SplitDiffResult splitDiff;
+ final EditorTheme editorTheme;
+ final AppFontItem editorFont;
+ final double fontSize;
+
+ final VoidCallback onAcceptCurrent;
+ final VoidCallback onAcceptIncoming;
+ final VoidCallback onAcceptBoth;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ final l10n = AppLocalizations.of(context)!;
+ final rowH = (fontSize * 1.35 + 2.0).roundToDouble();
+
+ return Dialog(
+ insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
+ backgroundColor: editorTheme.backgroundColor,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 820, maxHeight: 600),
+ child: Column(
+ children: [
+ // 顶栏标头
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ decoration: BoxDecoration(
+ color: theme.colorScheme.surface,
+ borderRadius: const BorderRadius.vertical(
+ top: Radius.circular(14),
+ ),
+ border: Border(
+ bottom: BorderSide(
+ color: theme.colorScheme.outlineVariant.withValues(
+ alpha: 0.5,
+ ),
+ ),
+ ),
+ ),
+ child: Row(
+ children: [
+ const Icon(
+ Icons.difference_rounded,
+ size: 18,
+ color: Color(0xFFFF9800),
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ l10n.gitConflictCompareTitle(blockIndex + 1),
+ style: const TextStyle(
+ fontSize: 14,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ IconButton(
+ icon: const Icon(Icons.close_rounded, size: 18),
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ ],
+ ),
+ ),
+
+ // 双侧标题标签
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
+ color: editorTheme.isDark
+ ? const Color(0xFF1E2227)
+ : const Color(0xFFEEEEEE),
+ child: Row(
+ children: [
+ Expanded(
+ child: Row(
+ children: [
+ const Icon(
+ Icons.arrow_downward_rounded,
+ size: 13,
+ color: Color(0xFF4CAF50),
+ ),
+ const SizedBox(width: 4),
+ Flexible(
+ child: Text(
+ l10n.gitConflictCurrentWithLabel(oursLabel),
+ style: const TextStyle(
+ fontSize: 11,
+ fontWeight: FontWeight.bold,
+ color: Color(0xFF4CAF50),
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ ),
+ Container(
+ width: 1,
+ height: 16,
+ color: editorTheme.gutterTextColor.withValues(alpha: 0.3),
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Row(
+ children: [
+ const Icon(
+ Icons.arrow_upward_rounded,
+ size: 13,
+ color: Color(0xFF2196F3),
+ ),
+ const SizedBox(width: 4),
+ Flexible(
+ child: Text(
+ l10n.gitConflictIncomingWithLabel(theirsLabel),
+ style: const TextStyle(
+ fontSize: 11,
+ fontWeight: FontWeight.bold,
+ color: Color(0xFF2196F3),
+ ),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+
+ // 差异双栏对比内容
+ Expanded(
+ child: splitDiff.leftLines.isEmpty && splitDiff.rightLines.isEmpty
+ ? Center(
+ child: Text(
+ l10n.gitConflictBothEmpty,
+ style: TextStyle(
+ fontSize: 12,
+ color: editorTheme.gutterTextColor,
+ ),
+ ),
+ )
+ : Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // 左侧 (当前版本)
+ Expanded(
+ child: ListView.builder(
+ itemCount: splitDiff.leftLines.length,
+ itemExtent: rowH,
+ itemBuilder: (ctx, i) {
+ final line = splitDiff.leftLines[i];
+ final isDel = line.type == DiffLineType.deleted;
+ final isEmpty = line.type == DiffLineType.empty;
+ Color? bg;
+ if (isDel) {
+ bg = Colors.red.withValues(
+ alpha: editorTheme.isDark ? 0.22 : 0.12,
+ );
+ } else if (isEmpty) {
+ bg = editorTheme.isDark
+ ? Colors.white.withValues(alpha: 0.03)
+ : Colors.black.withValues(alpha: 0.03);
+ }
+ return Container(
+ color: bg,
+ alignment: Alignment.centerLeft,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ ),
+ child: Text(
+ line.text,
+ style: TextStyle(
+ fontSize: fontSize - 1,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ color: isDel
+ ? (editorTheme.isDark
+ ? const Color(0xFFEF5350)
+ : const Color(0xFFD32F2F))
+ : editorTheme.textColor,
+ ),
+ overflow: TextOverflow.visible,
+ softWrap: false,
+ ),
+ );
+ },
+ ),
+ ),
+ Container(
+ width: 1.0,
+ color: editorTheme.gutterTextColor.withValues(
+ alpha: 0.2,
+ ),
+ ),
+ // 右侧 (传入版本)
+ Expanded(
+ child: ListView.builder(
+ itemCount: splitDiff.rightLines.length,
+ itemExtent: rowH,
+ itemBuilder: (ctx, i) {
+ final line = splitDiff.rightLines[i];
+ final isAdd = line.type == DiffLineType.added;
+ final isEmpty = line.type == DiffLineType.empty;
+ Color? bg;
+ if (isAdd) {
+ bg = Colors.green.withValues(
+ alpha: editorTheme.isDark ? 0.22 : 0.12,
+ );
+ } else if (isEmpty) {
+ bg = editorTheme.isDark
+ ? Colors.white.withValues(alpha: 0.03)
+ : Colors.black.withValues(alpha: 0.03);
+ }
+ return Container(
+ color: bg,
+ alignment: Alignment.centerLeft,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ ),
+ child: Text(
+ line.text,
+ style: TextStyle(
+ fontSize: fontSize - 1,
+ fontFamily: editorFont.fontFamily,
+ fontFamilyFallback: editorFont.fallback,
+ color: isAdd
+ ? (editorTheme.isDark
+ ? const Color(0xFF66BB6A)
+ : const Color(0xFF2E7D32))
+ : editorTheme.textColor,
+ ),
+ overflow: TextOverflow.visible,
+ softWrap: false,
+ ),
+ );
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+
+ // 底栏快速决策按钮
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
+ decoration: BoxDecoration(
+ color: theme.colorScheme.surface,
+ borderRadius: const BorderRadius.vertical(
+ bottom: Radius.circular(14),
+ ),
+ border: Border(
+ top: BorderSide(
+ color: theme.colorScheme.outlineVariant.withValues(
+ alpha: 0.5,
+ ),
+ ),
+ ),
+ ),
+ child: Row(
+ children: [
+ OutlinedButton(
+ onPressed: () => Navigator.of(context).pop(),
+ child: Text(l10n.cancel),
+ ),
+ const Spacer(),
+ OutlinedButton.icon(
+ style: OutlinedButton.styleFrom(
+ foregroundColor: const Color(0xFF2196F3),
+ ),
+ icon: const Icon(Icons.arrow_upward_rounded, size: 14),
+ label: Text(l10n.gitConflictAcceptIncoming),
+ onPressed: onAcceptIncoming,
+ ),
+ const SizedBox(width: 8),
+ FilledButton.icon(
+ style: FilledButton.styleFrom(
+ backgroundColor: const Color(0xFF4CAF50),
+ foregroundColor: Colors.white,
+ ),
+ icon: const Icon(Icons.arrow_downward_rounded, size: 14),
+ label: Text(l10n.gitConflictAcceptCurrent),
+ onPressed: onAcceptCurrent,
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+
diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt
index fdb22fa..ae88539 100644
--- a/linux/CMakeLists.txt
+++ b/linux/CMakeLists.txt
@@ -7,7 +7,7 @@ project(runner LANGUAGES CXX)
set(BINARY_NAME "code_editor")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
-set(APPLICATION_ID "com.example.code_editor")
+set(APPLICATION_ID "com.lzxnone.code_editor")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj
index be719a6..2e00f93 100644
--- a/macos/Runner.xcodeproj/project.pbxproj
+++ b/macos/Runner.xcodeproj/project.pbxproj
@@ -385,7 +385,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
@@ -399,7 +399,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
@@ -413,7 +413,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
- PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor.RunnerTests;
+ PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.codeEditor.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/code_editor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/code_editor";
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
index a2ec33f..96d3fee 100644
--- a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -1,68 +1,68 @@
{
- "images" : [
- {
- "size" : "16x16",
- "idiom" : "mac",
- "filename" : "app_icon_16.png",
- "scale" : "1x"
+ "info": {
+ "version": 1,
+ "author": "xcode"
},
- {
- "size" : "16x16",
- "idiom" : "mac",
- "filename" : "app_icon_32.png",
- "scale" : "2x"
- },
- {
- "size" : "32x32",
- "idiom" : "mac",
- "filename" : "app_icon_32.png",
- "scale" : "1x"
- },
- {
- "size" : "32x32",
- "idiom" : "mac",
- "filename" : "app_icon_64.png",
- "scale" : "2x"
- },
- {
- "size" : "128x128",
- "idiom" : "mac",
- "filename" : "app_icon_128.png",
- "scale" : "1x"
- },
- {
- "size" : "128x128",
- "idiom" : "mac",
- "filename" : "app_icon_256.png",
- "scale" : "2x"
- },
- {
- "size" : "256x256",
- "idiom" : "mac",
- "filename" : "app_icon_256.png",
- "scale" : "1x"
- },
- {
- "size" : "256x256",
- "idiom" : "mac",
- "filename" : "app_icon_512.png",
- "scale" : "2x"
- },
- {
- "size" : "512x512",
- "idiom" : "mac",
- "filename" : "app_icon_512.png",
- "scale" : "1x"
- },
- {
- "size" : "512x512",
- "idiom" : "mac",
- "filename" : "app_icon_1024.png",
- "scale" : "2x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-}
+ "images": [
+ {
+ "size": "16x16",
+ "idiom": "mac",
+ "filename": "app_icon_16.png",
+ "scale": "1x"
+ },
+ {
+ "size": "16x16",
+ "idiom": "mac",
+ "filename": "app_icon_32.png",
+ "scale": "2x"
+ },
+ {
+ "size": "32x32",
+ "idiom": "mac",
+ "filename": "app_icon_32.png",
+ "scale": "1x"
+ },
+ {
+ "size": "32x32",
+ "idiom": "mac",
+ "filename": "app_icon_64.png",
+ "scale": "2x"
+ },
+ {
+ "size": "128x128",
+ "idiom": "mac",
+ "filename": "app_icon_128.png",
+ "scale": "1x"
+ },
+ {
+ "size": "128x128",
+ "idiom": "mac",
+ "filename": "app_icon_256.png",
+ "scale": "2x"
+ },
+ {
+ "size": "256x256",
+ "idiom": "mac",
+ "filename": "app_icon_256.png",
+ "scale": "1x"
+ },
+ {
+ "size": "256x256",
+ "idiom": "mac",
+ "filename": "app_icon_512.png",
+ "scale": "2x"
+ },
+ {
+ "size": "512x512",
+ "idiom": "mac",
+ "filename": "app_icon_512.png",
+ "scale": "1x"
+ },
+ {
+ "size": "512x512",
+ "idiom": "mac",
+ "filename": "app_icon_1024.png",
+ "scale": "2x"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
index 82b6f9d..3f22069 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
index 13b35eb..6e40844 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
index 0a3f5fa..8c30752 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
index bdb5722..9bd6a60 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
index f083318..d8f48fd 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
index 326c0e7..8814264 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ
diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
index 2f1632c..562e3e4 100644
Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ
diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig
index 2db161c..b5b4f85 100644
--- a/macos/Runner/Configs/AppInfo.xcconfig
+++ b/macos/Runner/Configs/AppInfo.xcconfig
@@ -5,10 +5,10 @@
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
-PRODUCT_NAME = code_editor
+PRODUCT_NAME = LN 代码编辑器
// The application's bundle identifier
-PRODUCT_BUNDLE_IDENTIFIER = com.example.codeEditor
+PRODUCT_BUNDLE_IDENTIFIER = com.lzxnone.code_editor
// The copyright displayed in application information
-PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved.
+PRODUCT_COPYRIGHT = Copyright © 2026 com.lzxnone. All rights reserved.
diff --git a/pubspec.lock b/pubspec.lock
index e2a96cc..f086d43 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -41,6 +41,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
+ checked_yaml:
+ dependency: transitive
+ description:
+ name: checked_yaml
+ sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.4"
+ cli_util:
+ dependency: transitive
+ description:
+ name: cli_util
+ sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.4.2"
clock:
dependency: transitive
description:
@@ -142,6 +158,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ flutter_launcher_icons:
+ dependency: "direct dev"
+ description:
+ name: flutter_launcher_icons
+ sha256: "10f13781741a2e3972126fae08393d3c4e01fa4cd7473326b94b72cf594195e7"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.14.4"
flutter_lints:
dependency: "direct dev"
description:
@@ -189,6 +213,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.0"
+ image:
+ dependency: transitive
+ description:
+ name: image
+ sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.3.0"
intl:
dependency: "direct main"
description:
@@ -237,6 +269,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
+ json_annotation:
+ dependency: transitive
+ description:
+ name: json_annotation
+ sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.12.0"
leak_tracker:
dependency: transitive
description:
@@ -429,6 +469,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.2"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.2"
platform:
dependency: transitive
description:
@@ -713,6 +761,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.6.1"
xterm:
dependency: "direct main"
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 53c91d1..e5cede2 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,75 +1,94 @@
-name: code_editor
-description: "A new Flutter project."
-publish_to: 'none'
-
-version: 1.0.0+1
-
-environment:
- sdk: ^3.9.2
-
-dependencies:
- flutter:
- sdk: flutter
-
- flutter_localizations:
- sdk: flutter
-
- intl: any
-
- cupertino_icons: ^1.0.8
- shared_preferences: ^2.3.0
- path: ^1.9.0
- file_picker: ^8.1.7
- provider: ^6.1.2
- re_editor:
- path: packages/re_editor
- re_highlight: ^0.0.3
- permission_handler: ^13.0.2
- path_provider: ^2.1.5
- archive: ^3.6.1
- # 内置副本:上游 4.0.0 的 IndexAwareCircularBuffer.trimStart() 会破坏行索引不变式,
- # 导致 shell 的 clear / Ctrl+L(ESC[3J)之后终端框选失效。补丁说明见 packages/xterm/PATCHES.md
- xterm:
- path: packages/xterm
- flutter_pty: ^0.4.1
- url_launcher: ^6.3.2
-
-dev_dependencies:
- flutter_test:
- sdk: flutter
-
- flutter_lints: ^6.0.0
-
-flutter:
-
- generate: true
-
- uses-material-design: true
-
- assets:
- - assets/distros/
- - assets/certs/
- - assets/gradle/
- - assets/shims/x86_64/
- - assets/shims/arm64-v8a/
- - assets/icons/distros/
-
- fonts:
- - family: JetBrains Mono
- fonts:
- - asset: assets/fonts/JetBrainsMonoNerdFontMono-Regular.ttf
- - asset: assets/fonts/JetBrainsMonoNerdFontMono-Italic.ttf
- style: italic
- - asset: assets/fonts/JetBrainsMonoNerdFontMono-Bold.ttf
- weight: 700
- - asset: assets/fonts/JetBrainsMonoNerdFontMono-BoldItalic.ttf
- weight: 700
- style: italic
-
- - family: Fira Code
- fonts:
- - asset: assets/fonts/FiraCodeNerdFontMono-Regular.ttf
- - asset: assets/fonts/FiraCodeNerdFontMono-Medium.ttf
- weight: 500
- - asset: assets/fonts/FiraCodeNerdFontMono-Bold.ttf
- weight: 700
\ No newline at end of file
+name: code_editor
+description: "A new Flutter project."
+publish_to: 'none'
+
+version: 1.0.0+1
+
+environment:
+ sdk: ^3.9.2
+
+dependencies:
+ flutter:
+ sdk: flutter
+
+ flutter_localizations:
+ sdk: flutter
+
+ intl: any
+
+ cupertino_icons: ^1.0.8
+ shared_preferences: ^2.3.0
+ path: ^1.9.0
+ file_picker: ^8.1.7
+ provider: ^6.1.2
+ re_editor:
+ path: packages/re_editor
+ re_highlight: ^0.0.3
+ permission_handler: ^13.0.2
+ path_provider: ^2.1.5
+ archive: ^3.6.1
+ # 内置副本:上游 4.0.0 的 IndexAwareCircularBuffer.trimStart() 会破坏行索引不变式,
+ # 导致 shell 的 clear / Ctrl+L(ESC[3J)之后终端框选失效。补丁说明见 packages/xterm/PATCHES.md
+ xterm:
+ path: packages/xterm
+ flutter_pty: ^0.4.1
+ url_launcher: ^6.3.2
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+
+ flutter_lints: ^6.0.0
+ flutter_launcher_icons: ^0.14.3
+
+flutter:
+
+ generate: true
+
+ uses-material-design: true
+
+ assets:
+ - assets/distros/
+ - assets/certs/
+ - assets/gradle/
+ - assets/shims/x86_64/
+ - assets/shims/arm64-v8a/
+ - assets/icons/distros/
+
+ fonts:
+ - family: JetBrains Mono
+ fonts:
+ - asset: assets/fonts/JetBrainsMonoNerdFontMono-Regular.ttf
+ - asset: assets/fonts/JetBrainsMonoNerdFontMono-Italic.ttf
+ style: italic
+ - asset: assets/fonts/JetBrainsMonoNerdFontMono-Bold.ttf
+ weight: 700
+ - asset: assets/fonts/JetBrainsMonoNerdFontMono-BoldItalic.ttf
+ weight: 700
+ style: italic
+
+ - family: Fira Code
+ fonts:
+ - asset: assets/fonts/FiraCodeNerdFontMono-Regular.ttf
+ - asset: assets/fonts/FiraCodeNerdFontMono-Medium.ttf
+ weight: 500
+ - asset: assets/fonts/FiraCodeNerdFontMono-Bold.ttf
+ weight: 700
+
+flutter_launcher_icons:
+ android: "launcher_icon"
+ ios: true
+ image_path: "assets/icon/app_icon.png"
+ min_sdk_android: 21
+ adaptive_icon_background: "#121214"
+ adaptive_icon_foreground: "assets/icon/app_icon_foreground.png"
+ web:
+ generate: true
+ image_path: "assets/icon/app_icon.png"
+ windows:
+ generate: true
+ image_path: "assets/icon/app_icon.png"
+ icon_size: 48
+ macos:
+ generate: true
+ image_path: "assets/icon/app_icon.png"
\ No newline at end of file
diff --git a/test/code_completion_management_view_test.dart b/test/code_completion_management_view_test.dart
new file mode 100644
index 0000000..b0d2013
--- /dev/null
+++ b/test/code_completion_management_view_test.dart
@@ -0,0 +1,124 @@
+import 'package:code_editor/l10n/app_localizations.dart';
+import 'package:code_editor/providers/settings_provider.dart';
+import 'package:code_editor/views/code_completion_management_view.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:provider/provider.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ late SettingsProvider settingsProvider;
+
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ settingsProvider = SettingsProvider();
+ await settingsProvider.init();
+ });
+
+ Widget buildTestWidget({Locale locale = const Locale('zh')}) {
+ return ChangeNotifierProvider.value(
+ value: settingsProvider,
+ child: MaterialApp(
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: AppLocalizations.supportedLocales,
+ locale: locale,
+ home: const CodeCompletionManagementView(),
+ ),
+ );
+ }
+
+ testWidgets('代码补全管理页面展示总开关与两个分开关,且支持中文多语言', (tester) async {
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ // 1. 验证总开关
+ final masterSwitch = find.byKey(const ValueKey('lsp_master_switch'));
+ expect(masterSwitch, findsOneWidget);
+ expect(find.text('后端语言服务补全'), findsOneWidget);
+
+ // 2. 验证分开关 1:代码补全
+ final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
+ expect(completionSwitch, findsOneWidget);
+ expect(find.text('代码补全'), findsOneWidget);
+ expect(find.text('输入时实时提示函数、变量与语法补全'), findsOneWidget);
+
+ // 3. 验证分开关 2:代码纠错
+ final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
+ expect(diagnosticsSwitch, findsOneWidget);
+ expect(find.text('代码纠错'), findsOneWidget);
+ expect(find.text('实时语法检查、错误波浪线提示与修复建议'), findsOneWidget);
+
+ // 4. 默认总开关开启时,两个分开关均为启用状态 (onChanged != null)
+ final completionTile = tester.widget(completionSwitch);
+ final diagnosticsTile = tester.widget(diagnosticsSwitch);
+ expect(completionTile.onChanged, isNotNull);
+ expect(diagnosticsTile.onChanged, isNotNull);
+ expect(completionTile.value, isTrue);
+ expect(diagnosticsTile.value, isTrue);
+ });
+
+ testWidgets('代码补全管理页面支持英文多语言展示', (tester) async {
+ await tester.pumpWidget(buildTestWidget(locale: const Locale('en')));
+ await tester.pumpAndSettle();
+
+ expect(find.text('Backend Language Server'), findsOneWidget);
+ expect(find.text('Code Completion'), findsOneWidget);
+ expect(find.text('Code Correction'), findsOneWidget);
+ });
+
+ testWidgets('当总开关关闭时,两个分开关被禁用(onChanged == null)', (tester) async {
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ final masterSwitch = find.byKey(const ValueKey('lsp_master_switch'));
+ final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
+ final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
+
+ // 点击总开关以关闭
+ await tester.tap(masterSwitch);
+ await tester.pumpAndSettle();
+
+ expect(settingsProvider.enableLspCompletion, isFalse);
+
+ // 验证总开关关闭后,两个分开关的 onChanged 为 null (禁用状态)
+ final disabledCompletionTile = tester.widget(completionSwitch);
+ final disabledDiagnosticsTile = tester.widget(diagnosticsSwitch);
+ expect(disabledCompletionTile.onChanged, isNull);
+ expect(disabledDiagnosticsTile.onChanged, isNull);
+
+ // 点击分开关不会发生任何状态变更
+ await tester.tap(completionSwitch);
+ await tester.pumpAndSettle();
+ expect(settingsProvider.enableCodeCompletion, isTrue);
+
+ // 重新开启总开关后,两个分开关重新恢复启用
+ await tester.tap(masterSwitch);
+ await tester.pumpAndSettle();
+
+ expect(settingsProvider.enableLspCompletion, isTrue);
+ final reenabledCompletionTile = tester.widget(completionSwitch);
+ final reenabledDiagnosticsTile = tester.widget(diagnosticsSwitch);
+ expect(reenabledCompletionTile.onChanged, isNotNull);
+ expect(reenabledDiagnosticsTile.onChanged, isNotNull);
+ });
+
+ testWidgets('总开关开启时,点击两个分开关可正常独立切换各自状态', (tester) async {
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ final completionSwitch = find.byKey(const ValueKey('code_completion_sub_switch'));
+ final diagnosticsSwitch = find.byKey(const ValueKey('code_diagnostics_sub_switch'));
+
+ // 切换代码补全分开关
+ await tester.tap(completionSwitch);
+ await tester.pumpAndSettle();
+ expect(settingsProvider.enableCodeCompletion, isFalse);
+
+ // 切换代码纠错分开关
+ await tester.tap(diagnosticsSwitch);
+ await tester.pumpAndSettle();
+ expect(settingsProvider.enableCodeDiagnostics, isFalse);
+ });
+}
diff --git a/test/completion_pipeline_test.dart b/test/completion_pipeline_test.dart
index b2b72f1..11e53d1 100644
--- a/test/completion_pipeline_test.dart
+++ b/test/completion_pipeline_test.dart
@@ -167,6 +167,30 @@ void main() {
expect(restoredProvider.enableLspCompletion, isFalse);
});
+ test('SettingsProvider sub-switches (code completion & diagnostics) default to true and persist', () async {
+ final provider = SettingsProvider();
+ await provider.init();
+
+ expect(provider.enableCodeCompletion, isTrue);
+ expect(provider.enableCodeDiagnostics, isTrue);
+
+ await provider.setEnableCodeCompletion(false);
+ await provider.setEnableCodeDiagnostics(false);
+
+ expect(provider.enableCodeCompletion, isFalse);
+ expect(provider.enableCodeDiagnostics, isFalse);
+
+ final prefs = await SharedPreferences.getInstance();
+ expect(prefs.getBool('enable_code_completion'), isFalse);
+ expect(prefs.getBool('enable_code_diagnostics'), isFalse);
+
+ // 重新实例化验证从持久化中正确恢复
+ final restoredProvider = SettingsProvider();
+ await restoredProvider.init();
+ expect(restoredProvider.enableCodeCompletion, isFalse);
+ expect(restoredProvider.enableCodeDiagnostics, isFalse);
+ });
+
test('SmartCodeAutocompletePromptsBuilder provider filtering by flag', () {
// 1. 默认开启:仅 1 个 LspCompletionProvider
final builderDefault = SmartCodeAutocompletePromptsBuilder();
diff --git a/test/git_conflict_resolve_page_test.dart b/test/git_conflict_resolve_page_test.dart
new file mode 100644
index 0000000..c91e4e3
--- /dev/null
+++ b/test/git_conflict_resolve_page_test.dart
@@ -0,0 +1,248 @@
+import 'dart:io';
+
+import 'package:code_editor/l10n/app_localizations.dart';
+import 'package:code_editor/models/git_model.dart';
+import 'package:code_editor/providers/git_provider.dart';
+import 'package:code_editor/providers/settings_provider.dart';
+import 'package:code_editor/providers/tab_provider.dart';
+import 'package:code_editor/widgets/git/git_conflict_resolve_page.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:path/path.dart' as p;
+import 'package:provider/provider.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ late Directory tempDir;
+ late File conflictFile;
+ late GitProvider gitProvider;
+ late TabProvider tabProvider;
+ late SettingsProvider settingsProvider;
+
+ const conflictContent = 'first line\n'
+ '<<<<<<< HEAD\n'
+ 'current line 1\n'
+ 'current line 2\n'
+ '=======\n'
+ 'incoming line 1\n'
+ '>>>>>>> feature/test\n'
+ 'last line\n';
+
+ setUp(() {
+ tempDir = Directory.systemTemp.createTempSync('git_conflict_test_');
+ conflictFile = File(p.join(tempDir.path, 'conflict_sample.txt'));
+ conflictFile.writeAsStringSync(conflictContent);
+
+ gitProvider = GitProvider();
+ tabProvider = TabProvider();
+ settingsProvider = SettingsProvider();
+ });
+
+ tearDown(() {
+ try {
+ tempDir.deleteSync(recursive: true);
+ } catch (_) {}
+ });
+
+ Widget buildTestWidget() {
+ return MultiProvider(
+ providers: [
+ ChangeNotifierProvider.value(value: gitProvider),
+ ChangeNotifierProvider.value(value: tabProvider),
+ ChangeNotifierProvider.value(value: settingsProvider),
+ ],
+ child: MaterialApp(
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: AppLocalizations.supportedLocales,
+ locale: const Locale('zh'),
+ home: GitConflictResolvePage(
+ file: GitConflictedFile(
+ relativePath: 'conflict_sample.txt',
+ absolutePath: conflictFile.path,
+ type: GitConflictType.bothModified,
+ ),
+ gitProvider: gitProvider,
+ initialContent: conflictContent,
+ ),
+ ),
+ );
+ }
+
+ testWidgets('GitConflictResolvePage 成功渲染 VS Code 风格 CodeLens 与标头色带', (tester) async {
+ tester.view.physicalSize = const Size(1024, 800);
+ tester.view.devicePixelRatio = 1.0;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ // 1. 验证文件名与未解决徽标
+ expect(find.text('conflict_sample.txt'), findsOneWidget);
+ expect(find.text('1 未解决'), findsOneWidget);
+
+ // 2. 验证 CodeLens 按钮(紧凑模式下自适应短文案)
+ expect(find.text('当前'), findsOneWidget);
+ expect(find.text('传入'), findsOneWidget);
+ expect(find.text('双方'), findsOneWidget);
+ expect(find.text('对比'), findsOneWidget);
+
+ // 3. 验证标头带与分隔线
+ expect(find.textContaining('<<<<<<< HEAD'), findsOneWidget);
+ expect(find.text('======='), findsOneWidget);
+ expect(find.textContaining('>>>>>>> feature/test'), findsOneWidget);
+
+ // 4. 验证底部按钮
+ expect(find.byKey(const ValueKey('git_conflict_edit_manually')), findsOneWidget);
+ expect(find.byKey(const ValueKey('git_conflict_save_and_mark')), findsOneWidget);
+ });
+
+ testWidgets('点击「对比查看」能够弹出差异比对弹窗', (tester) async {
+ tester.view.physicalSize = const Size(1024, 800);
+ tester.view.devicePixelRatio = 1.0;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ // 点击对比查看
+ await tester.tap(find.text('对比'));
+ await tester.pumpAndSettle();
+
+ // 验证对比弹窗开启
+ expect(find.text('冲突对比 · 第 1 处'), findsOneWidget);
+ expect(find.textContaining('当前侧: HEAD'), findsOneWidget);
+ expect(find.textContaining('传入侧: feature/test'), findsOneWidget);
+ expect(find.text('取消'), findsOneWidget);
+
+ // 关闭弹窗
+ await tester.tap(find.text('取消'));
+ await tester.pumpAndSettle();
+ expect(find.text('冲突对比 · 第 1 处'), findsNothing);
+ });
+
+ testWidgets('点击「采用当前侧」正确替换该冲突块并更新状态为已解决', (tester) async {
+ tester.view.physicalSize = const Size(1024, 800);
+ tester.view.devicePixelRatio = 1.0;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ // 点击采用当前侧并在真实异步环境中等待文件写入与状态更新
+ await tester.runAsync(() async {
+ await tester.tap(find.text('当前'));
+ await Future.delayed(const Duration(milliseconds: 200));
+ });
+ await tester.pumpAndSettle();
+
+ // 验证冲突标记消除,状态变为已全部解决
+ expect(find.text('已全部解决'), findsOneWidget);
+ expect(find.text('冲突已解决 · 保存并提交'), findsOneWidget);
+
+ // 验证磁盘文件内容确实被写入
+ final updatedContent = conflictFile.readAsStringSync();
+ expect(updatedContent.contains('<<<<<<<'), isFalse);
+ expect(updatedContent.contains('current line 1'), isTrue);
+ expect(updatedContent.contains('incoming line 1'), isFalse);
+ });
+
+ testWidgets('当遇到嵌套/畸形冲突标记时,页面展示「标记异常」徽标与警示横幅,且绝不误显「已全部解决」', (tester) async {
+ const malformedContent = '''
+<<<<<<< HEAD
+<<<<<<< ours
+VERSION-A
+=======
+VERSION-B
+>>>>>>> theirs
+=======
+VERSION-C
+>>>>>>> 123456
+''';
+ final malformedFile = File(p.join(tempDir.path, 'nested.txt'))..writeAsStringSync(malformedContent);
+
+ await tester.pumpWidget(
+ MultiProvider(
+ providers: [
+ ChangeNotifierProvider.value(value: gitProvider),
+ ChangeNotifierProvider.value(value: tabProvider),
+ ChangeNotifierProvider.value(value: settingsProvider),
+ ],
+ child: MaterialApp(
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: AppLocalizations.supportedLocales,
+ locale: const Locale('zh'),
+ home: GitConflictResolvePage(
+ file: GitConflictedFile(
+ relativePath: 'nested.txt',
+ absolutePath: malformedFile.path,
+ type: GitConflictType.bothModified,
+ ),
+ gitProvider: gitProvider,
+ initialContent: malformedContent,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ // 1. 验证顶栏展示「标记异常」,绝不显示「已全部解决」
+ expect(find.text('标记异常'), findsOneWidget);
+ expect(find.text('已全部解决'), findsNothing);
+
+ // 2. 验证页面顶部悬浮警告横幅
+ expect(find.textContaining('检测到冲突标记嵌套或不完整'), findsOneWidget);
+
+ // 3. 底栏不可显示「冲突已解决 · 保存并提交」
+ expect(find.text('冲突已解决 · 保存并提交'), findsNothing);
+ });
+
+ testWidgets('极窄屏幕(如 240px 宽度)下 CodeLens 操作栏不会触发 RenderFlex 溢出,且支持水平拖动交互', (tester) async {
+ tester.view.physicalSize = const Size(240, 600);
+ tester.view.devicePixelRatio = 1.0;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ // 确认没有 RenderFlex overflow 异常
+ expect(tester.takeException(), isNull);
+
+ // 验证 CodeLens 容器中的 SingleChildScrollView
+ final horizontalScrollView = find.byWidgetPredicate(
+ (widget) => widget is SingleChildScrollView && widget.scrollDirection == Axis.horizontal,
+ );
+ expect(horizontalScrollView, findsWidgets);
+
+ // 进行水平拖动手势滑动
+ await tester.drag(horizontalScrollView.first, const Offset(-100, 0));
+ await tester.pumpAndSettle();
+
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('点击底栏「手动编辑」按钮能够正常触发并打开文件', (tester) async {
+ tester.view.physicalSize = const Size(1024, 800);
+ tester.view.devicePixelRatio = 1.0;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+
+ await tester.pumpWidget(buildTestWidget());
+ await tester.pumpAndSettle();
+
+ final editBtn = find.byKey(const ValueKey('git_conflict_edit_manually'));
+ expect(editBtn, findsOneWidget);
+
+ await tester.tap(editBtn);
+ await tester.pumpAndSettle();
+
+ expect(tester.takeException(), isNull);
+ });
+}
+
+
+
diff --git a/tools/build/build-shmem.ps1 b/tools/build/build-shmem.ps1
index 1d8e8ab..e255afc 100644
--- a/tools/build/build-shmem.ps1
+++ b/tools/build/build-shmem.ps1
@@ -51,7 +51,7 @@ if ((Test-Path $patch) -and -not (Select-String -Path (Join-Path $SrcDir "shmem.
# --- app id(决定 _PATH_TMP:命名 shm key 的 symlink 存放位置)-------------
if (-not $AppId) {
$m = Select-String -Path "android\app\build.gradle.kts" -Pattern 'applicationId\s*=\s*"([^"]+)"' | Select-Object -First 1
- $AppId = if ($m) { $m.Matches.Groups[1].Value } else { "com.example.code_editor" }
+ $AppId = if ($m) { $m.Matches.Groups[1].Value } else { "com.lzxnone.code_editor" }
}
$tmpDef = "-D_PATH_TMP=`"/data/data/$AppId/cache/`""
Write-Host "applicationId=$AppId _PATH_TMP=/data/data/$AppId/cache/" -ForegroundColor Cyan
diff --git a/tools/container-selfcheck/README.md b/tools/container-selfcheck/README.md
index acdef10..a784cfe 100644
--- a/tools/container-selfcheck/README.md
+++ b/tools/container-selfcheck/README.md
@@ -35,7 +35,7 @@ NDK=/toolchains/llvm/prebuilt//bin
前提:app 为 **debug** 构建(`run-as` 需要),设备已连 adb。
```bash
-PKG=com.example.code_editor
+PKG=com.lzxnone.code_editor
BASE=/data/data/$PKG/files/distros/alpine
R=$BASE/rootfs
diff --git a/tools/container-selfcheck/guest-run.sh b/tools/container-selfcheck/guest-run.sh
index 6afb086..3fa070e 100644
--- a/tools/container-selfcheck/guest-run.sh
+++ b/tools/container-selfcheck/guest-run.sh
@@ -3,7 +3,7 @@
# 注意:这条路径经 run-as 启动,**没有** Android 的 app seccomp 过滤器
#(容器里看到的 Seccomp:2 是 proot 自己的加速过滤器)。因此涉及
# poll/select 等平台策略的结论必须在 App 自己的会话里验证。
-PKG=com.example.code_editor
+PKG=com.lzxnone.code_editor
BASE=/data/data/$PKG/files/distros/alpine
ROOT=$BASE/rootfs
# 按设备 ABI 选择(arm64-v8a / x86_64),避免写死导致换架构失效
diff --git a/web/favicon.png b/web/favicon.png
index 8aaa46a..8c30752 100644
Binary files a/web/favicon.png and b/web/favicon.png differ
diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png
index b749bfe..8189718 100644
Binary files a/web/icons/Icon-192.png and b/web/icons/Icon-192.png differ
diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png
index 88cfd48..8814264 100644
Binary files a/web/icons/Icon-512.png and b/web/icons/Icon-512.png differ
diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png
index eb9b4d7..8189718 100644
Binary files a/web/icons/Icon-maskable-192.png and b/web/icons/Icon-maskable-192.png differ
diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png
index d69c566..8814264 100644
Binary files a/web/icons/Icon-maskable-512.png and b/web/icons/Icon-maskable-512.png differ
diff --git a/web/index.html b/web/index.html
index 1a8fc22..6bb8c29 100644
--- a/web/index.html
+++ b/web/index.html
@@ -23,13 +23,13 @@
-
+
- code_editor
+ LN 代码编辑器
diff --git a/web/manifest.json b/web/manifest.json
index 63f5459..d94c75a 100644
--- a/web/manifest.json
+++ b/web/manifest.json
@@ -1,6 +1,6 @@
{
- "name": "code_editor",
- "short_name": "code_editor",
+ "name": "LN 代码编辑器",
+ "short_name": "LN 代码编辑器",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
@@ -32,4 +32,4 @@
"purpose": "maskable"
}
]
-}
+}
\ No newline at end of file
diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico
index c04e20c..dbea918 100644
Binary files a/windows/runner/resources/app_icon.ico and b/windows/runner/resources/app_icon.ico differ