This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f876fa
commit bd2687b
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
**STRUCT** | ||
|
||
# `ProgressBar` | ||
|
||
A progress bar widget. | ||
|
||
## Properties | ||
### `value` | ||
|
||
The value. | ||
|
||
## Methods | ||
### `init(value:total:)` | ||
|
||
Initialize a progress bar widget. | ||
- Parameters: | ||
- value: The value. | ||
- total: The maximum value. | ||
|
||
### `update(_:modifiers:)` | ||
|
||
Update the view storage of the progress bar widget. | ||
- Parameters: | ||
- storage: The view storage. | ||
- modifiers: Modify views before being updated. | ||
|
||
### `container(modifiers:)` | ||
|
||
Get the container of the progress bar widget. | ||
- Returns: The view storage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Progressbar.swift | ||
// Adwaita | ||
// | ||
// Created by david-swift on 03.01.24. | ||
// | ||
|
||
import Libadwaita | ||
|
||
/// A progress bar widget. | ||
public struct ProgressBar: Widget { | ||
|
||
/// The value. | ||
var value: Double | ||
|
||
/// Initialize a progress bar widget. | ||
/// - Parameters: | ||
/// - value: The value. | ||
/// - total: The maximum value. | ||
public init(value: Double, total: Double) { | ||
if total != 0 { | ||
self.value = value / total | ||
} else { | ||
self.value = 0 | ||
} | ||
} | ||
|
||
/// Update the view storage of the progress bar widget. | ||
/// - Parameters: | ||
/// - storage: The view storage. | ||
/// - modifiers: Modify views before being updated. | ||
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { | ||
if let bar = storage.view as? Libadwaita.ProgressBar { | ||
_ = bar.fraction(value) | ||
} | ||
} | ||
|
||
/// Get the container of the progress bar widget. | ||
/// - Returns: The view storage. | ||
public func container(modifiers: [(View) -> View]) -> ViewStorage { | ||
let bar = Libadwaita.ProgressBar().fraction(value) | ||
_ = bar.sensitive(false) | ||
return .init(bar) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters