tera-ny / TegakiMarche

0 stars 0 forks source link

コンテンツ詳細の実装 #52

Open tera-ny opened 5 years ago

tera-ny commented 5 years ago

やりたいこと

工程

tera-ny commented 4 years ago

オーディオとピクチャーに対応したストアを用意したものの、最初はピクチャーオンリーで進めようと思う

tera-ny commented 4 years ago

ピクチャーオンリーとは言ったものの、PictureとAudioどちらもまともに設計をしていないので、テストを書きつつ、エンティティの再設計の時間を挟む

tera-ny commented 4 years ago

現状のコンテンツの構成

struct Content {
    enum ContentType: String {
        case audio
        case picture
    }
    private let id: String
    let title: String
    let thumbnailImageURL: URL
    let isPublished: Bool
    let type: ContentType
 }
struct Audio {
    let audioURL: URL
}
struct Picture {}
tera-ny commented 4 years ago

unsplash api

[
  {
    "id": "LBI7cgq3pbM",
    "created_at": "2016-05-03T11:00:28-04:00",
    "updated_at": "2016-07-10T11:00:01-05:00",
    "width": 5245,
    "height": 3497,
    "color": "#60544D",
    "likes": 12,
    "liked_by_user": false,
    "description": "A man drinking a coffee.",
    "user": {
      "id": "pXhwzz1JtQU",
      "username": "poorkane",
      "name": "Gilbert Kane",
      "portfolio_url": "https://theylooklikeeggsorsomething.com/",
      "bio": "XO",
      "location": "Way out there",
      "total_likes": 5,
      "total_photos": 74,
      "total_collections": 52,
      "instagram_username": "instantgrammer",
      "twitter_username": "crew",
      "profile_image": {
        "small": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=32&w=32",
        "medium": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=64&w=64",
        "large": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=128&w=128"
      },
      "links": {
        "self": "https://api.unsplash.com/users/poorkane",
        "html": "https://unsplash.com/poorkane",
        "photos": "https://api.unsplash.com/users/poorkane/photos",
        "likes": "https://api.unsplash.com/users/poorkane/likes",
        "portfolio": "https://api.unsplash.com/users/poorkane/portfolio"
      }
    },
    "current_user_collections": [ // The *current user's* collections that this photo belongs to.
      {
        "id": 206,
        "title": "Makers: Cat and Ben",
        "published_at": "2016-01-12T18:16:09-05:00",
        "updated_at": "2016-07-10T11:00:01-05:00",
        "curated": false,
        "cover_photo": null,
        "user": null
      },
      // ... more collections
    ],
    "urls": {
      "raw": "https://images.unsplash.com/face-springmorning.jpg",
      "full": "https://images.unsplash.com/face-springmorning.jpg?q=75&fm=jpg",
      "regular": "https://images.unsplash.com/face-springmorning.jpg?q=75&fm=jpg&w=1080&fit=max",
      "small": "https://images.unsplash.com/face-springmorning.jpg?q=75&fm=jpg&w=400&fit=max",
      "thumb": "https://images.unsplash.com/face-springmorning.jpg?q=75&fm=jpg&w=200&fit=max"
    },
    "links": {
      "self": "https://api.unsplash.com/photos/LBI7cgq3pbM",
      "html": "https://unsplash.com/photos/LBI7cgq3pbM",
      "download": "https://unsplash.com/photos/LBI7cgq3pbM/download",
      "download_location": "https://api.unsplash.com/photos/LBI7cgq3pbM/download"
    }
  },
  // ... more photos
]
tera-ny commented 4 years ago

とりあえず設計してみた

struct Picture {
    let contentURL: URL
    let country: String?
    let description: String?
    let creator: DocumentReference
    let simpleCreator: SimpleUser
    let links: [Link]
}
struct SimpleUser {
    let name: String
    let profileImage: URL?
    let description: String?
}
enum Link {
    case amazon(id: String)
    case youtube(id: String)
    case unsplash(id: String)
    case pixiv(id: String)
    case twitter(id: String)
}

Linkは調子乗って作ったけど、最初は機能させない方針で

tera-ny commented 4 years ago

とりあえず、最低限の実装は完了したので、一旦ストップ

テストはFirebase側の用意ができてから