profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/GeorgeElsham/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
George GeorgeElsham @AppUnwrapped Berkshire, UK appunwrapped.com Developing iOS apps.

GeorgeElsham/HidingViews 26

Custom ViewModifier: `.isHidden(_:)` - Easily hide Views, controlled by a boolean. https://stackoverflow.com/a/59228385/9607863

GeorgeElsham/ViewExtractor 18

Extract SwiftUI views from ViewBuilder content.

GeorgeElsham/BookshelvesExample 4

https://stackoverflow.com/a/59919052/9607863

GeorgeElsham/ShoppingListSwiftUIExample 4

Simple example app for using @EnvironmentObject

GeorgeElsham/Random-function 1

Swift - Easily get random number, linear or exponentially

GeorgeElsham/SupermarketTycoon 1

OCR Computer Science A-level coursework project. Exam year: 2021

GeorgeElsham/Pyramid-Game 0

Pyramids fly in the air, tap them!

GeorgeElsham/TagExtractor 0

Extract tag value from SwiftUI views.

GeorgeElsham/TestingTextures 0

Adding textures to sprites test

issue commentsiteline/SwiftUI-Introspect

Consider introspecting UIContextMenuInteraction

Is there a method on UIContextMenuInteraction you can call to even do that? Unfortunately, if you can only detect that by overriding a method like didMove(to:), it's likely not possible.

mycroftcanner

comment created time in 14 days

issue commentsiteline/SwiftUI-Introspect

.introspectTextField not working on macOS

@pmmlo Works for me, Introspect version 0.1.3. Could be on my part trying to reproduce the issue?

pmmlo

comment created time in 14 days

fork GeorgeElsham/DylanMcD8

Public profile Read Me

fork in 2 months

create barnchGeorgeElsham/TagExtractor

branch : main

created branch time in 2 months

created repositoryGeorgeElsham/TagExtractor

created time in 2 months

issue closedGeorgeElsham/ViewExtractor

Can't update SPM to 1.1

I think this could be because the version is called 1.1, and not 1.1.0.

closed time in 2 months

JaydenIrwin

issue commentGeorgeElsham/ViewExtractor

Can't update SPM to 1.1

Didn't realise that would cause issues, sorry! Renamed it to 1.1.0 and can confirm it now works.

JaydenIrwin

comment created time in 2 months

created tagGeorgeElsham/ViewExtractor

tag1.1.0

Extract SwiftUI views from ViewBuilder content.

created time in 2 months

issue commentGeorgeElsham/ViewExtractor

if statement creates a view even if false

@JetForMe To be honest we shouldn't really be digging into the views - but in rare cases it can be useful, which is why I made this repo. Glad you find it useful!

JetForMe

comment created time in 2 months

release GeorgeElsham/ViewExtractor

1.1

released time in 2 months

created tagGeorgeElsham/ViewExtractor

tag1.1

Extract SwiftUI views from ViewBuilder content.

created time in 2 months

issue closedGeorgeElsham/ViewExtractor

if statement creates a view even if false

I'm using ViewExtractor to create a divided stack, much like your Readme example. The problem is, I have a stack with a conditional view:

if condition {
    VStack { ... }
}

If condition is false, ViewExtractor still gets a view in the views array, a complicated optional view:

▿ AnyView
  ▿ storage : <AnyViewStorage<Optional<VStack…(the rest of my view hierarchy)>>>

I don't know how to test if one of these is actually empty, so as to not draw the divider.

closed time in 2 months

JetForMe

issue commentGeorgeElsham/ViewExtractor

if statement creates a view even if false

Fixed in this commit. Thank you!

JetForMe

comment created time in 2 months

push eventGeorgeElsham/ViewExtractor

GeorgeElsham

commit sha 09cc1e7bf7d1860b92b151bb0bf06ec25a9e9162

Fixed issue with `nil` view not getting removed.

view details

push time in 2 months

push eventGeorgeElsham/ViewExtractor

George

commit sha c233227f9e1fc11f2d7c34109e2c54c8a34235c8

Feature - get view by index (#6) * Ran SwiftFormat for consistent formatting. * Added comments on how the code works. * Improved checking for `EmptyView` and `ForEach` content. * Implemented way to get a specific view, without loading everything.

view details

GeorgeElsham

commit sha 0f0f458243dcc302509d2507946cac102d978ee3

Merge branch 'feature/get_view_by_index'

view details

push time in 2 months

push eventGeorgeElsham/ViewExtractor

GeorgeElsham

commit sha 3cfc10f0be707ae9c592732b79eccddf80cb5baa

Ran SwiftFormat for consistent formatting.

view details

GeorgeElsham

commit sha 67415a0c865ec61292395dbbc6f0e322245eeea9

Added comments on how the code works.

view details

GeorgeElsham

commit sha fad46e36ad6ab6223078633b9c745f37d0dadd2a

Improved checking for `EmptyView` and `ForEach` content.

view details

GeorgeElsham

commit sha aa4b77c2b80f6b092c35a44307765cc627446446

Implemented way to get a specific view, without loading everything.

view details

George

commit sha c85ddbab25d11282239aac976b22041913cfb8c6

Gave example for lazy-loaded views.

view details

GeorgeElsham

commit sha 0f0f458243dcc302509d2507946cac102d978ee3

Merge branch 'feature/get_view_by_index'

view details

push time in 2 months

PR closed GeorgeElsham/ViewExtractor

Feature - get view by index

Updated README with example for how to use this feature.

+152 -29

0 comment

4 changed files

GeorgeElsham

pr closed time in 2 months

PR opened GeorgeElsham/ViewExtractor

Feature - get view by index

Updated README with example for how to use this feature.

+152 -29

0 comment

4 changed files

pr created time in 2 months

issue closedGeorgeElsham/ViewExtractor

Extract one view

First of all, thank you for creating this. It's very helpful.

I'm trying to reimplement SwiftUI's List using a UITableView since List is still very limited. Do you think there is any way to extract a single view from the tuple without loading all of the views? The issue I'm having is that running .getViews loads all of the views at once, but I'd like to let UITableView request views as it needs them.

I'm going to keep studying the code to try and find a way to do this, but I figured I'd ask in the meantime!

Thanks again.

Edit: It seems like it might be possible to return an array of view creators: [() -> AnyView], give that to UITableView, and let UITableView call the function at the index it needs for the view. Not sure if that's a good way to go about it. I'm still pretty new to Swift in general though and struggling to get it working generically. As just a really messy test I modified part of the code and watched what happens in the debugger:

public extension TupleView {
    var views: [AnyView] {
        let children = Mirror(reflecting: value).children

        // Test code
        let map = children.map { $0.value }
        var array: [() -> ModifiedContent<Teller, _FrameLayout>] = []
        map.forEach {
            let mirror = Mirror(reflecting: $0)
            if let data = mirror.descendant("data") as? Range<Int>,
               let content = mirror.descendant("content") as? (Int) -> ModifiedContent<Teller, _FrameLayout> {
                let z = data.map { data in { content(data) } }
                array.append(contentsOf: z)
            }
        }
        let test = array[5]()

        return children.flatMap { ViewExtractor.views(from: $0.value) }
    }
}

TableView {
            ForEach(0..<5) { index in
                Teller(index: index)
                    .frame(width: 100, height: 100)
            }
            ForEach(5..<5000) { index in
                Teller(index: index)
                    .frame(width: 100, height: 100)
            }
        }

This is creating a flat array of 5005 functions that all create Teller views (just a tiny view I made for testing). Memory usage seems to be pretty much the same regardless of if I have 5 views (functions) or 5000, so maybe something like this could work.

I think I'll try putting this in something like .getViewCreators() or something, and try to get it working generically. Not sure if this is a good way to go about what I'm trying to accomplish. Let me know if you can think of a better solution!

closed time in 2 months

ekerik220

issue commentGeorgeElsham/ViewExtractor

Extract one view

Similar solution implemented: https://github.com/GeorgeElsham/ViewExtractor/pull/4

ekerik220

comment created time in 2 months

PR closed GeorgeElsham/ViewExtractor

Reviewers
Add getViewCreators

Hey, not sure if you're even interested in adding getViewCreators functionality, but I'm making this PR in hopes that you might be able to provide some guidance, if that's alright! I think there's still some handling missing in my code.

  1. I see that extractContent() unpacks the view let newContent = content(element) and checks if it's EmptyView or not. I guess this isn't possible with getViewCreators since the idea is to not unpack the views yet. I wonder if this is a big problem? I'm not totally sure in what cases the view would be EmptyView.

  2. In views(from view: Any) it looks like if the view is not EmptyView or castable to DynamicViewContentProvider, you're doing some handling that I don't quite understand.

     return withUnsafeBytes(of: view) { ptr -> [AnyView] in
         let binded = ptr.bindMemory(to: GenericView.self)
         return binded.first?.anyView.map { [$0] } ?? []
     }
    

I'm not sure what case this is covering, and how I might adapt it to getViewCreators. It seems to be there to handle cases that are just simple views (like not ForEach)?

Edit: I've added some handling for (2) that seems to work. The issue is that it could possibly result in a view creator that returns AnyView(EmptyView()). This was already an issue though I guess as mentioned in (1). I suppose a user would have to check for the possibility of an EmptyView being returned. I'll have to think about it, but that might(?) be okay for my use case, but maybe not clear enough for other people to use, so maybe this can't be merged!

+49 -0

2 comments

1 changed file

ekerik220

pr closed time in 2 months

pull request commentGeorgeElsham/ViewExtractor

Add getViewCreators

I apologise for this taking so long - I actually had it all done for a little while, but forgot to commit it to the remote! I did a slightly different approach.

Although I like your approach, here's why I decided to do it slightly differently:

  1. Less repeated code
  2. Wanted to be clear that getting a view from a specific index is not checked - because we are getting the views lazily, we don't know at the time if the view we are getting is actually EmptyView or a ForEach view itself rather than the content inside of it

I really appreciate you writing this and your code helped influence this to be made. If you do have any enhancements/changes to make it easier to use, understand, or to have more flexibility, feel free to add it in a new issue or pull request.

The changes are now on main, but new changes should probably be in the feature/get_view_by_index branch.

Thank you for contributing! 🎉

ekerik220

comment created time in 2 months

push eventGeorgeElsham/ViewExtractor

George

commit sha c85ddbab25d11282239aac976b22041913cfb8c6

Gave example for lazy-loaded views.

view details

push time in 2 months

push eventGeorgeElsham/ViewExtractor

George

commit sha c233227f9e1fc11f2d7c34109e2c54c8a34235c8

Feature - get view by index (#6) * Ran SwiftFormat for consistent formatting. * Added comments on how the code works. * Improved checking for `EmptyView` and `ForEach` content. * Implemented way to get a specific view, without loading everything.

view details

push time in 2 months

create barnchGeorgeElsham/ViewExtractor

branch : feature/get_view_by_index

created branch time in 2 months

pull request commentGeorgeElsham/ViewExtractor

Add getViewCreators

I'll take a look at this, thank you!

ekerik220

comment created time in 2 months

issue commentGeorgeElsham/ViewExtractor

Extract one view

Thank you @ekerik220! Sounds like a good suggestion - I'll do some experimenting and see if I can get it working well.

ekerik220

comment created time in 2 months

startednisrulz/app-privacy-policy-generator

started time in 3 months