-
-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2478 from proneon267/iOS_divider
Implemented Divider widget on iOS
- Loading branch information
Showing
8 changed files
with
56 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Divider widget was implemented on iOS. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
from travertino.size import at_least | ||
|
||
from toga_iOS.libs import UIColor, UIView | ||
from toga_iOS.widgets.base import Widget | ||
|
||
|
||
class Divider(Widget): | ||
def create(self): | ||
self.native = UIView.alloc().init() | ||
self.native.interface = self.interface | ||
self.native.impl = self | ||
|
||
# Background color needs to be set or else divider will not be visible. | ||
self.system_gray_color = UIColor.systemGrayColor() | ||
self.native.backgroundColor = self.system_gray_color | ||
|
||
# Add the layout constraints | ||
self.add_constraints() | ||
|
||
# Set the initial direction | ||
self._direction = self.interface.HORIZONTAL | ||
|
||
def set_background_color(self, value): | ||
# Do nothing, since background color of Divider shouldn't be changed. | ||
pass | ||
|
||
def rehint(self): | ||
content_size = self.native.intrinsicContentSize() | ||
|
||
if self._direction == self.interface.VERTICAL: | ||
self.interface.intrinsic.width = 1 | ||
self.interface.intrinsic.height = at_least(content_size.height) | ||
else: | ||
self.interface.intrinsic.width = at_least(content_size.width) | ||
self.interface.intrinsic.height = 1 | ||
|
||
def get_direction(self): | ||
return self._direction | ||
|
||
def set_direction(self, value): | ||
self._direction = value |
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,7 @@ | ||
from toga_iOS.libs import UIView | ||
|
||
from .base import SimpleProbe | ||
|
||
|
||
class DividerProbe(SimpleProbe): | ||
native_class = UIView |
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