Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion QVRWeekView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'QVRWeekView'
s.version = '0.15.1'
s.version = '0.15.2'
s.summary = 'QVRWeekView is a simple calendar week view with support for horizontal, vertical scrolling and zooming.'
s.swift_version = '5'

Expand Down
24 changes: 5 additions & 19 deletions QVRWeekView/Classes/Common/EventLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ class EventLayer: CALayer {
let tagName = eventTag.name
let tagColor = eventTag.color

let tagLower = tagName.lowercased()

// Try to load icon for any tag (automatically detects from Images.xcassets/tags/)
let iconImage = loadIconImage(named: tagLower)
// Try to load icon for the tag from app's Images.xcassets
let iconImage = loadIconImage(named: tagName)

// Check if tag is emoji-only
let isEmojiOnly = isEmoji(tagName)
Expand Down Expand Up @@ -226,25 +224,13 @@ class EventLayer: CALayer {
}

private func loadIconImage(named: String) -> UIImage? {
// Try to load from main app bundle under tags namespace (Images.xcassets/tags/)
// Load tag image from app's main bundle (Images.xcassets) with "tags/" prefix (e.g., "tags/BED")
if let image = UIImage(named: "tags/\(named)", in: Bundle.main, compatibleWith: nil) {
return image
}

// Try without namespace in main bundle
if let image = UIImage(named: named, in: Bundle.main, compatibleWith: nil) {
return image
}

// Try from framework bundle under tags namespace
let bundle = Bundle(for: EventLayer.self)

if let image = UIImage(named: "tags/\(named)", in: bundle, compatibleWith: nil) {
return image
}

// Try without namespace in framework bundle
if let image = UIImage(named: named, in: bundle, compatibleWith: nil) {
// Try with "Tags/" prefix (e.g., "Tags/BED")
if let image = UIImage(named: "Tags/\(named)", in: Bundle.main, compatibleWith: nil) {
return image
}

Expand Down
73 changes: 62 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,20 @@ Below is a table of all customizable properties of the `WeekView`

### Event Tags

Events support tags which are displayed at the bottom of event cells. Tags can be text labels or icons.
Events support tags which are displayed at the bottom of event cells. Tags can be displayed in three different ways:
1. **Icon images** from your app's Assets
2. **Emojis** (any unicode emoji)
3. **Text labels** with colored backgrounds

#### Using Tags

Add tags to events by passing a string array:
Add tags to events by passing tag objects:

```swift
let bedTag = EventTag(name: "BED", color: .blue)
let emojiTag = EventTag(name: "🎉", color: .clear)
let textTag = EventTag(name: "Important", color: .red)

let event = EventData(
id: "1",
title: "Meeting",
Expand All @@ -211,21 +218,65 @@ let event = EventData(
location: "Room 101",
color: .blue,
allDay: false,
tags: ["Work", "Important"]
tags: [bedTag, emojiTag, textTag]
)
```

#### Custom Tag Icons
#### Tag Types

**Icon Tags**
- Place image files (PNG, SVG, PDF) in your app's `Assets.xcassets`
- Create an Image Set folder with the tag name (e.g., `BED.imageset`)
- Add images to the set and set them to **Universal** (not Unassigned)
- Use the **exact folder name as the tag name** in code

The framework searches for icons in these locations:
- `Assets.xcassets/tags/TAGNAME`
- `Assets.xcassets/Tags/TAGNAME`

Example folder structure:
```
Assets.xcassets/
├── Tags/
│ ├── BED.imageset/
│ │ ├── bed.svg
│ │ └── Contents.json
│ ├── BEER.imageset/
│ │ ├── beer.svg
│ │ └── Contents.json
```

**Emoji Tags**
- Use any unicode emoji as the tag name
- Emojis are automatically detected and displayed as-is
- Emojis preserve their native colors and do not use the `color` parameter
- The `color` parameter is **ignored** for emoji tags

Example:
```swift
EventTag(name: "🎉", color: .clear) // color parameter ignored
EventTag(name: "⭐", color: .red) // color parameter ignored
```

**Text Tags**
- Any text that's not an emoji and doesn't have a matching icon image
- Displays with a colored background
- Use the `color` parameter to set the background color

Example:
```swift
EventTag(name: "Important", color: .red)
EventTag(name: "Work", color: .blue)
```

These tags will display as icons instead of text if you add them to your app's Assets.xcassets
#### Implementation Details

To add your own custom tag icons:
- Open your app's `Assets.xcassets`
- Add a new Image Set for each icon (e.g., "meeting", "personal")
- Add images to the image sets
- Use the **image set name as the tag name**
Tags are rendered in this order:
1. Check if a matching icon image exists in Assets
2. Check if the tag name is emoji-only
3. Display as a text label with color background

Tags without matching icons will be displayed as text tags with the event color.
Icon images are displayed without text, while text and emoji tags may include additional styling based on the event color.
Comment on lines +272 to +279
Copy link
Contributor

Choose a reason for hiding this comment

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

Hzo? Die moeten gewoon gerendered worden zoals de volgorde gegeven is. Hiermee kunnen we altijd later nog aanpassingen maken vanuit de native side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ik snap niet echt wat je bedoelt, maar die checkt gwn als die string dat die krijgt onder Tags staat in Images.xcassets, dan checkt ie als het een emoji is (want emojis worden zonder achtergrond en een beetje groter gerendered). Anders wordt het op de normale manier gerenderd.


## How it works

Expand Down