{"id":23413685,"url":"https://github.com/http-rpc/lima","last_synced_at":"2025-04-05T02:10:17.503Z","repository":{"id":41384868,"uuid":"155084105","full_name":"HTTP-RPC/Lima","owner":"HTTP-RPC","description":"Declarative UI for iOS","archived":false,"fork":false,"pushed_at":"2025-02-19T16:09:02.000Z","size":9123,"stargazers_count":174,"open_issues_count":0,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T01:13:02.241Z","etag":null,"topics":["auto-layout","declarative-ui","dsl","swift","uikit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HTTP-RPC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-28T15:11:19.000Z","updated_at":"2025-02-19T15:38:46.000Z","dependencies_parsed_at":"2025-02-24T16:23:15.664Z","dependency_job_id":null,"html_url":"https://github.com/HTTP-RPC/Lima","commit_stats":null,"previous_names":["gk-brown/lima"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTTP-RPC%2FLima","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTTP-RPC%2FLima/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTTP-RPC%2FLima/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTTP-RPC%2FLima/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HTTP-RPC","download_url":"https://codeload.github.com/HTTP-RPC/Lima/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-layout","declarative-ui","dsl","swift","uikit"],"created_at":"2024-12-22T19:54:07.068Z","updated_at":"2025-04-05T02:10:17.487Z","avatar_url":"https://github.com/HTTP-RPC.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Releases](https://img.shields.io/github/release/HTTP-RPC/Lima.svg)](https://github.com/HTTP-RPC/Lima/releases)\n\n# Introduction\nLima is a Swift package for simplifying development of UIKit-based iOS applications. The project's name comes from the nautical _L_ or _Lima_ flag, representing the first letter of the word \"layout\":\n\n![](lima.png)\n\nFor example, the following code creates an instance of Lima's `LMColumnView` class containing an image view and a label:\n\n```swift\nlet columnView = LMColumnView(\n    UIImageView(image: UIImage(named: \"world.png\"), contentMode: .scaleAspectFit),\n    UILabel(text: \"Hello, World!\", textAlignment: .center)\n)\n```\n\nThe result is shown below:\n\n\u003cimg src=\"README/hello-world.png\" width=\"250px\"/\u003e\n\nThe complete source code for this example can be found [here](LimaTest/GreetingViewController.swift).\n\nLima requires iOS 16 or later.\n\n# Lima Classes\nAuto layout in UIKit is implemented via layout constraints, which, while powerful, are not particularly convenient to work with. To simplify the process, Lima provides a set of view classes whose sole responsibility is managing the size and position of their respective subviews. These classes use layout constraints internally, allowing developers to easily take advantage of auto layout while eliminating the need to manage constraints directly:\n\n* `LMRowView` - arranges subviews in a horizontal line, optionally aligning to baseline\n* `LMColumnView` - arranges subviews in a vertical line, optionally aligning nested elements to a grid\n* `LMAnchorView` - anchors subviews to one or more edges\n\nAdditionally, the `LMSpacer` class can be used to create fixed or flexible space between other views.\n\nLima adds the following properties to `UIView` to control how subviews are sized and positioned by a layout view:\n\n* `width` - assigns a fixed width to a view\n* `height` - assigns a fixed height to a view\n* `weight` - when used with row and column views, determines how excess space is allocated within the parent\n* `anchor` - when used with anchor views, determines the edges to which the view will be anchored within the parent\n\nLima also provides the following classes to simplify the use of some common UIKit types:\n \n* `LMScrollView` - extends `UIScrollView` to automatically adapt to content size\n* `LMTableViewCell` - extends `UITableViewCell` to automatically pin content to edges\n* `LMTableViewHeaderFooterView` - extends `UITableViewHeaderFooterView` to automatically pin content to edges\n\nFinally, Lima adds initializers to common UIKit views and controls to simplify their declaration in a view hieararchy. These initializers support callbacks that can be used to further customize the instantiated views and are discussed in more detail [later](#initializer-callbacks).\n\n## LMRowView and LMColumnView\nThe `LMRowView` and `LMColumnView` classes arrange subviews in a horizontal or vertical line, respectively. Both classes extend the abstract `LMBoxView` class, which defines the following properties:\n\n* `horizontalAlignment`\n* `verticalAlignment`\n* `spacing`\n\nHorizontal alignment options include `fill`, `leading`, `trailing`, and `center`. Vertical alignment options include `fill`, `top`, `bottom`, and `center`. Both values are set to `fill` by default, which pins subviews along both axes. Other values pin subviews to a single edge or center them along a given axis:\n\n\u003cimg src=\"README/horizontal-alignment.png\" width=\"250px\"/\u003e\n\u003cbr/\u003e\n\u003cimg src=\"README/vertical-alignment.png\" width=\"542px\"/\u003e\n\nThe `spacing` property defines the amount of space reserved between subviews. For row views, this refers to the horizontal space between the subviews; for column views, it refers to the vertical space. If unspecified, a default (system-dependent) value is used.\n\n### Baseline Alignment\nThe `isAlignToBaseline` property enables baseline alignment in a row view. When this property is set to `true`, subviews are aligned to their respective baselines. For [example](LimaTest/BaselineAlignmentViewController.swift):\n\n\u003cimg src=\"README/baseline-alignment.png\" width=\"250px\"/\u003e\n\n### Grid Alignment\nThe `isAlignToGrid` property enables grid alignment in a column view. When this property is set to `true`, the subviews of every `LMRowView` in the column are vertically aligned in a grid, as in a spreadsheet or HTML table. For [example](LimaTest/GridAlignmentViewController.swift):\n\n\u003cimg src=\"README/grid-alignment.png\" width=\"250px\"/\u003e\n\n### View Weights\nOften, a row or column view will be given more space than it needs to accommodate the intrinsic sizes of its subviews. The `weight` property can be used to specify the amount of excess space that should be allocated to a subview, relative to other weighted subviews. For row views, weights apply to the excess horizontal space, and for column views to the excess vertical space.\n\nNote that explicitly defined width and height values take priority over weights. If a view has both a weight and a fixed dimension, the weight value will be ignored.\n \n## LMAnchorView\nThe `LMAnchorView` class optionally anchors subviews to one or more of its own edges. Anchors are specified as an option set that defines the edges to which the view will be anchored within the parent. For [example](LimaTest/AnchorViewController.swift): \n\n\u003cimg src=\"README/anchor-view.png\" width=\"542px\"/\u003e\n\nIf no anchor is specified for a given dimension, the subview will be centered within the parent for that dimension.\n\n## LMSpacer\nThe `LMSpacer` class has a default weight of 1 and is typically used to create flexible space between other views. However, the `width` and `height` properties can be used to assign a fixed size to a spacer view. For example, this code creates a half-pixel wide spacer with a gray background:\n\n```swift\nLMSpacer(width: 0.5, backgroundColor: .gray)\n```\n\n## LMScrollView\nThe `LMScrollView` class extends `UIScrollView` to simplify the declaration of scrollable content. The following properties determine how the content will be presented:\n\n* `isFitToWidth`\n* `isFitToHeight` \n\nWhen both values are `false` (the default), the scroll view will automatically display scroll bars when needed, allowing the user to pan in both directions to see the content in its entirety. \n\nWhen `fitToWidth` is `true`, the scroll view will ensure that the width of its content matches the width of its adjusted content area, causing the content to wrap and scroll in the vertical direction only. The vertical scroll bar will appear when necessary, and the horizontal scroll bar will never be shown.\n\nWhen `fitToHeight` is `true`, the scroll view will ensure that the height of its content matches the height of its adjusted content area, causing the content to wrap and scroll in the horizontal direction only. The horizontal scroll bar will appear when necessary, and the vertical scroll bar will never be shown.\n\nSetting both properties to `true` produces the same behavior as anchoring a subview to all sides of an `LMAnchorView`.\n\n## LMTableViewCell and LMTableViewHeaderFooterView\nThe `LMTableViewCell` and `LMTableViewHeaderFooterView` classes facilitate the declaration of custom table view content. For [example](LimaTest/ControlsViewController.swift):\n\n\u003cimg src=\"README/controls.png\" width=\"250px\"/\u003e\n\nThey can also be used as the base class for custom cell and header/footer view classes. For [example](LimaTest/TableViewCellController.swift):\n\n\u003cimg src=\"README/table-view-cell.png\" width=\"250px\"/\u003e\n\n# Initializer Callbacks\nAll Lima initializers provide a callback parameter that can be used to further customize the instantiated view. This callback is automatically invoked by the initializer before it returns.\n\nA common use of initializer callbacks is to associate view instances with controller member variables, or \"outlets\". For [example](LimaTest/ActionViewController.swift):\n\n\u003cimg src=\"README/action.png\" width=\"250px\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-rpc%2Flima","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttp-rpc%2Flima","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-rpc%2Flima/lists"}