Skip to content

Commit 0d47ff9

Browse files
authored
优化微软登录扫描二维码界面布局 (#6767)
1 parent 4064c5c commit 0d47ff9

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/account/MicrosoftAccountLoginPane.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
import javafx.scene.Cursor;
3030
import javafx.scene.Group;
3131
import javafx.scene.control.Label;
32-
import javafx.scene.layout.FlowPane;
33-
import javafx.scene.layout.StackPane;
34-
import javafx.scene.layout.VBox;
32+
import javafx.scene.layout.*;
3533
import javafx.scene.shape.SVGPath;
3634
import org.jackhuang.hmcl.auth.Account;
3735
import org.jackhuang.hmcl.auth.AuthInfo;
@@ -141,20 +139,22 @@ private void onStep(Step currentStep) {
141139
setBody(rootContainer);
142140
rootContainer.setAlignment(Pos.TOP_CENTER);
143141

144-
if (Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) {
145-
var snapshotHint = new HintPane(MessageDialogPane.MessageType.WARNING);
142+
StackPane warningPane = new StackPane();
143+
144+
if (!IntegrityChecker.isOfficial()) {
145+
var unofficialHintPane = new HintPane(MessageDialogPane.MessageType.WARNING);
146+
unofficialHintPane.setSegment(i18n("unofficial.hint"));
147+
warningPane.getChildren().add(unofficialHintPane);
148+
} else if (Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) {
149+
HintPane snapshotHint = new HintPane(MessageDialogPane.MessageType.WARNING);
146150
snapshotHint.setSegment(i18n("account.methods.microsoft.snapshot"));
147-
rootContainer.getChildren().add(snapshotHint);
151+
warningPane.getChildren().add(snapshotHint);
148152
btnLogin.setDisable(true);
149153
loginButtonSpinner.setLoading(false);
150154
return;
151155
}
152156

153-
if (!IntegrityChecker.isOfficial()) {
154-
var unofficialHintPane = new HintPane(MessageDialogPane.MessageType.WARNING);
155-
unofficialHintPane.setSegment(i18n("unofficial.hint"));
156-
rootContainer.getChildren().add(unofficialHintPane);
157-
}
157+
rootContainer.getChildren().add(warningPane);
158158

159159
if (currentStep instanceof Step.Init) {
160160
btnLogin.setOnAction(e -> this.step.set(new Step.StartAuthorizationCodeLogin()));
@@ -198,6 +198,20 @@ private void onStep(Step currentStep) {
198198
} else if (currentStep instanceof Step.WaitForScanQrCode wait) {
199199
loginButtonSpinner.setLoading(true);
200200

201+
VBox leftVBox = new VBox(6);
202+
leftVBox.setAlignment(Pos.CENTER);
203+
VBox rightVBox = new VBox(6);
204+
205+
HBox hbox = new HBox(leftVBox, rightVBox);
206+
207+
leftVBox.prefWidthProperty().bind(hbox.widthProperty().divide(2));
208+
rightVBox.prefWidthProperty().bind(hbox.widthProperty().divide(2));
209+
leftVBox.setMaxWidth(Double.MAX_VALUE);
210+
rightVBox.setMaxWidth(Double.MAX_VALUE);
211+
212+
HBox.setHgrow(leftVBox, Priority.ALWAYS);
213+
HBox.setHgrow(rightVBox, Priority.ALWAYS);
214+
201215
String scanUri = "https://www.microsoft.com/link".equals(wait.verificationUri())
202216
? "https://www.microsoft.com/link?otc=" + wait.userCode()
203217
: wait.verificationUri();
@@ -225,7 +239,10 @@ private void onStep(Step currentStep) {
225239
FXUtils.onClicked(codeBox, () -> FXUtils.copyText(wait.userCode()));
226240
codeBox.setMaxWidth(USE_PREF_SIZE);
227241

228-
rootContainer.getChildren().addAll(deviceHint, new Group(qrCode), codeBox);
242+
leftVBox.getChildren().setAll(new Group(qrCode), codeBox);
243+
rightVBox.getChildren().setAll(warningPane, deviceHint);
244+
245+
rootContainer.getChildren().setAll(hbox);
229246
} else if (currentStep instanceof Step.DeviceLoginCompleted) {
230247
loginButtonSpinner.setLoading(true);
231248

0 commit comments

Comments
 (0)