Skip to content
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

Merged
merged 5 commits into from
Sep 24, 2024
Merged

Add ViewModel for FindBridge #26

merged 5 commits into from
Sep 24, 2024

Conversation

Demon32123
Copy link
Contributor

I linked the bridges algorithm to the button

@@ -48,8 +52,25 @@ class UndirectedViewModel(
set(value) {
_ranked.value = value
ranks = PageRank(graph).computePageRank(3)
println("хуй")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все круто, но это убери))))))))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все убрал, в следующий раз постараюсь быть аккуратней :)

Comment on lines 57 to 60
if(image == "FindBridge.svg"){
onClick()
}
}, viewModel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так как по умолчанию у нас пустная функция {}, полагаю, можно сделать просто вот так:

Suggested change
if(image == "FindBridge.svg"){
onClick()
}
}, viewModel
ImageButton(imageResourceId = image, onClick = onClick, viewModel)

Comment on lines 76 to 91
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
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь отличается только модификатор, поэтому давай менять только его

Comment on lines 76 to 91
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
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь отличается только модификатор, поэтому давай менять только его

Suggested change
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
)

Comment on lines 110 to 112
DisplayAlgorithmMenu("DownMenuAlgorithm.svg",
mainViewModel.menuViewModel
){ isBridgeFinded = !isBridgeFinded }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему функция onClick передается в весь DisplayAlgorithmMenu и является только функцией для алгоритма нахождения мостов?)

А как мне добавить свой обработчик?
Ну это ладно, сегодня придумаем как сделать универсальный

Как по мне должен быть список кнопок в меню, в котором также находится обработчик для каждой кнопки

Comment on lines +62 to +72
_bridgeFinded.value = value
bridges = FindBridges(graph).findBridges()
bridges.forEach {
BridgesWthColor.add(it to Color.Red)
}
if (bridgeFinded) {
changeEdgesColor(BridgesWthColor)
}
else{
resetEdgesColorToDefault()
}
Copy link
Contributor

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 (форматирование)

Suggested change
_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()
}

@homka122 homka122 self-requested a review September 24, 2024 09:50
@Demon32123 Demon32123 merged commit a121e05 into dev Sep 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants