-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ViewModel for FindBridge #26
Conversation
@@ -48,8 +52,25 @@ class UndirectedViewModel( | |||
set(value) { | |||
_ranked.value = value | |||
ranks = PageRank(graph).computePageRank(3) | |||
println("хуй") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
все круто, но это убери))))))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все убрал, в следующий раз постараюсь быть аккуратней :)
src/main/kotlin/view/MainView.kt
Outdated
if(image == "FindBridge.svg"){ | ||
onClick() | ||
} | ||
}, viewModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так как по умолчанию у нас пустная функция {}
, полагаю, можно сделать просто вот так:
if(image == "FindBridge.svg"){ | |
onClick() | |
} | |
}, viewModel | |
ImageButton(imageResourceId = image, onClick = onClick, viewModel) |
src/main/kotlin/view/MainView.kt
Outdated
if (imageResourceId == "FindBridge.svg") { | ||
Image( | ||
painter = painterResource(imageResourceId), | ||
contentDescription = "Button Image", | ||
modifier = Modifier.glowRec(viewModel.isFinded).size(445.dp, 59.dp).onClick(onClick = onClick), | ||
contentScale = ContentScale.Crop | ||
) | ||
} | ||
else { | ||
Image( | ||
painter = painterResource(imageResourceId), | ||
contentDescription = "Button Image", | ||
modifier = Modifier.alpha(0.2f).size(445.dp, 59.dp).onClick(onClick = onClick), | ||
contentScale = ContentScale.Crop | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь отличается только модификатор, поэтому давай менять только его
src/main/kotlin/view/MainView.kt
Outdated
if (imageResourceId == "FindBridge.svg") { | ||
Image( | ||
painter = painterResource(imageResourceId), | ||
contentDescription = "Button Image", | ||
modifier = Modifier.glowRec(viewModel.isFinded).size(445.dp, 59.dp).onClick(onClick = onClick), | ||
contentScale = ContentScale.Crop | ||
) | ||
} | ||
else { | ||
Image( | ||
painter = painterResource(imageResourceId), | ||
contentDescription = "Button Image", | ||
modifier = Modifier.alpha(0.2f).size(445.dp, 59.dp).onClick(onClick = onClick), | ||
contentScale = ContentScale.Crop | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь отличается только модификатор, поэтому давай менять только его
if (imageResourceId == "FindBridge.svg") { | |
Image( | |
painter = painterResource(imageResourceId), | |
contentDescription = "Button Image", | |
modifier = Modifier.glowRec(viewModel.isFinded).size(445.dp, 59.dp).onClick(onClick = onClick), | |
contentScale = ContentScale.Crop | |
) | |
} | |
else { | |
Image( | |
painter = painterResource(imageResourceId), | |
contentDescription = "Button Image", | |
modifier = Modifier.alpha(0.2f).size(445.dp, 59.dp).onClick(onClick = onClick), | |
contentScale = ContentScale.Crop | |
) | |
} | |
val modifier = when (imageResourceId) { | |
"FindBridge.svg" -> Modifier.glowRec(viewModel.isFinded) | |
else -> Modifier.alpha(0.2f) | |
} | |
Image( | |
painter = painterResource(imageResourceId), | |
contentDescription = "Button Image", | |
modifier = modifier.size(445.dp, 59.dp).onClick(onClick = onClick), | |
contentScale = ContentScale.Crop | |
) |
src/main/kotlin/view/MainView.kt
Outdated
DisplayAlgorithmMenu("DownMenuAlgorithm.svg", | ||
mainViewModel.menuViewModel | ||
){ isBridgeFinded = !isBridgeFinded } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а почему функция onClick передается в весь DisplayAlgorithmMenu и является только функцией для алгоритма нахождения мостов?)
А как мне добавить свой обработчик?
Ну это ладно, сегодня придумаем как сделать универсальный
Как по мне должен быть список кнопок в меню, в котором также находится обработчик для каждой кнопки
_bridgeFinded.value = value | ||
bridges = FindBridges(graph).findBridges() | ||
bridges.forEach { | ||
BridgesWthColor.add(it to Color.Red) | ||
} | ||
if (bridgeFinded) { | ||
changeEdgesColor(BridgesWthColor) | ||
} | ||
else{ | ||
resetEdgesColorToDefault() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Включи в настройках "Format on save", либо почаще нажимай Ctrl + Shiift + L (форматирование)
_bridgeFinded.value = value | |
bridges = FindBridges(graph).findBridges() | |
bridges.forEach { | |
BridgesWthColor.add(it to Color.Red) | |
} | |
if (bridgeFinded) { | |
changeEdgesColor(BridgesWthColor) | |
} | |
else{ | |
resetEdgesColorToDefault() | |
} | |
_bridgeFinded.value = value | |
bridges = FindBridges(graph).findBridges() | |
bridges.forEach { | |
BridgesWthColor.add(it to Color.Red) | |
} | |
if (bridgeFinded) { | |
changeEdgesColor(BridgesWthColor) | |
} else { | |
resetEdgesColorToDefault() | |
} |
… button and the algorithm
I linked the bridges algorithm to the button